submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s455086798
p00683
Java
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Map; import java.util.PriorityQueue; import java.math.BigInteger; import java.math.BigDecimal; ?????????????? public class Main{ ?????? static final InputStream in=System.in; static final PrintWriter out=new PrintWriter(System.out); static final int INF=Integer.MAX_VALUE/2; static final long LINF=Long.MAX_VALUE/2; static int MAX=100000; static char[] str=new char[MAX+1]; ?????? public static void main(String[] args) throws IOException{ ????BufferedReader br=new BufferedReader(new InputStreamReader(in)); ????int n=Integer.parseInt(br.readLine()); ????while(n-->0){ ????????String line=br.readLine(); ????????int cur=0; ????????for(int i=0;i<=MAX;i++) str[i]='-'; ????????for(int i=0;i<line.length();i++) str[i]=line.charAt(i); ????????int m=Integer.parseInt(br.readLine()); ????????while(m-->0){ ????????????String[] com=br.readLine().split(" "); ????????????String com0=com[0]; ????????????String com1=com[1]; ????????????if("forward".equals(com0)){ ????????????????if("char".equals(com1)&&str[cur]!='-') cur++; ????????????????else{ ????????????????????while(str[cur]==' ') cur++; ????????????????????while(str[cur]!=' '&&str[cur]!='-') cur++; ????????????????} ????????????} ????????????else if("backward".equals(com0)){ ????????????????if("char".equals(com1)&&cur!=0) cur--; ????????????????else{ ????????????????????while(cur>0&&str[cur-1]==' ') cur--; ????????????????????while(cur>0&&str[cur-1]!=' ') cur--; ????????????????} ????????????} ????????????else if("insert".equals(com0)){ ????????????????if(com1.length()>2){ ????????????????????String insertionStr=com[1].substring(1,com1.length()-1); ????????????????????for(int i=MAX-insertionStr.length();i>=cur;i--){ ????????????????????????if(str[i]!='-') str[i+insertionStr.length()]=str[i]; ????????????????????} ????????????????????for(int i=0;i<insertionStr.length();i++){ ????????????????????????str[cur+i]=insertionStr.charAt(i); ????????????????????} ????????????????????cur+=insertionStr.length(); ????????????????} ????????????} ????????????else{ ????????????????if("char".equals(com1)&&str[cur]!='-'){ ????????????????????for(int i=cur;i<=MAX;i++){ ????????????????????????if(str[i]=='-') break; ????????????????????????str[i]=str[i+1]; ????????????????????} ????????????????} ????????????????else{ ????????????????????int cnt=cur; ????????????????????boolean flag=false; ????????????????????while(str[cnt]==' ') cnt++; ????????????????????while(str[cnt]!=' '&&str[cnt]!='-'){ ????????????????????????cnt++; ????????????????????????flag=true; ????????????????????} ????????????????????if(flag){ ????????????????????????for(int i=cnt;i<=MAX;i++){ ????????????????????????if(str[i-cnt+cur]=='-') break; ????????????????????????????str[i-cnt+cur]=str[i]; ????????????????????????} ????????????????????} ????????????????} ????????????} ????????} ????????for(int i=0;;i++){ ????????????if(i==cur) out.print("^"); ????????????if(str[i]=='-') break; ????????????out.print(str[i]); ????????} ????????out.println(); ????} out.flush(); } }
Main.java:17: error: class, interface, enum, or record expected ?????????????? ^ Main.java:19: error: illegal start of type ?????? ^ Main.java:26: error: illegal start of type ?????? ^ Main.java:28: error: illegal start of expression ????BufferedReader br=new BufferedReader(new InputStreamReader(in)); ^ Main.java:28: error: illegal start of expression ????BufferedReader br=new BufferedReader(new InputStreamReader(in)); ^ Main.java:28: error: illegal start of expression ????BufferedReader br=new BufferedReader(new InputStreamReader(in)); ^ Main.java:28: error: illegal start of expression ????BufferedReader br=new BufferedReader(new InputStreamReader(in)); ^ Main.java:28: error: : expected ????BufferedReader br=new BufferedReader(new InputStreamReader(in)); ^ Main.java:28: error: : expected ????BufferedReader br=new BufferedReader(new InputStreamReader(in)); ^ Main.java:29: error: illegal start of expression ????int n=Integer.parseInt(br.readLine()); ^ Main.java:29: error: illegal start of expression ????int n=Integer.parseInt(br.readLine()); ^ Main.java:29: error: illegal start of expression ????int n=Integer.parseInt(br.readLine()); ^ Main.java:29: error: illegal start of expression ????int n=Integer.parseInt(br.readLine()); ^ Main.java:29: error: '.class' expected ????int n=Integer.parseInt(br.readLine()); ^ Main.java:29: error: : expected ????int n=Integer.parseInt(br.readLine()); ^ Main.java:30: error: illegal start of expression ????while(n-->0){ ^ Main.java:30: error: illegal start of expression ????while(n-->0){ ^ Main.java:30: error: illegal start of expression ????while(n-->0){ ^ Main.java:30: error: illegal start of expression ????while(n-->0){ ^ Main.java:30: error: illegal start of expression ????while(n-->0){ ^ Main.java:31: error: illegal start of expression ????????String line=br.readLine(); ^ Main.java:31: error: illegal start of expression ????????String line=br.readLine(); ^ Main.java:31: error: illegal start of expression ????????String line=br.readLine(); ^ Main.java:31: error: illegal start of expression ????????String line=br.readLine(); ^ Main.java:31: error: illegal start of expression ????????String line=br.readLine(); ^ Main.java:31: error: illegal start of expression ????????String line=br.readLine(); ^ Main.java:31: error: illegal start of expression ????????String line=br.readLine(); ^ Main.java:31: error: illegal start of expression ????????String line=br.readLine(); ^ Main.java:31: error: : expected ????????String line=br.readLine(); ^ Main.java:31: error: : expected ????????String line=br.readLine(); ^ Main.java:32: error: illegal start of expression ????????int cur=0; ^ Main.java:32: error: illegal start of expression ????????int cur=0; ^ Main.java:32: error: illegal start of expression ????????int cur=0; ^ Main.java:32: error: illegal start of expression ????????int cur=0; ^ Main.java:32: error: illegal start of expression ????????int cur=0; ^ Main.java:32: error: illegal start of expression ????????int cur=0; ^ Main.java:32: error: illegal start of expression ????????int cur=0; ^ Main.java:32: error: illegal start of expression ????????int cur=0; ^ Main.java:32: error: '.class' expected ????????int cur=0; ^ Main.java:32: error: : expected ????????int cur=0; ^ Main.java:33: error: illegal start of expression ????????for(int i=0;i<=MAX;i++) str[i]='-'; ^ Main.java:33: error: illegal start of expression ????????for(int i=0;i<=MAX;i++) str[i]='-'; ^ Main.java:33: error: illegal start of expression ????????for(int i=0;i<=MAX;i++) str[i]='-'; ^ Main.java:33: error: illegal start of expression ????????for(int i=0;i<=MAX;i++) str[i]='-'; ^ Main.java:33: error: illegal start of expression ????????for(int i=0;i<=MAX;i++) str[i]='-'; ^ Main.java:33: error: illegal start of expression ????????for(int i=0;i<=MAX;i++) str[i]='-'; ^ Main.java:33: error: illegal start of expression ????????for(int i=0;i<=MAX;i++) str[i]='-'; ^ Main.java:33: error: illegal start of expression ????????for(int i=0;i<=MAX;i++) str[i]='-'; ^ Main.java:33: error: illegal start of expression ????????for(int i=0;i<=MAX;i++) str[i]='-'; ^ Main.java:34: error: illegal start of expression ????????for(int i=0;i<line.length();i++) str[i]=line.charAt(i); ^ Main.java:34: error: illegal start of expression ????????for(int i=0;i<line.length();i++) str[i]=line.charAt(i); ^ Main.java:34: error: illegal start of expression ????????for(int i=0;i<line.length();i++) str[i]=line.charAt(i); ^ Main.java:34: error: illegal start of expression ????????for(int i=0;i<line.length();i++) str[i]=line.charAt(i); ^ Main.java:34: error: illegal start of expression ????????for(int i=0;i<line.length();i++) str[i]=line.charAt(i); ^ Main.java:34: error: illegal start of expression ????????for(int i=0;i<line.length();i++) str[i]=line.charAt(i); ^ Main.java:34: error: illegal start of expression ????????for(int i=0;i<line.length();i++) str[i]=line.charAt(i); ^ Main.java:34: error: illegal start of expression ????????for(int i=0;i<line.length();i++) str[i]=line.charAt(i); ^ Main.java:34: error: illegal start of expression ????????for(int i=0;i<line.length();i++) str[i]=line.charAt(i); ^ Main.java:35: error: illegal start of expression ????????int m=Integer.parseInt(br.readLine()); ^ Main.java:35: error: illegal start of expression ????????int m=Integer.parseInt(br.readLine()); ^ Main.java:35: error: illegal start of expression ????????int m=Integer.parseInt(br.readLine()); ^ Main.java:35: error: illegal start of expression ????????int m=Integer.parseInt(br.readLine()); ^ Main.java:35: error: illegal start of expression ????????int m=Integer.parseInt(br.readLine()); ^ Main.java:35: error: illegal start of expression ????????int m=Integer.parseInt(br.readLine()); ^ Main.java:35: error: illegal start of expression ????????int m=Integer.parseInt(br.readLine()); ^ Main.java:35: error: illegal start of expression ????????int m=Integer.parseInt(br.readLine()); ^ Main.java:35: error: '.class' expected ????????int m=Integer.parseInt(br.readLine()); ^ Main.java:35: error: : expected ????????int m=Integer.parseInt(br.readLine()); ^ Main.java:36: error: illegal start of expression ????????while(m-->0){ ^ Main.java:36: error: illegal start of expression ????????while(m-->0){ ^ Main.java:36: error: illegal start of expression ????????while(m-->0){ ^ Main.java:36: error: illegal start of expression ????????while(m-->0){ ^ Main.java:36: error: illegal start of expression ????????while(m-->0){ ^ Main.java:36: error: illegal start of expression ????????while(m-->0){ ^ Main.java:36: error: illegal start of expression ????????while(m-->0){ ^ Main.java:36: error: illegal start of expression ????????while(m-->0){ ^ Main.java:36: error: illegal start of expression ????????while(m-->0){ ^ Main.java:37: error: illegal start of expression ????????????String[] com=br.readLine().split(" "); ^ Main.java:37: error: illegal start of expression ????????????String[] com=br.readLine().split(" "); ^ Main.java:37: error: illegal start of expression ????????????String[] com=br.readLine().split(" "); ^ Main.java:37: error: illegal start of expression ????????????String[] com=br.readLine().split(" "); ^ Main.java:37: error: illegal start of expression ????????????String[] com=br.readLine().split(" "); ^ Main.java:37: error: illegal start of expression ????????????String[] com=br.readLine().split(" "); ^ Main.java:37: error: illegal start of expression ????????????String[] com=br.readLine().split(" "); ^ Main.java:37: error: illegal start of expression ????????????String[] com=br.readLine().split(" "); ^ Main.java:37: error: illegal start of expression ????????????String[] com=br.readLine().split(" "); ^ Main.java:37: error: illegal start of expression ????????????String[] com=br.readLine().split(" "); ^ Main.java:37: error: illegal start of expression ????????????String[] com=br.readLine().split(" "); ^ Main.java:37: error: illegal start of expression ????????????String[] com=br.readLine().split(" "); ^ Main.java:37: error: '.class' expected ????????????String[] com=br.readLine().split(" "); ^ Main.java:37: error: : expected ????????????String[] com=br.readLine().split(" "); ^ Main.java:38: error: illegal start of expression ????????????String com0=com[0]; ^ Main.java:38: error: illegal start of expression ????????????String com0=com[0]; ^ Main.java:38: error: illegal start of expression ????????????String com0=com[0]; ^ Main.java:38: error: illegal start of expression ????????????String com0=com[0]; ^ Main.java:38: error: illegal start of expression ????????????String com0=com[0]; ^ Main.java:38: error: illegal start of expression ????????????String com0=com[0]; ^ Main.java:38: error: illegal start of expression ????????????String com0=com[0]; ^ Main.java:38: error: illegal start of expression ????????????String com0=com[0]; ^ Main.java:38: error: illegal start of expression ????????????String com0=com[0]; ^ 100 errors only showing the first 100 errors, of 1007 total; use -Xmaxerrs if you would like to see more printing javac parameters to: /w/javac.20260128_024943.args
s470212420
p00683
Java
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Map; import java.util.PriorityQueue; import java.util.StringTokenizer; import java.math.BigInteger; import java.math.BigDecimal; public class Main{ static final InputStream in=System.in; static final PrintWriter out=new PrintWriter(System.out); static final int INF=Integer.MAX_VALUE/2; static final long LINF=Long.MAX_VALUE/2; static int MAX=10000; static char[] str=new char[MAX+1]; public static void main(String[] args) throws IOException{ Scanner sc=new Scanner(in); int n=sc.nextInt(); sc.nextLine(); while(n-->0){ String line=sc.nextLine(); int cur=0; Arrays.fill(str,'-'); for(int i=0;i<line.length();i++) str[i]=line.charAt(i); int m=sc.nextInt(); sc.nextLine(); while(m-->0){ String com0=sc.next(); String com1=sc.next(); if("forward".equals(com0)){ if("char".equals(com1)){ if(str[cur]!='-') cur++; } else{ while(str[cur]==' ') cur++; while(str[cur]!=' '&&str[cur]!='-') cur++; } } else if("backward".equals(com0)){ if("char".equals(com1)){ if(cur>0) cur--; } else{ while(cur>0&&str[cur-1]==' ') cur--; while(cur>0&&str[cur-1]!=' ') cur--; } } else if("insert".equals(com0)){ if(com1.length()>2){ String insertionStr=com1.substring(1,com1.length()-1); for(int i=MAX-insertionStr.length();i>=cur;i--){ if(str[i]!='-') str[i+insertionStr.length()]=str[i]; } for(int i=0;i<insertionStr.length();i++){ str[cur+i]=insertionStr.charAt(i); } cur+=insertionStr.length(); } } else if("delete".equals(com0)){ if("char".equals(com1)){ if(str[cur]!='-'){ for(int i=cur;;i++){ if(str[i]=='-') break; str[i]=str[i+1]; } } } else{ int cnt=cur; while(str[cnt]==' ') cnt++; if(str[cnt]!='-'){ while(str[cnt]!=' '&&str[cnt]!='-') cnt++; for(int i=cur;;i++){ if(str[i]=='-') break; str[i]=str[i-cur+cnt]; } } } } } StringBuilder sb=new StringBuilder(); for(int i=0;;i++){ if(i==cur) sb.append("^"); if(str[i]=='-') break; sb.append(String.valueOf(str[i])); } out.println(sb); } out.flush(); } }
Main.java:29: error: cannot find symbol Scanner sc=new Scanner(in); ^ symbol: class Scanner location: class Main Main.java:29: error: cannot find symbol Scanner sc=new Scanner(in); ^ symbol: class Scanner location: class Main 2 errors
s169033657
p00683
Java
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Map; import java.util.PriorityQueue; import java.util.StringTokenizer; import java.math.BigInteger; import java.math.BigDecimal; public class Main{ static final InputStream in=System.in; static final PrintWriter out=new PrintWriter(System.out); static final int INF=Integer.MAX_VALUE/2; static final long LINF=Long.MAX_VALUE/2; static int MAX=1000; static char[] str=new char[MAX+1]; public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(in)); int n=Integer.parseInt(br.readLine()); while(n-->0){ String line=br.readLine(); int cur=0; Arrays.fill(str,'-'); for(int i=0;i<line.length();i++) str[i]=line.charAt(i); int m=Integer.parseInt(br.readLine()); while(m-->0){ String com=br.readLine(); String com0=com.split(" ")[0]; String com1=com.split(" ")[1]; if("forward".equals(com0)){ if("char".equals(com1)){ if(str[cur]!='-') cur++; } else if("word".equals(com1)){ while(str[cur]==' ') cur++; while(str[cur]!=' '&&str[cur]!='-') cur++; } } else if("backward".equals(com0)){ if("char".equals(com1)){ if(cur>0) cur--; } else if("word".equals(com1)){ while(cur>0&&str[cur-1]==' ') cur--; while(cur>0&&str[cur-1]!=' ') cur--; } } else if("insert".equals(com0)){ String insertionStr="=com.substring(8,(com.length()-1)); for(int i=MAX-insertionStr.length();i>=cur;i--){ if(str[i]!='-') str[i+insertionStr.length()]=str[i]; } for(int i=0;i<insertionStr.length();i++){ str[cur+i]=insertionStr.charAt(i); } cur+=insertionStr.length(); } else if("delete".equals(com0)){ if("char".equals(com1)){ if(str[cur]!='-'){ for(int i=cur;;i++){ if(str[i]=='-') break; str[i]=str[i+1]; } } } else if("word".equals(com1)){ int cnt=cur; while(str[cnt]==' ') cnt++; if(str[cnt]!='-'){ while(str[cnt]!=' '&&str[cnt]!='-') cnt++; for(int i=cur;;i++){ if(str[i]=='-') break; str[i]=str[i-cur+cnt]; } } } } } StringBuilder sb=new StringBuilder(); for(int i=0;;i++){ if(i==cur) sb.append("^"); if(str[i]=='-') break; sb.append(String.valueOf(str[i])); } out.println(sb); out.flush(); } } }
Main.java:60: error: unclosed string literal String insertionStr="=com.substring(8,(com.length()-1)); ^ 1 error
s144235240
p00683
Java
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Deque; import java.util.HashMap; import java.util.InputMismatchException; import java.util.Map; import java.util.PriorityQueue; import java.util.StringTokenizer; import java.math.BigInteger; import java.math.BigDecimal; public class Main{ static final InputStream in=System.in; static final PrintWriter out=new PrintWriter(System.out); static final int INF=Integer.MAX_VALUE/2; static final long LINF=Long.MAX_VALUE/2; static int MAX=1000; static char[] str=new char[MAX+1]; public static void main(String[] args) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(in)); int n=Integer.parseInt(br.readLine()); while(n-->0){ String line=br.readLine(); int cur=0; Arrays.fill(str,'-'); for(int i=0;i<line.length();i++) str[i]=line.charAt(i); int m=Integer.parseInt(br.readLine()); while(m-->0){ String com=br.readLine(); String com0=com.split(" ")[0]; String com1=com.split(" ")[1]; if("forward".equals(com0)){ if("char".equals(com1)){ if(str[cur]!='-') cur++; } else if("word".equals(com1)){ while(str[cur]==' ') cur++; while(str[cur]!=' '&&str[cur]!='-') cur++; } } else if("backward".equals(com0)){ if("char".equals(com1)){ if(cur>0) cur--; } else if("word".equals(com1)){ while(cur>0&&str[cur-1]==' ') cur--; while(cur>0&&str[cur-1]!=' ') cur--; } } else if("insert".equals(com0)){ String insertionStr="=com.substring(8,com.length()-1); for(int i=MAX-insertionStr.length();i>=cur;i--){ if(str[i]!='-') str[i+insertionStr.length()]=str[i]; } for(int i=0;i<insertionStr.length();i++){ str[cur+i]=insertionStr.charAt(i); } cur+=insertionStr.length(); } else if("delete".equals(com0)){ if("char".equals(com1)){ if(str[cur]!='-'){ for(int i=cur;;i++){ if(str[i]=='-') break; str[i]=str[i+1]; } } } else if("word".equals(com1)){ int cnt=cur; while(str[cnt]==' ') cnt++; if(str[cnt]!='-'){ while(str[cnt]!=' '&&str[cnt]!='-') cnt++; for(int i=cur;;i++){ if(str[i]=='-') break; str[i]=str[i-cur+cnt]; } } } } } StringBuilder sb=new StringBuilder(); for(int i=0;;i++){ if(i==cur) sb.append("^"); if(str[i]=='-') break; sb.append(String.valueOf(str[i])); } out.println(sb); out.flush(); } } }
Main.java:60: error: unclosed string literal String insertionStr="=com.substring(8,com.length()-1); ^ 1 error
s757710336
p00683
Java
import java.io.InputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.math.BigInteger; public class Main{ static PrintWriter out; static InputReader ir; static void solve(){ int n=ir.nextInt(); while(n-->0){ String s=ir.next(); int cur=0; Arrays.fill(str,'-'); for(int i=0;i<s.length();i++) str[i]=s.charAt(i); int m=ir.nextInt(); while(m-->0){ String com0=ir.next(),com1=ir.next(); if("forward".equals(com0)){ if("char".equals(com1)){ if(str[cur]!='-') cur++; } else if("word".equals(com1)){ while(str[cur]==' ') cur++; while(str[cur]!=' '&&str[cur]!='-') cur++; } } else if("backward".equals(com0)){ if("char".equals(com1)){ if(cur>0) cur--; } else if("word".equals(com1)){ while(cur>0&&str[cur-1]==' ') cur--; while(cur>0&&str[cur-1]!=' ') cur--; } } else if("insert".equals(com0)){ if(com1.length()>2){ String insertionStr=com1.substring(1,com1.length()-1); for(int i=MAX-insertionStr.length();i>=cur;i--){ if(str[i]!='-') str[i+insertionStr.length()]=str[i]; } for(int i=0;i<insertionStr.length();i++){ str[cur+i]=insertionStr.charAt(i); } cur+=insertionStr.length(); } } else if("delete".equals(com0)){ if("char".equals(com1)){ if(str[cur]!='-'){ for(int i=cur;;i++){ if(str[i]=='-') break; str[i]=str[i+1]; } } } else if("word".equals(com1)){ int cnt=cur; while(str[cnt]==' ') cnt++; if(str[cnt]!='-'){ while(str[cnt]!=' '&&str[cnt]!='-') cnt++; for(int i=cur;;i++){ if(str[i]=='-') break; str[i]=str[i-cur+cnt]; } } } } } StringBuilder sb=new StringBuilder(); for(int i=0;;i++){ if(i==cur) sb.append("^"); if(str[i]=='-') break; sb.append(String.valueOf(str[i])); } out.println(sb); } } public static void main(String[] args) throws Exception{ ir=new InputReader(System.in); out=new PrintWriter(System.out); solve(); out.flush(); } static class InputReader { private InputStream in; private byte[] buffer=new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;} public boolean hasNextByte() { if(curbuf>=lenbuf){ curbuf= 0; try{ lenbuf=in.read(buffer); }catch(IOException e) { throw new InputMismatchException(); } if(lenbuf<=0) return false; } return true; } private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;} private boolean isSpaceChar(int c){return !(c>=33&&c<=126);} private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;} public boolean hasNext(){skip(); return hasNextByte();} public String next(){ if(!hasNext()) throw new NoSuchElementException(); StringBuilder sb=new StringBuilder(); int b=readByte(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString(); } public int nextInt() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } int res=0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public long nextLong() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } long res = 0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public double nextDouble(){return Double.parseDouble(next());} public BigInteger nextBigInteger(){return new BigInteger(next());} public int[] nextIntArray(int n){ int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=nextInt(); return a; } public long[] nextLongArray(int n){ long[] a=new long[n]; for(int i=0;i<n;i++) a[i]=nextLong(); return a; } public char[][] nextCharMap(int n,int m){ char[][] map=new char[n][m]; for(int i=0;i<n;i++) map[i]=next().toCharArray(); return map; } } }
Main.java:21: error: cannot find symbol Arrays.fill(str,'-'); ^ symbol: variable str location: class Main Main.java:22: error: cannot find symbol for(int i=0;i<s.length();i++) str[i]=s.charAt(i); ^ symbol: variable str location: class Main Main.java:28: error: cannot find symbol if(str[cur]!='-') cur++; ^ symbol: variable str location: class Main Main.java:31: error: cannot find symbol while(str[cur]==' ') cur++; ^ symbol: variable str location: class Main Main.java:32: error: cannot find symbol while(str[cur]!=' '&&str[cur]!='-') cur++; ^ symbol: variable str location: class Main Main.java:32: error: cannot find symbol while(str[cur]!=' '&&str[cur]!='-') cur++; ^ symbol: variable str location: class Main Main.java:40: error: cannot find symbol while(cur>0&&str[cur-1]==' ') cur--; ^ symbol: variable str location: class Main Main.java:41: error: cannot find symbol while(cur>0&&str[cur-1]!=' ') cur--; ^ symbol: variable str location: class Main Main.java:47: error: cannot find symbol for(int i=MAX-insertionStr.length();i>=cur;i--){ ^ symbol: variable MAX location: class Main Main.java:48: error: cannot find symbol if(str[i]!='-') str[i+insertionStr.length()]=str[i]; ^ symbol: variable str location: class Main Main.java:48: error: cannot find symbol if(str[i]!='-') str[i+insertionStr.length()]=str[i]; ^ symbol: variable str location: class Main Main.java:48: error: cannot find symbol if(str[i]!='-') str[i+insertionStr.length()]=str[i]; ^ symbol: variable str location: class Main Main.java:51: error: cannot find symbol str[cur+i]=insertionStr.charAt(i); ^ symbol: variable str location: class Main Main.java:58: error: cannot find symbol if(str[cur]!='-'){ ^ symbol: variable str location: class Main Main.java:60: error: cannot find symbol if(str[i]=='-') break; ^ symbol: variable str location: class Main Main.java:61: error: cannot find symbol str[i]=str[i+1]; ^ symbol: variable str location: class Main Main.java:61: error: cannot find symbol str[i]=str[i+1]; ^ symbol: variable str location: class Main Main.java:67: error: cannot find symbol while(str[cnt]==' ') cnt++; ^ symbol: variable str location: class Main Main.java:68: error: cannot find symbol if(str[cnt]!='-'){ ^ symbol: variable str location: class Main Main.java:69: error: cannot find symbol while(str[cnt]!=' '&&str[cnt]!='-') cnt++; ^ symbol: variable str location: class Main Main.java:69: error: cannot find symbol while(str[cnt]!=' '&&str[cnt]!='-') cnt++; ^ symbol: variable str location: class Main Main.java:71: error: cannot find symbol if(str[i]=='-') break; ^ symbol: variable str location: class Main Main.java:72: error: cannot find symbol str[i]=str[i-cur+cnt]; ^ symbol: variable str location: class Main Main.java:72: error: cannot find symbol str[i]=str[i-cur+cnt]; ^ symbol: variable str location: class Main Main.java:81: error: cannot find symbol if(str[i]=='-') break; ^ symbol: variable str location: class Main Main.java:82: error: cannot find symbol sb.append(String.valueOf(str[i])); ^ symbol: variable str location: class Main 26 errors
s173447496
p00683
Java
import java.io.InputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.math.BigInteger; public class Main{ static PrintWriter out; static InputReader ir; static void solve(){ int n=ir.nextInt(); while(n-->0){ String s=ir.next(); int cur=0; char[] str=new char[1501]; Arrays.fill(str,'-'); for(int i=0;i<s.length();i++) str[i]=s.charAt(i); int m=ir.nextInt(); while(m-->0){ String com0=ir.next(),com1=ir.next(); if("forward".equals(com0)){ if("char".equals(com1)){ if(str[cur]!='-') cur++; } else if("word".equals(com1)){ while(str[cur]==' ') cur++; while(str[cur]!=' '&&str[cur]!='-') cur++; } } else if("backward".equals(com0)){ if("char".equals(com1)){ if(cur>0) cur--; } else if("word".equals(com1)){ while(cur>0&&str[cur-1]==' ') cur--; while(cur>0&&str[cur-1]!=' ') cur--; } } else if("insert".equals(com0)){ if(com1.length()>2){ String insertionStr=com1.substring(1,com1.length()-1); for(int i=MAX-insertionStr.length();i>=cur;i--){ if(str[i]!='-') str[i+insertionStr.length()]=str[i]; } for(int i=0;i<insertionStr.length();i++){ str[cur+i]=insertionStr.charAt(i); } cur+=insertionStr.length(); } } else if("delete".equals(com0)){ if("char".equals(com1)){ if(str[cur]!='-'){ for(int i=cur;;i++){ if(str[i]=='-') break; str[i]=str[i+1]; } } } else if("word".equals(com1)){ int cnt=cur; while(str[cnt]==' ') cnt++; if(str[cnt]!='-'){ while(str[cnt]!=' '&&str[cnt]!='-') cnt++; for(int i=cur;;i++){ if(str[i]=='-') break; str[i]=str[i-cur+cnt]; } } } } } StringBuilder sb=new StringBuilder(); for(int i=0;;i++){ if(i==cur) sb.append("^"); if(str[i]=='-') break; sb.append(String.valueOf(str[i])); } out.println(sb); } } public static void main(String[] args) throws Exception{ ir=new InputReader(System.in); out=new PrintWriter(System.out); solve(); out.flush(); } static class InputReader { private InputStream in; private byte[] buffer=new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;} public boolean hasNextByte() { if(curbuf>=lenbuf){ curbuf= 0; try{ lenbuf=in.read(buffer); }catch(IOException e) { throw new InputMismatchException(); } if(lenbuf<=0) return false; } return true; } private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;} private boolean isSpaceChar(int c){return !(c>=33&&c<=126);} private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;} public boolean hasNext(){skip(); return hasNextByte();} public String next(){ if(!hasNext()) throw new NoSuchElementException(); StringBuilder sb=new StringBuilder(); int b=readByte(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString(); } public int nextInt() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } int res=0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public long nextLong() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } long res = 0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public double nextDouble(){return Double.parseDouble(next());} public BigInteger nextBigInteger(){return new BigInteger(next());} public int[] nextIntArray(int n){ int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=nextInt(); return a; } public long[] nextLongArray(int n){ long[] a=new long[n]; for(int i=0;i<n;i++) a[i]=nextLong(); return a; } public char[][] nextCharMap(int n,int m){ char[][] map=new char[n][m]; for(int i=0;i<n;i++) map[i]=next().toCharArray(); return map; } } }
Main.java:48: error: cannot find symbol for(int i=MAX-insertionStr.length();i>=cur;i--){ ^ symbol: variable MAX location: class Main 1 error
s858874134
p00683
Java
import java.io.InputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.math.BigInteger; public class Main{ static PrintWriter out; static InputReader ir; static void solve(){ int n=ir.nextInt(); while(n-->0){ String s=ir.next(); int cur=0,MAX=1500 char[] str=new char[MAX+1]; Arrays.fill(str,'-'); for(int i=0;i<s.length();i++) str[i]=s.charAt(i); int m=ir.nextInt(); while(m-->0){ String com0=ir.next(),com1=ir.next(); if("forward".equals(com0)){ if("char".equals(com1)){ if(str[cur]!='-') cur++; } else if("word".equals(com1)){ while(str[cur]==' ') cur++; while(str[cur]!=' '&&str[cur]!='-') cur++; } } else if("backward".equals(com0)){ if("char".equals(com1)){ if(cur>0) cur--; } else if("word".equals(com1)){ while(cur>0&&str[cur-1]==' ') cur--; while(cur>0&&str[cur-1]!=' ') cur--; } } else if("insert".equals(com0)){ if(com1.length()>2){ String insertionStr=com1.substring(1,com1.length()-1); for(int i=MAX-insertionStr.length();i>=cur;i--){ if(str[i]!='-') str[i+insertionStr.length()]=str[i]; } for(int i=0;i<insertionStr.length();i++){ str[cur+i]=insertionStr.charAt(i); } cur+=insertionStr.length(); } } else if("delete".equals(com0)){ if("char".equals(com1)){ if(str[cur]!='-'){ for(int i=cur;;i++){ if(str[i]=='-') break; str[i]=str[i+1]; } } } else if("word".equals(com1)){ int cnt=cur; while(str[cnt]==' ') cnt++; if(str[cnt]!='-'){ while(str[cnt]!=' '&&str[cnt]!='-') cnt++; for(int i=cur;;i++){ if(str[i]=='-') break; str[i]=str[i-cur+cnt]; } } } } } StringBuilder sb=new StringBuilder(); for(int i=0;;i++){ if(i==cur) sb.append("^"); if(str[i]=='-') break; sb.append(String.valueOf(str[i])); } out.println(sb); } } public static void main(String[] args) throws Exception{ ir=new InputReader(System.in); out=new PrintWriter(System.out); solve(); out.flush(); } static class InputReader { private InputStream in; private byte[] buffer=new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;} public boolean hasNextByte() { if(curbuf>=lenbuf){ curbuf= 0; try{ lenbuf=in.read(buffer); }catch(IOException e) { throw new InputMismatchException(); } if(lenbuf<=0) return false; } return true; } private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;} private boolean isSpaceChar(int c){return !(c>=33&&c<=126);} private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;} public boolean hasNext(){skip(); return hasNextByte();} public String next(){ if(!hasNext()) throw new NoSuchElementException(); StringBuilder sb=new StringBuilder(); int b=readByte(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString(); } public int nextInt() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } int res=0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public long nextLong() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } long res = 0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public double nextDouble(){return Double.parseDouble(next());} public BigInteger nextBigInteger(){return new BigInteger(next());} public int[] nextIntArray(int n){ int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=nextInt(); return a; } public long[] nextLongArray(int n){ long[] a=new long[n]; for(int i=0;i<n;i++) a[i]=nextLong(); return a; } public char[][] nextCharMap(int n,int m){ char[][] map=new char[n][m]; for(int i=0;i<n;i++) map[i]=next().toCharArray(); return map; } } }
Main.java:20: error: ';' expected int cur=0,MAX=1500 ^ 1 error
s599291389
p00683
C
#include <cstdio> #include <cctype> #include <cstring> #include <string> #define MIN(A,B) \ ( (B) < (A) ? (B) : (A) ) #define MAX(A,B) \ ( (B) > (A) ? (B) : (A) ) using namespace std; /** Application main entry point. */ int main ( int argc, char * argv[ ] ) { char buf[ 256 ]; int n; fgets ( buf, sizeof ( buf ), stdin ); sscanf ( buf, "%d", &n ); while ( n-- ) { string res; int m; int p = 0; fgets ( buf, sizeof ( buf ), stdin ); *( strchr ( buf, '\n' ) ) = '\0'; res.assign ( buf ); fgets ( buf, sizeof ( buf ), stdin ); sscanf ( buf, "%d", &m ); while ( m-- ) { fgets ( buf, sizeof ( buf ), stdin ); if ( !strncmp ( buf, "forward char", 12 ) ) { ++p; p = MIN( p, res.size ( ) ); continue ; } if ( !strncmp ( buf, "backward char", 13 ) ) { --p; p = MAX( p, 0 ); continue ; } if ( !strncmp ( buf, "forward word", 12 ) ) { while ( p < res.size ( ) && isspace ( res[ p ] ) ) ++p; while ( p < res.size ( ) && !isspace ( res[ p ] ) ) ++p; continue ; } if ( !strncmp ( buf, "backward word", 13 ) ) { while ( p > 0 && isspace ( res[ p - 1 ] ) ) --p; while ( p > 0 && !isspace ( res[ p - 1 ] ) ) --p; continue ; } if ( !strncmp ( buf, "insert", 6 ) ) { *( strrchr ( buf, '\"' ) ) = '\0'; res.insert ( p, strchr ( buf, '\"' ) + 1 ); p += strlen ( strchr ( buf, '\"' ) + 1 ); continue ; } if ( !strncmp ( buf, "delete char", 11 ) ) { if ( p < res.size ( ) ) res.erase ( p, 1 ); continue ; } if ( !strncmp ( buf, "delete word", 11 ) ) { int q = p; while ( q < res.size ( ) && isspace ( res[ q ] ) ) ++q; while ( q < res.size ( ) && !isspace ( res[ q ] ) ) ++q; res.erase ( p, q - p ); continue ; } } printf ( "%s^%s\n" , res.substr ( 0, p ).c_str ( ) , res.substr ( p, res.size ( ) - p ).c_str ( ) ); } return ( 0 ); }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s564671327
p00683
C++
3 A sample input 9 forward word delete char forward word delete char forward word delete char backward word backward word forward word Hallow, Word. 7 forward char delete word insert "ello, " forward word backward char backward char insert "l" 3 forward word backward word delete word
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 3 | ^
s872430847
p00683
C++
#include <iostream> #include <stdlib> #include <string> using namespace std; int main() { int N,n,c; string str,cmd; getline(cin,cmd); N=atoi(cmd.c_str()); while(N--) { c=0; getline(cin,str); getline(cin,cmd); n=atoi(cmd.c_str()); while(n--) { getline(cin,cmd); if(cmd=="forward char") { if(c<str.size()) c++; } else if(cmd=="forward word") { bool ws = false; while(c<str.size()) { if(str[c]!=' ') { ws=true; } else if(ws) { break; } c++; } } else if(cmd=="backward char") { if(0<c) c--; } else if(cmd=="backward word") { bool ws = false; while(0<c) { if(str[c]!=' ') { ws=true; } else if(ws) { break; } c--; } } else if(cmd=="delete char") { if(c<str.size()) str.erase(str.begin()+c); } else if(cmd=="delete word") { int t=c; bool ws=false; while(t<str.size()) { if(str[t]!=' ') { ws=true; } else if(ws) { break; } t++; } if(ws) { str.erase(str.begin()+c,str.begin()+t); } } else { cmd.erase(0,8); cmd.erase(cmd.end()-1); str.insert(c,cmd); c += cmd.size(); } } str.insert(c,"^"); cout << str << endl; } }
a.cc:2:10: fatal error: stdlib: No such file or directory 2 | #include <stdlib> | ^~~~~~~~ compilation terminated.
s872045397
p00683
C++
{ string str; char c; c = _space(); if (c == '\n') return str; do { str+=c; } while ((c = getchar()) != '\n'); return string(str); } string nextQuote() { space(); char c; string str = ""; while ((c = getchar()) != '"') { str += c; } return str; } int main() { int nTest; scanf("%d ",&nTest); //cout << nTest << endl; for (int testIdx = 0; testIdx < nTest; testIdx++) { string text = nextLine(); //cout << text << endl; // cin.ignore(); int N; scanf(" %d ", &N); //cout << "N = " << N << endl; //cin.ignore(); int cur = 0; for (int i = 0; i < N; i++) { string cmd, arg; cmd = nextStr(); if (cmd == "forward") { arg = nextStr(); if (arg == "char") { if (cur < text.size()) { cur++; } } else { while (cur < text.size() && isblank(text[cur])) {cur++;} while (cur < text.size() && !isblank(text[cur])) {cur++;} } } else if (cmd == "backward") { arg = nextStr(); if (arg == "char") { if (cur > 0) { cur--; } } else { while (cur > 0 && !isblank(text[cur])) {cur--;} //while (cur > 0 && isblank(text[cur])) {cur--;} } } else if (cmd == "insert") { arg = nextQuote(); text.insert(text.begin() + cur, arg.begin(), arg.end()); cur += arg.size(); } else if (cmd == "delete") { arg = nextStr(); if (arg == "char") { if (cur < text.size()) { text.erase(text.begin() + cur); } } else { while (cur < text.size() && isblank(text[cur])) { text.erase(text.begin() + cur); } while (cur < text.size() && !isblank(text[cur])) { text.erase(text.begin() + cur); } /* */ } } //cout << "cmd, arg = " << cmd << ", " << arg << endl; //cout << "cur = " << cur << endl; //cout << text << endl; } for (int i = 0; i < cur; i++) { cout << text[i]; } cout << "^"; for (int i = cur; i < text.size(); i++) { cout << text[i]; } cout << endl; } return 0; }
a.cc:1:1: error: expected unqualified-id before '{' token 1 | { | ^ a.cc:13:1: error: 'string' does not name a type 13 | string nextQuote() | ^~~~~~ a.cc: In function 'int main()': a.cc:27:3: error: 'scanf' was not declared in this scope 27 | scanf("%d ",&nTest); | ^~~~~ a.cc:31:5: error: 'string' was not declared in this scope 31 | string text = nextLine(); | ^~~~~~ a.cc:41:13: error: expected ';' before 'cmd' 41 | string cmd, arg; | ^~~~ | ; a.cc:42:7: error: 'cmd' was not declared in this scope 42 | cmd = nextStr(); | ^~~ a.cc:42:13: error: 'nextStr' was not declared in this scope 42 | cmd = nextStr(); | ^~~~~~~ a.cc:44:9: error: 'arg' was not declared in this scope 44 | arg = nextStr(); | ^~~ a.cc:46:21: error: 'text' was not declared in this scope 46 | if (cur < text.size()) { | ^~~~ a.cc:50:24: error: 'text' was not declared in this scope 50 | while (cur < text.size() && isblank(text[cur])) {cur++;} | ^~~~ a.cc:50:39: error: 'isblank' was not declared in this scope 50 | while (cur < text.size() && isblank(text[cur])) {cur++;} | ^~~~~~~ a.cc:51:24: error: 'text' was not declared in this scope 51 | while (cur < text.size() && !isblank(text[cur])) {cur++;} | ^~~~ a.cc:51:40: error: 'isblank' was not declared in this scope 51 | while (cur < text.size() && !isblank(text[cur])) {cur++;} | ^~~~~~~ a.cc:54:9: error: 'arg' was not declared in this scope 54 | arg = nextStr(); | ^~~ a.cc:60:38: error: 'text' was not declared in this scope 60 | while (cur > 0 && !isblank(text[cur])) {cur--;} | ^~~~ a.cc:60:30: error: 'isblank' was not declared in this scope 60 | while (cur > 0 && !isblank(text[cur])) {cur--;} | ^~~~~~~ a.cc:64:9: error: 'arg' was not declared in this scope 64 | arg = nextQuote(); | ^~~ a.cc:64:15: error: 'nextQuote' was not declared in this scope 64 | arg = nextQuote(); | ^~~~~~~~~ a.cc:65:9: error: 'text' was not declared in this scope 65 | text.insert(text.begin() + cur, arg.begin(), arg.end()); | ^~~~ a.cc:68:9: error: 'arg' was not declared in this scope 68 | arg = nextStr(); | ^~~ a.cc:70:21: error: 'text' was not declared in this scope 70 | if (cur < text.size()) { | ^~~~ a.cc:74:24: error: 'text' was not declared in this scope 74 | while (cur < text.size() && isblank(text[cur])) { | ^~~~ a.cc:74:39: error: 'isblank' was not declared in this scope 74 | while (cur < text.size() && isblank(text[cur])) { | ^~~~~~~ a.cc:77:24: error: 'text' was not declared in this scope 77 | while (cur < text.size() && !isblank(text[cur])) { | ^~~~ a.cc:77:40: error: 'isblank' was not declared in this scope 77 | while (cur < text.size() && !isblank(text[cur])) { | ^~~~~~~ a.cc:89:7: error: 'cout' was not declared in this scope 89 | cout << text[i]; | ^~~~ a.cc:89:15: error: 'text' was not declared in this scope 89 | cout << text[i]; | ^~~~ a.cc:91:5: error: 'cout' was not declared in this scope 91 | cout << "^"; | ^~~~ a.cc:92:27: error: 'text' was not declared in this scope 92 | for (int i = cur; i < text.size(); i++) { | ^~~~ a.cc:95:13: error: 'endl' was not declared in this scope 95 | cout << endl; | ^~~~
s306400747
p00683
C++
using namespace std; #include <iostream> #include <vector> #include <string.h> #include <string> #define REP(i, n) for(int i=0; i<n; i++) typedef vector<int> VI; int T, N; string text; string cmd; string tmp; void execute(string& text, string cmd) { if(cmd == "forward char"){ REP(i, text.size()) { if(text[i] == '^') { if(i != text.size()-1) { text[i] = text[i+1]; text[i+1] = '^'; break; } } } } else if(cmd =="forward word") { int iCaret = -1; REP(i, text.size()) { if(text[i] == '^') { iCaret = i; continue; } if(text[i] == ' ' && iCaret != -1) { if(i != 0) { if(text[i-1] == ' ' || text[i-1] == '^') { continue; } } text.insert(text.begin()+i, '^'); text.erase(text.begin()+iCaret); break; } if(i == text.size()-1 && iCaret != -1) { text.insert(text.end(), '^'); text.erase(text.begin()+iCaret); break; } } } else if(cmd == "backward char") { REP(i, text.size()) { if(text[i] == '^') { if(i != 0) { text[i] = text[i-1]; text[i-1] = '^'; } } } } else if(cmd == "backward word") { int iCaret = -1; for(int i=text.size()-1; i>=0; i--) { if(text[i] == '^') { iCaret = i; continue; } if(text[i] == ' ' && iCaret != -1) { if(i != text.size()-1) { if(text[i+1] == ' ' || text[i+1] == '^') { continue; } } text.erase(text.begin() + iCaret); text.insert(text.begin() + i, '^'); break; } if(i == 0 && iCaret != -1) { text.erase(text.begin() + iCaret); text.insert(text.begin(), '^'); break; } } } else if(cmd == "delete char") { REP(i, text.size()) { if(text[i] == '^') { if(i != text.size()-1) { text.erase(text.begin() + i+1); } } } } else if(cmd == "delete word") { int first = 0; int last = 0; REP(i, text.size()) { if(text[i] == '^') { < first = i; } if((text[i] == ' ' || i == text.size()-1) && first != 0) { if(i != 0) { if(text[i-1] == ' ' || text[i-1] == ' ') { continue; } } text.erase(text.begin()+first+1, text.begin()+i); } } } else { bool is_insert = true; string str_insert = "insert"; REP(i, str_insert.size()) { if(str_insert[i] != cmd[i]) { is_insert = false; break; } } if(is_insert) { string word_insert = string(cmd, str_insert.size()+2, cmd.size()-str_insert.size()-3); std::copy(cmd.begin()+str_insert.size()+2, cmd.end()-1, word_insert.begin()); cout << word_insert << endl; REP(i, text.size()) { if(text[i] == '^') { text.insert(i, word_insert); break; } } } } } int main() { getline(cin, tmp); T = atoi(tmp.c_str()); REP(t, T) { getline(cin, text); text = "^" + text; cout << text << endl; getline(cin, tmp); N = atoi(tmp.c_str()); REP(n, N) { getline(cin, cmd); execute(text, cmd); cout << text << endl; } } }
a.cc: In function 'void execute(std::string&, std::string)': a.cc:135:25: error: expected primary-expression before '<' token 135 | < first = i; | ^
s081347466
p00683
C++
#include <cstdio> #include <iostream> #include <string> #include <cmath> using namespace std; int main(){ int n; cin>>n; for(int i=0;i<n;i++){ char b[1009]; gets(b); gets(b); string buf(b); //cout << "buf is " << buf << endl; int pos=0; int cn; cin>>cn; for(int k=0;k<cn;k++){ string command; cin >> command; if(command=="forward"){ cin >> command; if(command=="char"){ if(!buf.empty()) pos = min(pos+1,(int)buf.size()); }else{ // word while(buf[pos]==' ' && pos < buf.size())pos++; while(buf[pos]!=' ' && pos < buf.size())pos++; } }else if(command=="backward"){ cin >> command; if(command=="char"){ if(!buf.empty()) pos = max(pos-1,0); }else{ // word while(buf[pos]==' ' && pos > 0)pos--; while(buf[pos]!=' ' && pos > 0)pos--; } }else if(command=="insert"){ getline(cin,command); string text; bool f= false; for(int i=0;i<command.size();i++){ if(f&&command[i]=='\"')break; if(f)text.push_back(command[i]); if(command[i]=='\"')f=true; } buf.insert(pos,text); pos+= text.size(); }else {//delete cin >> command; if(command== "char"){ if(!buf.empty()&&pos!=buf.size()){ buf.erase(pos,1); pos = min(pos,(int)buf.size()); } }else{ if(!buf.empty()){ int t=pos; while(t<buf.size() && buf[t]!=' ')t++; while(t<buf.size() && buf[t]==' ')t++; buf.erase(pos,t-pos); } } } } //cout << buf << "****" << endl; if(buf.empty()){ printf("^\n"); }else{ for(int p=0;p<buf.size();p++){ if(pos==p)printf("^"); printf("%c",buf[p]); } if(pos==buf.size())printf("^"); printf("\n");} } return 0; }
a.cc: In function 'int main()': a.cc:13:9: error: 'gets' was not declared in this scope; did you mean 'getw'? 13 | gets(b); | ^~~~ | getw
s167841141
p00683
C++
#include <iostream> #include <cstdio> #include <cmath> #include <string> using namespace std; int main(){ int n,r; cin >> n; cin.ignore(); while(n--){ int cur = 0; string text, command; getline(cin, text); int len = text.size(); cin >> r; cin.ignore(); while(r--){ getline(cin, command); if(command == "forward char"){ cur=min(len, cur+1); }else if(command == "forward word"){ for(;cur<len && text[cur] == ' '; cur++); for(;cur<len && text[cur] != ' '; cur++); }else if(command == "backward char"){ cur=max(0, cur-1); }else if(command == "backward word"){ for(;cur>0 && text[cur-1] == ' '; cur--); for(;cur>0 && text[cur-1] != ' '; cur--); }else if(command == "delete char"){ if(cur>=len) continue; text.erase(text.begin()+cur); len--; }else if(command == "delete word"){ int s = cur; for(;s<len && text[s] == ' '; s++){ #include <iostream> #include <cstdio> #include <cmath> #include <string> using namespace std; int main(){ int n,r; cin >> n; cin.ignore(); while(n--){ int cur = 0; string text, command; getline(cin, text); int len = text.size(); cin >> r; cin.ignore(); while(r--){ getline(cin, command); if(command == "forward char"){ cur=min(len, cur+1); }else if(command == "forward word"){ for(;cur<len && text[cur] == ' '; cur++); for(;cur<len && text[cur] != ' '; cur++); }else if(command == "backward char"){ cur=max(0, cur-1); }else if(command == "backward word"){ for(;cur>0 && text[cur-1] == ' '; cur--); for(;cur>0 && text[cur-1] != ' '; cur--); }else if(command == "delete char"){ if(cur>=len) continue; text.erase(text.begin()+cur); len--; }else if(command == "delete word"){ int s = cur; for(;s<len && text[s] == ' '; s++){ text.erase(text.begin()+s); len--; } for(;s<len && text[s] != ' ';){ text.erase(text.begin()+s); len--; } }else if(command.find("insert")!=command.npos){ string ins; int s = command.find('"'); int t = command.find('"',s+1); ins = command.substr(s+1,t-s-1); text.insert(cur,ins); len+=t-s-1; cur+=t-s-1; } } cout<<text.substr(0,cur)<<"^"<<text.substr(cur)<<endl; } return 0; } } for(;s<len && text[s] != ' ';){ text.erase(text.begin()+s); len--; } }else if(command.find("insert")!=command.npos){ string ins; int s = command.find('"'); int t = command.find('"',s+1); ins = command.substr(s+1,t-s-1); text.insert(cur,ins); len+=t-s-1; cur+=t-s-1; } } text.insert(text.begin()+cur,'^'); cout << text << endl; } return 0; }
a.cc: In function 'int main()': a.cc:43:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 43 | int main(){ | ^~ a.cc:43:9: note: remove parentheses to default-initialize a variable 43 | int main(){ | ^~ | -- a.cc:43:9: note: or replace parentheses with braces to value-initialize a variable a.cc:43:11: error: a function-definition is not allowed here before '{' token 43 | int main(){ | ^
s129125254
p00683
C++
#include <iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; int main() { string bla = "bla"; cout<<bla.substr(3)<<endl; int nb_cas; cin>>nb_cas; cin.ignore(); while(nb_cas--) { string texte; getline(cin,texte); int nb_op; cin>>nb_op; int curseur = 0; for(int c=0;c<nb_op;c++) { string s1,s2; cin>>s1; cin.ignore(); getline(cin,s2); if(s1=="forward"||s1=="backward") { int d = (s1=="forward"?1:-1); if(s2=="char") curseur+=d; else if(s2=="word") { while(curseur>= 0 && curseur<=texte.size()&&(curseur == texte.size()||texte[curseur]==' ')) curseur+=d; while(curseur>=-0&&curseur<=texte.size()&&(curseur==texte.size()||texte[curseur]!=' ')) { curseur += d; } } curseur = max(curseur,0); curseur = min(curseur,(int)texte.size()); } else if(s1=="delete") { if(s2=="char") { texte = texte.substr(0,min(texte.size(),curseur))+texte.substr(min(curseur+1,(int)texte.size())); } else if(s2=="word") { int finMot = curseur; while(finMot<texte.size()&&texte[finMot]==' ') finMot++; while(finMot<texte.size()&&texte[finMot]!=' ') { finMot ++; } texte = texte.substr(0,curseur)+(finMot < texte.size()?texte.substr(finMot):""); } } else { s2 = s2.substr(1,s2.size()-2); texte = texte.substr(0,curseur)+s2+(curseur<(int)texte.size()?texte.substr(curseur):""); curseur += s2.size(); } } cout<<texte.substr(0,curseur)+"^"+(curseur<(int)texte.size()?texte.substr(curseur):"")<<endl; } }
a.cc: In function 'int main()': a.cc:46:47: error: no matching function for call to 'min(std::__cxx11::basic_string<char>::size_type, int&)' 46 | texte = texte.substr(0,min(texte.size(),curseur))+texte.substr(min(curseur+1,(int)texte.size())); | ~~~^~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:46:47: note: deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int') 46 | texte = texte.substr(0,min(texte.size(),curseur))+texte.substr(min(curseur+1,(int)texte.size())); | ~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:46:47: note: mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int' 46 | texte = texte.substr(0,min(texte.size(),curseur))+texte.substr(min(curseur+1,(int)texte.size())); | ~~~^~~~~~~~~~~~~~~~~~~~~~
s000147843
p00683
C++
#include <iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; int main() { string bla = "bla"; cout<<bla.substr(3)<<endl; int nb_cas; cin>>nb_cas; cin.ignore(); while(nb_cas--) { string texte; getline(cin,texte); int nb_op; cin>>nb_op; int curseur = 0; for(int c=0;c<nb_op;c++) { string s1,s2; cin>>s1; cin.ignore(); getline(cin,s2); if(s1=="forward"||s1=="backward") { int d = (s1=="forward"?1:-1); if(s2=="char") curseur+=d; else if(s2=="word") { while(curseur>= 0 && curseur<=texte.size()&&(curseur == texte.size()||texte[curseur]==' ')) curseur+=d; while(curseur>=-0&&curseur<=texte.size()&&(curseur==texte.size()||texte[curseur]!=' ')) { curseur += d; } } curseur = max(curseur,0); curseur = min(curseur,(int)texte.size()); } else if(s1=="delete") { if(s2=="char") { texte = texte.substr(0,min(texte.size(),(int)curseur))+texte.substr(min(curseur+1,(int)texte.size())); } else if(s2=="word") { int finMot = curseur; while(finMot<texte.size()&&texte[finMot]==' ') finMot++; while(finMot<texte.size()&&texte[finMot]!=' ') { finMot ++; } texte = texte.substr(0,curseur)+(finMot < texte.size()?texte.substr(finMot):""); } } else { s2 = s2.substr(1,s2.size()-2); texte = texte.substr(0,curseur)+s2+(curseur<(int)texte.size()?texte.substr(curseur):""); curseur += s2.size(); } } cout<<texte.substr(0,curseur)+"^"+(curseur<(int)texte.size()?texte.substr(curseur):"")<<endl; } }
a.cc: In function 'int main()': a.cc:46:47: error: no matching function for call to 'min(std::__cxx11::basic_string<char>::size_type, int)' 46 | texte = texte.substr(0,min(texte.size(),(int)curseur))+texte.substr(min(curseur+1,(int)texte.size())); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)' 233 | min(const _Tp& __a, const _Tp& __b) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:233:5: note: template argument deduction/substitution failed: a.cc:46:47: note: deduced conflicting types for parameter 'const _Tp' ('long unsigned int' and 'int') 46 | texte = texte.substr(0,min(texte.size(),(int)curseur))+texte.substr(min(curseur+1,(int)texte.size())); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)' 281 | min(const _Tp& __a, const _Tp& __b, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)' 5686 | min(initializer_list<_Tp> __l) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate expects 1 argument, 2 provided /usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)' 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~ /usr/include/c++/14/bits/stl_algo.h:5696:5: note: template argument deduction/substitution failed: a.cc:46:47: note: mismatched types 'std::initializer_list<_Tp>' and 'long unsigned int' 46 | texte = texte.substr(0,min(texte.size(),(int)curseur))+texte.substr(min(curseur+1,(int)texte.size())); | ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
s924950111
p00683
C++
#include <iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; int main() { string bla = "bla"; cout<<bla.substr(3)<<endl; int nb_cas; cin>>nb_cas; cin.ignore(); while(nb_cas--) { string texte; getline(cin,texte); int nb_op; cin>>nb_op; int curseur = 0; for(int c=0;c<nb_op;c++) { string s1,s2; cin>>s1; cin.ignore(); getline(cin,s2); if(s1=="forward"||s1=="backward") { int d = (s1=="forward"?1:-1); if(s2=="char") curseur+=d; else if(s2=="word") { while(curseur>= 0 && curseur<=texte.size()&&(curseur == texte.size()||texte[curseur]==' ')) curseur+=d; while(curseur>=-0&&curseur<=texte.size()&&(curseur==texte.size()||texte[curseur]!=' ')) { curseur += d; } } curseur = max(curseur,0); curseur = min(curseur,(int)texte.size()); } else if(s1=="delete") { if(s2=="char"&&curseur<texte.size()) { texte = texte.substr(0,curseur)+texte.substr(curseur+1); } else if(s2=="word") { int finMot = curseur; while(finMot<texte.size()&&texte[finMot]==' ') finMot++; if(finMot == texte.size()) continue; while(finMot<texte.size()&&texte[finMot]!=' ') { finMot ++; } texte = texte.substr(0,curseur)+(finMot < texte.size()?texte.substr(finMot):""); } } else { while(s2[0]!="\"") s2=s2.substr(1); while(s2[s2.size()-1]!="\"") s2 = s2.substr(s2.size()-1); s2 = s2.substr(1,s2.size()-2); texte = texte.substr(0,curseur)+s2+(curseur<(int)texte.size()?texte.substr(curseur):""); curseur += s2.size(); } } cout<<texte.substr(0,curseur)+"^"+(curseur<(int)texte.size()?texte.substr(curseur):"")<<endl; } }
a.cc: In function 'int main()': a.cc:62:28: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 62 | while(s2[0]!="\"") s2=s2.substr(1); a.cc:63:38: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 63 | while(s2[s2.size()-1]!="\"") s2 = s2.substr(s2.size()-1);
s993638147
p00683
C++
#include<iostream> #include<string> #include<vector> using namespace std; int main(){ int n; cin >>n; cin.ignore(); for(int i=0;i<n;i++){ string str; int cn,pos; if(!getline(cin,str)){ str = ""; } cin >> cn; pos = 0; for(int j=0;j<cn;j++){ string command,target; char ch; cin >> command; getline(cin,target); target.erase(0,1); if(command == "forward"){ if(pos<str.size()){ if(target == "word"){ int temp = pos; int judge = 0; while(temp<str.size()){ if(str[temp]!=' '){ judge = 1; break; } temp++; } if(judge==1){ do{ pos++; }while(pos<str.size()&&str[pos]!=' '); } }else{ pos++; } } }else if(command == "delete"){ if(str.size()!=0&&pos!=str.size()){ if(target == "word"){ int stage = 0; while(pos<str.size()){ if(stage==0){ if(str[temp]!=" "){ stage = 1; } }else{ if(str[temp]==" "){ break; } } str.erase(pos,1); } while(pos<str.size()&&str[pos]!=' '){ str.erase(pos,1); } }else{ str.erase(pos,1); } } }else if(command == "backward"){ if(pos>0){ if(target == "word"){ int temp = pos; int judge = 0; while(temp>=0){ if(str[temp]!=' '){ judge = 1; break; } temp--; } if(judge==1){ do{ pos--; }while(pos>0&&str[pos]!=' '); } }else{ pos--; } } }else if(command == "insert"){ target = target.substr(1,target.size()-2); str.insert(pos,target); pos += target.size(); } } str.insert(pos,"^"); cout << str << endl; } return 0; }
a.cc: In function 'int main()': a.cc:51:24: error: 'temp' was not declared in this scope; did you mean 'tm'? 51 | if(str[temp]!=" "){ | ^~~~ | tm a.cc:55:24: error: 'temp' was not declared in this scope; did you mean 'tm'? 55 | if(str[temp]==" "){ | ^~~~ | tm
s987592711
p00684
Java
import java.util.*; public class AOJ_1102{ void run(){ Scanner sc = new Scanner(System.in); while(sc.hasNext()){ String exp = sc.next(); try{ Parser parser = new Parser(exp); System.out.println(parser.expression()); } catch(MyOverFlowException e){ System.out.println("overflow"); } } } public static void main(String[] args){ new AOJ_1102().run(); } } class Z{ int re,im; Z(int re, int im){ this.re = re; this.im = im; } Z add(Z z){ return new Z(re + z.re, im + z.im); } Z sub(Z z){ return new Z(re - z.re, im - z.im); } Z mul(Z z){ return new Z(re * z.re - im * z.im, re * z.im + im * z.re); } public String toString(){ if(re == 0 && im == 0){ return "0"; } if(im == 0){ return re + ""; } if(re == 0){ return im + "i"; } if(im > 0){ return re + "+" + im + "i"; } return re + "" + im + "i"; } } class MyOverFlowException extends Exception{ public MyOverFlowException(){ super(); } } class Parser{ char[] exp; int begin; Parser(String str){ this.exp = (str+"#").toCharArray(); } //四則演算の式をパースして、その評価結果を返す Z expression() throws MyOverFlowException{ Z ret = term(); while(true){ if(exp[begin] == '+'){ begin++; ret = ret.add(term()); if(Math.abs(ret.re) > 10000 || Math.abs(ret.im) > 10000){ throw new MyOverFlowException(); } } else if(exp[begin] == '-'){ begin++; ret = ret.sub(term()); if(Math.abs(ret.re) > 10000 || Math.abs(ret.im) > 10000){ throw new MyOverFlowException(); } } else{ break; } } return ret; } //乗算除算の式をパースして、その評価結果を返す Z term() throws MyOverFlowException{ Z ret = factor(); while(true){ if(exp[begin] == '*'){ begin++; ret = ret.mul(factor()); if(Math.abs(ret.re) > 10000 || Math.abs(ret.im) > 10000){ throw new MyOverFlowException(); } } /* else if(exp[begin] == '/'){ begin++; ret = ret.div(factor()) } */ else{ break; } } return ret; } //数字の列をパースして、その数を返す Z number() throws MyOverFlowException{ if(exp[begin] == 'i'){ begin++; return new Z(0,1); } int re = 0; while(Character.isDigit(exp[begin])){ re *= 10; re += exp[begin] - '0'; begin++; if(Math.abs(re) > 10000){ throw new MyOverFlowException(); } } return new Z(re,0); } //括弧か数かをパースして、その評価結果を返す Z factor() throws MyOverFlowException{ if(exp[begin] == '('){ begin++;//'('を飛ばす Z ret = expression(); begin++;//')'を飛ばす return ret; } else{ return number(); } } } //https://gist.github.com/draftcode/1357281
Main.java:2: error: class AOJ_1102 is public, should be declared in a file named AOJ_1102.java public class AOJ_1102{ ^ 1 error
s262172638
p00684
C
typedef struct{int r,i;}C;char*p,s[999];o;C E(),M(),a;C G(r,i){C c={r,i};o|=abs(r)>1e4||abs(i)>1e4;return c;}C T(r,l){C c;*p==40?c=E(p++),p++:*p<58?sscanf(p,"%d%n",&r,&l),p+=l,c=G(r,0):(c=G(0,1),p++);return c;}C E(f){C c=M(),d;for(f=1;f;)f=*p==43?d=M(p++),c=G(c.r+d.r,c.i+d.i),1:*p==45?d=M(p++),c=G(c.r-d.r,c.i-d.i),1:0;return c;}C M(f){C c=T(),d;for(f=1;f;)f=*p==42?d=T(p++),c=G(c.r*d.r-c.i*d.i,c.r*d.i+c.i*d.r),1:0;return c;}main(){for(;~scanf("%s",p=s);o?o=!puts("overflow"):a.i?a.r?printf("%d%+di\n",a.r,a.i):printf("%di\n",a.i):printf("%d\n",a.r))a=E();}
main.c:1:41: warning: data definition has no type or storage class 1 | typedef struct{int r,i;}C;char*p,s[999];o;C E(),M(),a;C G(r,i){C c={r,i};o|=abs(r)>1e4||abs(i)>1e4;return c;}C T(r,l){C c;*p==40?c=E(p++),p++:*p<58?sscanf(p,"%d%n",&r,&l),p+=l,c=G(r,0):(c=G(0,1),p++);return c;}C E(f){C c=M(),d;for(f=1;f;)f=*p==43?d=M(p++),c=G(c.r+d.r,c.i+d.i),1:*p==45?d=M(p++),c=G(c.r-d.r,c.i-d.i),1:0;return c;}C M(f){C c=T(),d;for(f=1;f;)f=*p==42?d=T(p++),c=G(c.r*d.r-c.i*d.i,c.r*d.i+c.i*d.r),1:0;return c;}main(){for(;~scanf("%s",p=s);o?o=!puts("overflow"):a.i?a.r?printf("%d%+di\n",a.r,a.i):printf("%di\n",a.i):printf("%d\n",a.r))a=E();} | ^ main.c:1:41: error: type defaults to 'int' in declaration of 'o' [-Wimplicit-int] main.c: In function 'G': main.c:1:57: error: type of 'r' defaults to 'int' [-Wimplicit-int] 1 | typedef struct{int r,i;}C;char*p,s[999];o;C E(),M(),a;C G(r,i){C c={r,i};o|=abs(r)>1e4||abs(i)>1e4;return c;}C T(r,l){C c;*p==40?c=E(p++),p++:*p<58?sscanf(p,"%d%n",&r,&l),p+=l,c=G(r,0):(c=G(0,1),p++);return c;}C E(f){C c=M(),d;for(f=1;f;)f=*p==43?d=M(p++),c=G(c.r+d.r,c.i+d.i),1:*p==45?d=M(p++),c=G(c.r-d.r,c.i-d.i),1:0;return c;}C M(f){C c=T(),d;for(f=1;f;)f=*p==42?d=T(p++),c=G(c.r*d.r-c.i*d.i,c.r*d.i+c.i*d.r),1:0;return c;}main(){for(;~scanf("%s",p=s);o?o=!puts("overflow"):a.i?a.r?printf("%d%+di\n",a.r,a.i):printf("%di\n",a.i):printf("%d\n",a.r))a=E();} | ^ main.c:1:57: error: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:1:77: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration] 1 | typedef struct{int r,i;}C;char*p,s[999];o;C E(),M(),a;C G(r,i){C c={r,i};o|=abs(r)>1e4||abs(i)>1e4;return c;}C T(r,l){C c;*p==40?c=E(p++),p++:*p<58?sscanf(p,"%d%n",&r,&l),p+=l,c=G(r,0):(c=G(0,1),p++);return c;}C E(f){C c=M(),d;for(f=1;f;)f=*p==43?d=M(p++),c=G(c.r+d.r,c.i+d.i),1:*p==45?d=M(p++),c=G(c.r-d.r,c.i-d.i),1:0;return c;}C M(f){C c=T(),d;for(f=1;f;)f=*p==42?d=T(p++),c=G(c.r*d.r-c.i*d.i,c.r*d.i+c.i*d.r),1:0;return c;}main(){for(;~scanf("%s",p=s);o?o=!puts("overflow"):a.i?a.r?printf("%d%+di\n",a.r,a.i):printf("%di\n",a.i):printf("%d\n",a.r))a=E();} | ^~~ main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'abs' +++ |+#include <stdlib.h> 1 | typedef struct{int r,i;}C;char*p,s[999];o;C E(),M(),a;C G(r,i){C c={r,i};o|=abs(r)>1e4||abs(i)>1e4;return c;}C T(r,l){C c;*p==40?c=E(p++),p++:*p<58?sscanf(p,"%d%n",&r,&l),p+=l,c=G(r,0):(c=G(0,1),p++);return c;}C E(f){C c=M(),d;for(f=1;f;)f=*p==43?d=M(p++),c=G(c.r+d.r,c.i+d.i),1:*p==45?d=M(p++),c=G(c.r-d.r,c.i-d.i),1:0;return c;}C M(f){C c=T(),d;for(f=1;f;)f=*p==42?d=T(p++),c=G(c.r*d.r-c.i*d.i,c.r*d.i+c.i*d.r),1:0;return c;}main(){for(;~scanf("%s",p=s);o?o=!puts("overflow"):a.i?a.r?printf("%d%+di\n",a.r,a.i):printf("%di\n",a.i):printf("%d\n",a.r))a=E();} main.c: In function 'T': main.c:1:112: error: type of 'r' defaults to 'int' [-Wimplicit-int] 1 | typedef struct{int r,i;}C;char*p,s[999];o;C E(),M(),a;C G(r,i){C c={r,i};o|=abs(r)>1e4||abs(i)>1e4;return c;}C T(r,l){C c;*p==40?c=E(p++),p++:*p<58?sscanf(p,"%d%n",&r,&l),p+=l,c=G(r,0):(c=G(0,1),p++);return c;}C E(f){C c=M(),d;for(f=1;f;)f=*p==43?d=M(p++),c=G(c.r+d.r,c.i+d.i),1:*p==45?d=M(p++),c=G(c.r-d.r,c.i-d.i),1:0;return c;}C M(f){C c=T(),d;for(f=1;f;)f=*p==42?d=T(p++),c=G(c.r*d.r-c.i*d.i,c.r*d.i+c.i*d.r),1:0;return c;}main(){for(;~scanf("%s",p=s);o?o=!puts("overflow"):a.i?a.r?printf("%d%+di\n",a.r,a.i):printf("%di\n",a.i):printf("%d\n",a.r))a=E();} | ^ main.c:1:112: error: type of 'l' defaults to 'int' [-Wimplicit-int] main.c:1:149: error: implicit declaration of function 'sscanf' [-Wimplicit-function-declaration] 1 | typedef struct{int r,i;}C;char*p,s[999];o;C E(),M(),a;C G(r,i){C c={r,i};o|=abs(r)>1e4||abs(i)>1e4;return c;}C T(r,l){C c;*p==40?c=E(p++),p++:*p<58?sscanf(p,"%d%n",&r,&l),p+=l,c=G(r,0):(c=G(0,1),p++);return c;}C E(f){C c=M(),d;for(f=1;f;)f=*p==43?d=M(p++),c=G(c.r+d.r,c.i+d.i),1:*p==45?d=M(p++),c=G(c.r-d.r,c.i-d.i),1:0;return c;}C M(f){C c=T(),d;for(f=1;f;)f=*p==42?d=T(p++),c=G(c.r*d.r-c.i*d.i,c.r*d.i+c.i*d.r),1:0;return c;}main(){for(;~scanf("%s",p=s);o?o=!puts("overflow"):a.i?a.r?printf("%d%+di\n",a.r,a.i):printf("%di\n",a.i):printf("%d\n",a.r))a=E();} | ^~~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'sscanf' +++ |+#include <stdio.h> 1 | typedef struct{int r,i;}C;char*p,s[999];o;C E(),M(),a;C G(r,i){C c={r,i};o|=abs(r)>1e4||abs(i)>1e4;return c;}C T(r,l){C c;*p==40?c=E(p++),p++:*p<58?sscanf(p,"%d%n",&r,&l),p+=l,c=G(r,0):(c=G(0,1),p++);return c;}C E(f){C c=M(),d;for(f=1;f;)f=*p==43?d=M(p++),c=G(c.r+d.r,c.i+d.i),1:*p==45?d=M(p++),c=G(c.r-d.r,c.i-d.i),1:0;return c;}C M(f){C c=T(),d;for(f=1;f;)f=*p==42?d=T(p++),c=G(c.r*d.r-c.i*d.i,c.r*d.i+c.i*d.r),1:0;return c;}main(){for(;~scanf("%s",p=s);o?o=!puts("overflow"):a.i?a.r?printf("%d%+di\n",a.r,a.i):printf("%di\n",a.i):printf("%d\n",a.r))a=E();} main.c:1:149: warning: incompatible implicit declaration of built-in function 'sscanf' [-Wbuiltin-declaration-mismatch] 1 | typedef struct{int r,i;}C;char*p,s[999];o;C E(),M(),a;C G(r,i){C c={r,i};o|=abs(r)>1e4||abs(i)>1e4;return c;}C T(r,l){C c;*p==40?c=E(p++),p++:*p<58?sscanf(p,"%d%n",&r,&l),p+=l,c=G(r,0):(c=G(0,1),p++);return c;}C E(f){C c=M(),d;for(f=1;f;)f=*p==43?d=M(p++),c=G(c.r+d.r,c.i+d.i),1:*p==45?d=M(p++),c=G(c.r-d.r,c.i-d.i),1:0;return c;}C M(f){C c=T(),d;for(f=1;f;)f=*p==42?d=T(p++),c=G(c.r*d.r-c.i*d.i,c.r*d.i+c.i*d.r),1:0;return c;}main(){for(;~scanf("%s",p=s);o?o=!puts("overflow"):a.i?a.r?printf("%d%+di\n",a.r,a.i):printf("%di\n",a.i):printf("%d\n",a.r))a=E();} | ^~~~~~ main.c:1:149: note: include '<stdio.h>' or provide a declaration of 'sscanf' main.c:1:185: error: type mismatch in conditional expression 1 | typedef struct{int r,i;}C;char*p,s[999];o;C E(),M(),a;C G(r,i){C c={r,i};o|=abs(r)>1e4||abs(i)>1e4;return c;}C T(r,l){C c;*p==40?c=E(p++),p++:*p<58?sscanf(p,"%d%n",&r,&l),p+=l,c=G(r,0):(c=G(0,1),p++);return c;}C E(f){C c=M(),d;for(f=1;f;)f=*p==43?d=M(p++),c=G(c.r+d.r,c.i+d.i),1:*p==45?d=M(p++),c=G(c.r-d.r,c.i-d.i),1:0;return c;}C M(f){C c=T(),d;for(f=1;f;)f=*p==42?d=T(p++),c=G(c.r*d.r-c.i*d.i,c.r*d.i+c.i*d.r),1:0;return c;}main(){for(;~scanf("%s",p=s);o?o=!puts("overflow"):a.i?a.r?printf("%d%+di\n",a.r,a.i):printf("%di\n",a.i):printf("%d\n",a.r))a=E();} | ^ main.c: In function 'E': main.c:1:213: error: type of 'f' defaults to 'int' [-Wimplicit-int] 1 | typedef struct{int r,i;}C;char*p,s[999];o;C E(),M(),a;C G(r,i){C c={r,i};o|=abs(r)>1e4||abs(i)>1e4;return c;}C T(r,l){C c;*p==40?c=E(p++),p++:*p<58?sscanf(p,"%d%n",&r,&l),p+=l,c=G(r,0):(c=G(0,1),p++);return c;}C E(f){C c=M(),d;for(f=1;f;)f=*p==43?d=M(p++),c=G(c.r+d.r,c.i+d.i),1:*p==45?d=M(p++),c=G(c.r-d.r,c.i-d.i),1:0;return c;}C M(f){C c=T(),d;for(f=1;f;)f=*p==42?d=T(p++),c=G(c.r*d.r-c.i*d.i,c.r*d.i+c.i*d.r),1:0;return c;}main(){for(;~scanf("%s",p=s);o?o=!puts("overflow"):a.i?a.r?printf("%d%+di\n",a.r,a.i):printf("%di\n",a.i):printf("%d\n",a.r))a=E();} | ^ main.c: In function 'M': main.c:1:333: error: type of 'f' defaults to 'int' [-Wimplicit-int] 1 | typedef struct{int r,i;}C;char*p,s[999];o;C E(),M(),a;C G(r,i){C c={r,i};o|=abs(r)>1e4||abs(i)>1e4;return c;}C T(r,l){C c;*p==40?c=E(p++),p++:*p<58?sscanf(p,"%d%n",&r,&l),p+=l,c=G(r,0):(c=G(0,1),p++);return c;}C E(f){C c=M(),d;for(f=1;f;)f=*p==43?d=M(p++),c=G(c.r+d.r,c.i+d.i),1:*p==45?d=M(p++),c=G(c.r-d.r,c.i-d.i),1:0;return c;}C M(f){C c=T(),d;for(f=1;f;)f=*p==42?d=T(p++),c=G(c.r*d.r-c.i*d.i,c.r*d.i+c.i*d.r),1:0;return c;}main(){for(;~scanf("%s",p=s);o?o=!puts("overflow"):a.i?a.r?printf("%d%+di\n",a.r,a.i):printf("%di\n",a.i):printf("%d\n",a.r))a=E();} | ^ main.c: At top level: main.c:1:428: error: return type defaults to 'int' [-Wimplicit-int] 1 | typedef struct{int r,i;}C;char*p,s[999];o;C E(),M(),a;C G(r,i){C c={r,i};o|=abs(r)>1e4||abs(i)>1e4;return c;}C T(r,l){C c;*p==40?c=E(p++),p++:*p<58?sscanf(p,"%d%n",&r,&l),p+=l,c=G(r,0):(c=G(0,1),p++);return c;}C E(f){C c=M(),d;for(f=1;f;)f=*p==43?d=M(p++),c=G(c.r+d.r,c.i+d.i),1:*p==45?d=M(p++),c=G(c.r-d.r,c.i-d.i),1:0;return c;}C M(f){C c=T(),d;for(f=1;f;)f=*p==42?d=T(p++),c=G(c.r*d.r-c.i*d.i,c.r*d.i+c.i*d.r),1:0;return c;}main(){for(;~scanf("%s",p=s);o?o=!puts("overflow"):a.i?a.r?printf("%d%+di\n",a.r,a.i):printf("%di\n",a.i):printf("%d\n",a.r))a=E();} | ^~~~ main.c: In function 'main': main.c:1:441: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | typedef struct{int r,i;}C;char*p,s[999];o;C E(),
s666973850
p00684
C++
#include <bits/stdc++.h> using namespace std; typedef string::const_iterator State; typedef pair<int, int> Pii; #define fr first #define sc second bool is_over = false; struct Parser { Pii expression(State &idx) { Pii ret = term(idx); if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; while ( 1 ) { if ( *idx == '+' ) { idx++; Pii tmp = term(idx); ret.fr = ret.fr + tmp.fr; ret.sc = ret.sc + tmp.sc; if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; } else if ( *idx == '-' ) { idx++; Pii tmp = term(idx); ret.fr = ret.fr - tmp.fr; ret.sc = ret.sc - tmp.sc; if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; } else { break; } } if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; return ret; } Pii term(State &idx) { Pii ret = factor(idx); if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; // while ( 1 ) { if ( *idx == '*' ) { idx++; Pii tmp = factor(idx), tmp2 = ret; //cout << ret.fr << " " << ret.sc << endl; //cout << tmp.fr << " " << tmp.sc << endl; ret.fr = tmp2.fr * tmp.fr - tmp2.sc * tmp.sc; ret.sc = tmp2.fr * tmp.sc + tmp2.sc * tmp.fr; if ( abs(ret.fr)> 10000 || abs(ret.sc) > 10000 ) is_over = true; // cout << ret.fr << " " << ret.sc << endl; } else { break; } } if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; return ret; } Pii factor(State &idx) { Pii ret; if ( *idx == '(' ) { idx++; ret = expression(idx); if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; idx++; } else { ret = number(idx); if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; } if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; return ret; } Pii number(State &idx) { int tmp = 0; while ( '0' <= *idx && *idx <= '9' ) { tmp *= 10; tmp += *idx - '0'; if ( abs(tmp) > 10000 ) is_over = true; idx++; /*if ( *idx == 'i' ) { is_real = false; idx++; }*/ } if ( abs(tmp) > 10000 ) is_over = true; //cout << tmp << endl; if ( *idx == 'i' ) { idx++; return Pii(0, 1); } else return Pii(tmp, 0); } }; int main()#include <bits/stdc++.h> using namespace std; typedef string::const_iterator State; typedef pair<int, int> Pii; #define fr first #define sc second bool is_over = false; struct Parser { Pii expression(State &idx) { Pii ret = term(idx); if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; while ( 1 ) { if ( *idx == '+' ) { idx++; Pii tmp = term(idx); ret.fr = ret.fr + tmp.fr; ret.sc = ret.sc + tmp.sc; if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; } else if ( *idx == '-' ) { idx++; Pii tmp = term(idx); ret.fr = ret.fr - tmp.fr; ret.sc = ret.sc - tmp.sc; if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; } else { break; } } if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; return ret; } Pii term(State &idx) { Pii ret = factor(idx); if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; // while ( 1 ) { if ( *idx == '*' ) { idx++; Pii tmp = factor(idx), tmp2 = ret; //cout << ret.fr << " " << ret.sc << endl; //cout << tmp.fr << " " << tmp.sc << endl; ret.fr = tmp2.fr * tmp.fr - tmp2.sc * tmp.sc; ret.sc = tmp2.fr * tmp.sc + tmp2.sc * tmp.fr; if ( abs(ret.fr)> 10000 || abs(ret.sc) > 10000 ) is_over = true; // cout << ret.fr << " " << ret.sc << endl; } else { break; } } if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; return ret; } Pii factor(State &idx) { Pii ret; if ( *idx == '(' ) { idx++; ret = expression(idx); if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; idx++; } else { ret = number(idx); if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; } if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; return ret; } Pii number(State &idx) { int tmp = 0; while ( '0' <= *idx && *idx <= '9' ) { tmp *= 10; tmp += *idx - '0'; if ( abs(tmp) > 10000 ) is_over = true; idx++; /*if ( *idx == 'i' ) { is_real = false; idx++; }*/ } if ( abs(tmp) > 10000 ) is_over = true; //cout << tmp << endl; if ( *idx == 'i' ) { idx++; return Pii(0, 1); } else return Pii(tmp, 0); } }; int main() { string s; while ( cin >> s ) { is_over = false; Parser ps; string tmp = s.substr(0, s.size() - 1); State idx = s.begin(); Pii ret = ps.expression(idx); if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; if ( is_over ) cout << "overflow" << endl; else if ( ret.fr == 0 && ret.sc == 0 ) cout << 0 << endl; else if ( ret.fr == 0 ) { printf("%di\n", ret.sc);#include <bits/stdc++.h> using namespace std; typedef string::const_iterator State; typedef pair<int, int> Pii; #define fr first #define sc second bool is_over = false; struct Parser { Pii expression(State &idx) { Pii ret = term(idx); if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; while ( 1 ) { if ( *idx == '+' ) { idx++; Pii tmp = term(idx); ret.fr = ret.fr + tmp.fr; ret.sc = ret.sc + tmp.sc; if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; } else if ( *idx == '-' ) { idx++; Pii tmp = term(idx); ret.fr = ret.fr - tmp.fr; ret.sc = ret.sc - tmp.sc; if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; } else { break; } } if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; return ret; } Pii term(State &idx) { Pii ret = factor(idx); if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; // while ( 1 ) { if ( *idx == '*' ) { idx++; Pii tmp = factor(idx), tmp2 = ret; //cout << ret.fr << " " << ret.sc << endl; //cout << tmp.fr << " " << tmp.sc << endl; ret.fr = tmp2.fr * tmp.fr - tmp2.sc * tmp.sc; ret.sc = tmp2.fr * tmp.sc + tmp2.sc * tmp.fr; if ( abs(ret.fr)> 10000 || abs(ret.sc) > 10000 ) is_over = true; // cout << ret.fr << " " << ret.sc << endl; } else { break; } } if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; return ret; } Pii factor(State &idx) { Pii ret; if ( *idx == '(' ) { idx++; ret = expression(idx); if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; idx++; } else { ret = number(idx); if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; } if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; return ret; } Pii number(State &idx) { int tmp = 0; while ( '0' <= *idx && *idx <= '9' ) { tmp *= 10; tmp += *idx - '0'; if ( abs(tmp) > 10000 ) is_over = true; idx++; /*if ( *idx == 'i' ) { is_real = false; idx++; }*/ } if ( abs(tmp) > 10000 ) is_over = true; //cout << tmp << endl; if ( *idx == 'i' ) { idx++; return Pii(0, 1); } else return Pii(tmp, 0); } }; int main() { string s; while ( cin >> s ) { is_over = false; Parser ps; string tmp = s.substr(0, s.size() - 1); State idx = s.begin(); Pii ret = ps.expression(idx); if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; if ( is_over ) cout << "overflow" << endl; else if ( ret.fr == 0 && ret.sc == 0 ) cout << 0 << endl; else if ( ret.fr == 0 ) { printf("%di\n", ret.sc); } else if ( ret.sc == 0 ) { printf("%d\n", ret.fr); } else { printf("%d", ret.fr); printf("%+di\n", ret.sc); // cout << ret.fr << '+' << ret.sc << 'i' << endl; } } return 0; } } else if ( ret.sc == 0 ) { printf("%d\n", ret.fr); } else { printf("%d", ret.fr); printf("%+di\n", ret.sc); // cout << ret.fr << '+' << ret.sc << 'i' << endl; } } return 0; } { string s; while ( cin >> s ) { is_over = false; Parser ps; string tmp = s.substr(0, s.size() - 1); State idx = s.begin(); Pii ret = ps.expression(idx); if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; if ( is_over ) cout << "overflow" << endl; else if ( ret.fr == 0 && ret.sc == 0 ) cout << 0 << endl; else if ( ret.fr == 0 ) { printf("%di\n", ret.sc); } else if ( ret.sc == 0 ) { printf("%d\n", ret.fr); } else { printf("%d", ret.fr); printf("%+di\n", ret.sc); // cout << ret.fr << '+' << ret.sc << 'i' << endl; } } return 0; }
a.cc:98:11: error: stray '#' in program 98 | int main()#include <bits/stdc++.h> | ^ a.cc:209:31: error: stray '#' in program 209 | printf("%di\n", ret.sc);#include <bits/stdc++.h> | ^ a.cc:98:12: error: expected initializer before 'include' 98 | int main()#include <bits/stdc++.h> | ^~~~~~~ a.cc:108:6: error: redefinition of 'bool is_over' 108 | bool is_over = false; | ^~~~~~~ a.cc:11:6: note: 'bool is_over' previously defined here 11 | bool is_over = false; | ^~~~~~~ a.cc:110:8: error: redefinition of 'struct Parser' 110 | struct Parser { | ^~~~~~ a.cc:13:8: note: previous definition of 'struct Parser' 13 | struct Parser { | ^~~~~~ a.cc: In function 'int main()': a.cc:209:32: error: 'include' was not declared in this scope 209 | printf("%di\n", ret.sc);#include <bits/stdc++.h> | ^~~~~~~ a.cc:209:41: error: 'bits' was not declared in this scope 209 | printf("%di\n", ret.sc);#include <bits/stdc++.h> | ^~~~ a.cc:209:46: error: 'stdc' was not declared in this scope; did you mean 'std'? 209 | printf("%di\n", ret.sc);#include <bits/stdc++.h> | ^~~~ | std a.cc:211:1: error: expected primary-expression before 'using' 211 | using namespace std; | ^~~~~ a.cc: In member function 'Pii main()::Parser::expression(State&)': a.cc:224:55: error: use of local variable with automatic storage from containing function 224 | if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; | ^~~~~~~ a.cc:219:6: note: 'bool is_over' declared here 219 | bool is_over = false; | ^~~~~~~ a.cc:231:59: error: use of local variable with automatic storage from containing function 231 | if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; | ^~~~~~~ a.cc:219:6: note: 'bool is_over' declared here 219 | bool is_over = false; | ^~~~~~~ a.cc:237:59: error: use of local variable with automatic storage from containing function 237 | if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; | ^~~~~~~ a.cc:219:6: note: 'bool is_over' declared here 219 | bool is_over = false; | ^~~~~~~ a.cc:242:55: error: use of local variable with automatic storage from containing function 242 | if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; | ^~~~~~~ a.cc:219:6: note: 'bool is_over' declared here 219 | bool is_over = false; | ^~~~~~~ a.cc: In member function 'Pii main()::Parser::term(State&)': a.cc:248:55: error: use of local variable with automatic storage from containing function 248 | if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; | ^~~~~~~ a.cc:219:6: note: 'bool is_over' declared here 219 | bool is_over = false; | ^~~~~~~ a.cc:258:58: error: use of local variable with automatic storage from containing function 258 | if ( abs(ret.fr)> 10000 || abs(ret.sc) > 10000 ) is_over = true; | ^~~~~~~ a.cc:219:6: note: 'bool is_over' declared here 219 | bool is_over = false; | ^~~~~~~ a.cc:264:55: error: use of local variable with automatic storage from containing function 264 | if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; | ^~~~~~~ a.cc:219:6: note: 'bool is_over' declared here 219 | bool is_over = false; | ^~~~~~~ a.cc: In member function 'Pii main()::Parser::factor(State&)': a.cc:273:57: error: use of local variable with automatic storage from containing function 273 | if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; | ^~~~~~~ a.cc:219:6: note: 'bool is_over' declared here 219 | bool is_over = false; | ^~~~~~~ a.cc:277:57: error: use of local variable with automatic storage from containing function 277 | if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; | ^~~~~~~ a.cc:219:6: note: 'bool is_over' declared here 219 | bool is_over = false; | ^~~~~~~ a.cc:279:55: error: use of local variable with automatic storage from containing function 279 | if ( abs(ret.fr) > 10000 || abs(ret.sc) > 10000 ) is_over = true; | ^~~~~~~ a.cc:219:6: note: 'bool is_over' declared here 219 | bool is_over = false; | ^~~~~~~ a.cc: In member function 'Pii main()::Parser::number(State&)': a.cc:288:31: error: use of local variable with automatic storage from containing function 288 | if ( abs(tmp) > 10000 ) is_over = true; | ^~~~~~~ a.cc:219:6: note: 'bool is_over' declared here 219 | bool is_over = false; | ^~~~~~~ a.cc:295:29: error: use of local variable with automatic storage from containing function 295 | if ( abs(tmp) > 10000 ) is_over = true; | ^~~~~~~ a.cc:219:6: note: 'bool is_over' declared here 219 | bool is_over = false; | ^~~~~~~ a.cc: In function 'int main()': a.cc:306:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 306 | int main() | ^~ a.cc:306:9: note: remove parentheses to default-initialize a variable 306 | int main() | ^~ | -- a.cc:306:9: note: or replace parentheses with braces to value-initialize a variable a.cc:307:1: error: a function-definition is not allowed here before '{' token 307 | { | ^ a.cc: At global scope: a.cc:349:1: error: expected unqualified-id before '{' token 349 | { | ^
s648858868
p00684
C++
#include<iostream> #include<string> #include<complex> using namespace std; typedef complex<int> ci; string expr;bool of; ci prs(int s,int t){ int d=0,mi=t,pmi=t; for(int i=s;i<t;i++){ char c=expr[i]; if(c=='(')d++; if(c==')')d--; if(d==0&&c=='*')mi=i; if(d==0&&(c=='+'||c=='-'))pmi=i; } ci r; if(pmi<t)r=prs(s,pmi)+(expr[pmi]=='+'?ci(1,0):ci(-1,0))*prs(pmi+1,t); else if(mi<t)r=prs(s,mi)*prs(mi+1,t); else if(expr[s]=='(')r=prs(s+1,t-1); else{ if(expr[s]=='i')r.imag()=1; else for(int i=s;i<t;i++)r.real()*=10,r.real()+=expr[i]-'0'; } if(abs(r.real())>10000||abs(r.imag())>10000)of=1; return r; } int main(){ while(cin>>expr){ of=0; ci ans=prs(0,expr.size()); if(of)cout<<"overflow"; else{ if(ans==0)cout<<0; if(ans.real()!=0)cout<<ans.real(); if(ans.imag()!=0){ cout<<(ans.real()!=0&&ans.imag()>0?"+":""); if(abs(ans.imag())!=1)cout<<ans.imag(); cout<<"i"; } } cout<<endl; } return 0; }
a.cc: In function 'ci prs(int, int)': a.cc:21:39: error: lvalue required as left operand of assignment 21 | if(expr[s]=='i')r.imag()=1; | ~~~~~~^~ a.cc:22:48: error: lvalue required as left operand of assignment 22 | else for(int i=s;i<t;i++)r.real()*=10,r.real()+=expr[i]-'0'; | ~~~~~~^~ a.cc:22:61: error: lvalue required as left operand of assignment 22 | else for(int i=s;i<t;i++)r.real()*=10,r.real()+=expr[i]-'0'; | ~~~~~~^~
s938746705
p00684
C++
#include <iostream> #include <complex> #include <map> #include <stack> #include <string> #include <cctype> #include <cstdlib> using namespace std; typedef complex<int> C; int p; string expr; bool err; int parseInt() { int ret=0; while(isdigit(expr[p])) { ret*=10; ret+=expr[p]-'0'; p++; } return ret; } char parseChr() { char ret=expr[p]; p++; return ret; } bool check(C& c) { if(abs(c.real()) > 10000) return true; if(abs(c.imag()) > 10000) return true; return false; } C calc(stack<C>& num, stack<char>& sta) { C r=num.top(); num.pop(); C l=num.top(); num.pop(); if(check(r)) err=1; if(check(l)) err=1; char e=sta.top(); sta.pop(); if(e=='+') return l+r; if(e=='-') return l-r; if(e=='*') return l*r; return l/r; } int main() { map<char, int> tab; tab.insert(make_pair('+',1)); tab.insert(make_pair('-',1)); tab.insert(make_pair('*',2)); tab.insert(make_pair('/',2)); tab.insert(make_pair('(',3)); tab.insert(make_pair(')',-3)); while(cin >> expr) { err=false; p=0; expr+="="; int nc=0; stack<char> sta; stack<int> cnt; stack<C> num; while(expr[p]!='=') { if(isdigit(expr[p])) { num.push(C(parseInt(),0)); } else { char c=parseChr(); if(c=='('||c==')') nc+=tab[c]; else if(c=='i') { num.push(C(0,1)); } else { while(!sta.empty()) { if(cnt.top()+tab[sta.top()] >= nc+tab[c]) { C ret=calc(num,sta); if(check(ret)) err=true; num.push(ret); cnt.pop(); } else break; } sta.push(c); cnt.push(nc); } } } while(!sta.empty()) { C ret=calc(num,sta); if(check(ret)) err=true; num.push(ret); } if(check(num.top()) err=1; if(err) cout << "overflow" << endl; else { C ans=num.top(); if(ans.real() == 0 && ans.imag() == 0) cout << 0 << endl; else { if(ans.real() != 0) { cout << ans.real(); if(ans.imag() > 0) cout << "+"; } if(ans.imag() != 0) cout << ans.imag() << "i" << endl; else cout << endl; } } } }
a.cc: In function 'int main()': a.cc:122:36: error: expected ';' before 'err' 122 | if(check(num.top()) err=1; | ^~~~ | ; a.cc:124:17: error: expected primary-expression before 'if' 124 | if(err) cout << "overflow" << endl; | ^~ a.cc:122:43: error: expected ')' before 'if' 122 | if(check(num.top()) err=1; | ~ ^ | ) 123 | 124 | if(err) cout << "overflow" << endl; | ~~
s506569916
p00684
C++
#include <iostream> #include <complex> #include <map> #include <stack> #include <string> #include <cctype> #include <cstdlib> using namespace std; typedef complex<int> C; int p; string expr; bool err; int parseInt() { int ret=0; while(isdigit(expr[p])) { ret*=10; ret+=expr[p]-'0'; p++; } return ret; } char parseChr() { char ret=expr[p]; p++; return ret; } bool check(C& c) { if(abs(c.real()) > 10000) return true; if(abs(c.imag()) > 10000) return true; return false; } C calc(stack<C>& num, stack<char>& sta) { C r=num.top(); num.pop(); C l=num.top(); num.pop(); if(check(r)) err=1; if(check(l)) err=1; char e=sta.top(); sta.pop(); if(e=='+') return l+r; if(e=='-') return l-r; if(e=='*') return l*r; return l/r; } int main() { map<char, int> tab; tab.insert(make_pair('+',1)); tab.insert(make_pair('-',1)); tab.insert(make_pair('*',2)); tab.insert(make_pair('/',2)); tab.insert(make_pair('(',3)); tab.insert(make_pair(')',-3)); while(cin >> expr) { err=false; p=0; expr+="="; int nc=0; stack<char> sta; stack<int> cnt; stack<C> num; while(expr[p]!='=') { if(isdigit(expr[p])) { num.push(C(parseInt(),0)); } else { char c=parseChr(); if(c=='('||c==')') nc+=tab[c]; else if(c=='i') { num.push(C(0,1)); } else { while(!sta.empty()) { if(cnt.top()+tab[sta.top()] >= nc+tab[c]) { C ret=calc(num,sta); if(check(ret)) err=true; num.push(ret); cnt.pop(); } else break; } sta.push(c); cnt.push(nc); } } } while(!sta.empty()) { C ret=calc(num,sta); if(check(ret)) err=true; num.push(ret); } if(check(num.top()) err=1; if(err) cout << "overflow" << endl; else { C ans=num.top(); if(ans.real() == 0 && ans.imag() == 0) cout << 0 << endl; else { if(ans.real() != 0) { cout << ans.real(); if(ans.imag() > 0) cout << "+"; } if(ans.imag() != 0) cout << ans.imag() << "i" << endl; else cout << endl; } } } }
a.cc: In function 'int main()': a.cc:122:36: error: expected ';' before 'err' 122 | if(check(num.top()) err=1; | ^~~~ | ; a.cc:124:17: error: expected primary-expression before 'if' 124 | if(err) cout << "overflow" << endl; | ^~ a.cc:122:43: error: expected ')' before 'if' 122 | if(check(num.top()) err=1; | ~ ^ | ) 123 | 124 | if(err) cout << "overflow" << endl; | ~~
s211369230
p00684
C++
#include <iostream> #include <complex> #include <map> #include <stack> #include <string> #include <cctype> #include <cstdlib> using namespace std; typedef complex<int> C; int p; string expr; bool err; int parseInt() { int ret=0; while(isdigit(expr[p])) { ret*=10; ret+=expr[p]-'0'; p++; } return ret; } char parseChr() { char ret=expr[p]; p++; return ret; } bool check(C& c) { if(abs(c.real()) > 10000) return true; if(abs(c.imag()) > 10000) return true; return false; } C calc(stack<C>& num, stack<char>& sta) { C r=num.top(); num.pop(); C l=num.top(); num.pop(); if(check(r)) err=1; if(check(l)) err=1; char e=sta.top(); sta.pop(); if(e=='+') return l+r; if(e=='-') return l-r; if(e=='*') return l*r; return l/r; } int main() { map<char, int> tab; tab.insert(make_pair('+',1)); tab.insert(make_pair('-',1)); tab.insert(make_pair('*',2)); tab.insert(make_pair('/',2)); tab.insert(make_pair('(',3)); tab.insert(make_pair(')',-3)); while(cin >> expr) { err=false; p=0; expr+="="; int nc=0; stack<char> sta; stack<int> cnt; stack<C> num; while(expr[p]!='=') { if(isdigit(expr[p])) { num.push(C(parseInt(),0)); } else { char c=parseChr(); if(c=='('||c==')') nc+=tab[c]; else if(c=='i') { num.push(C(0,1)); } else { while(!sta.empty()) { if(cnt.top()+tab[sta.top()] >= nc+tab[c]) { C ret=calc(num,sta); if(check(ret)) err=true; num.push(ret); cnt.pop(); } else break; } sta.push(c); cnt.push(nc); } } } while(!sta.empty()) { C ret=calc(num,sta); if(check(ret)) err=true; num.push(ret); } if(check(num.top()) err=1; if(err) cout << "overflow" << endl; else { C ans=num.top(); if(ans.real() == 0 && ans.imag() == 0) cout << 0 << endl; else { if(ans.real() != 0) { cout << ans.real(); if(ans.imag() > 0) cout << "+"; } if(ans.imag() != 0) cout << ans.imag() << "i" << endl; else cout << endl; } } } }
a.cc: In function 'int main()': a.cc:122:36: error: expected ';' before 'err' 122 | if(check(num.top()) err=1; | ^~~~ | ; a.cc:124:17: error: expected primary-expression before 'if' 124 | if(err) cout << "overflow" << endl; | ^~ a.cc:122:43: error: expected ')' before 'if' 122 | if(check(num.top()) err=1; | ~ ^ | ) 123 | 124 | if(err) cout << "overflow" << endl; | ~~
s511513627
p00684
C++
#include <iostream> #include <complex> #include <map> #include <stack> #include <string> #include <cctype> #include <cstdlib> using namespace std; typedef complex<int> C; int p; string expr; bool err; int parseInt() { int ret=0; while(isdigit(expr[p])) { ret*=10; ret+=expr[p]-'0'; p++; } return ret; } char parseChr() { char ret=expr[p]; p++; return ret; } bool check(C& c) { if(abs(c.real()) > 10000) return true; if(abs(c.imag()) > 10000) return true; return false; } C calc(stack<C>& num, stack<char>& sta) { C r=num.top(); num.pop(); C l=num.top(); num.pop(); if(check(r)) err=1; if(check(l)) err=1; char e=sta.top(); sta.pop(); if(e=='+') return l+r; if(e=='-') return l-r; if(e=='*') return l*r; return l/r; } int main() { map<char, int> tab; tab.insert(make_pair('+',1)); tab.insert(make_pair('-',1)); tab.insert(make_pair('*',2)); tab.insert(make_pair('/',2)); tab.insert(make_pair('(',3)); tab.insert(make_pair(')',-3)); while(cin >> expr) { err=false; p=0; expr+="="; int nc=0; stack<char> sta; stack<int> cnt; stack<C> num; while(expr[p]!='=') { if(isdigit(expr[p])) { num.push(C(parseInt(),0)); } else { char c=parseChr(); if(c=='('||c==')') nc+=tab[c]; else if(c=='i') { num.push(C(0,1)); } else { while(!sta.empty()) { if(cnt.top()+tab[sta.top()] >= nc+tab[c]) { C ret=calc(num,sta); if(check(ret)) err=true; num.push(ret); cnt.pop(); } else break; } sta.push(c); cnt.push(nc); } } } while(!sta.empty()) { C ret=calc(num,sta); if(check(ret)) err=true; num.push(ret); } if(check(num.top()) err=1; if(err) cout << "overflow" << endl; else { C ans=num.top(); if(ans.real() == 0 && ans.imag() == 0) cout << 0 << endl; else { if(ans.real() != 0) { cout << ans.real(); if(ans.imag() > 0) cout << "+"; } if(ans.imag() != 0) cout << ans.imag() << "i" << endl; else cout << endl; } } } }
a.cc: In function 'int main()': a.cc:122:36: error: expected ';' before 'err' 122 | if(check(num.top()) err=1; | ^~~~ | ; a.cc:124:17: error: expected primary-expression before 'if' 124 | if(err) cout << "overflow" << endl; | ^~ a.cc:122:43: error: expected ')' before 'if' 122 | if(check(num.top()) err=1; | ~ ^ | ) 123 | 124 | if(err) cout << "overflow" << endl; | ~~
s666844273
p00684
C++
#include <iostream> #include <algorithm> #include <complex> #include <cassert> using namespace std; typedef complex<long long> P; long long abs(long long x){ return x < 0 ? -x : x; } int pos; string ln; bool f = 0; P term(); P factor(); P formula(){ P ans = term(); while(ln[pos] == '+' || ln[pos] == '-'){ if(ln[pos] == '+'){ pos++; ans += term(); }else{ pos++; ans -= term(); } if( abs(ans.real()) > 10000 || abs(ans.imag()) > 10000 ) f = 1; } //cout << ln[pos] << endl; if(ln[pos] == '(') assert(0); return ans; } P term(){ P r = factor(); while(ln[pos] == '*'){ if(ln[pos]=='*'){ pos++; r *= factor(); if( abs(r.real()) > 10000 || abs(r.imag()) > 10000 ) f = 1; } } return r; } P factor(){ bool minus = 0; while(ln[pos] == '-') minus ^= 1 , pos++; if(ln[pos] == '('){ pos++; P r = formula(); pos++; if(ln[pos] == 'i') r *= P(0,1) , pos++; if( abs(r.real()) > 10000 || abs(r.imag()) > 10000 ) f = 1; return r * (minus?P(-1,0):P(1,0)); }else{ P r(0,0); while(ln[pos] == '-') minus ^= 1 , pos++; if(ln[pos] != 'i'){ while( (ln[pos] <= '9' && ln[pos] >= '0') || ln[pos] == 'i'){ if(ln[pos] == 'i') r *= P(0,1); else r = P(r.real() * 10 + ln[pos]-'0',0); if( abs(r.real()) > 10000 || abs(r.imag()) > 10000 ) f = 1; //cout << r << " " << ln[pos] << endl; pos++; } return r * (minus?P(-1,0):P(1,0)); }else{ pos++; return P(0,1) * (minus?P(-1,0):P(1,0)); } } } int main(){ while(cin >> ln){ ln += "~"; pos = 0; f = 0; P r = formula(); if(!f){ if(r.real() != 0){ cout << r.real(); if(r.imag()<0){ if(r.imag() == -1) cout << "-i"; else cout << r.imag() << "i"; }else if(r.imag()>0){ if(r.imag() == 1) cout << "+i"; else cout << "+" << r.imag() << "i"; } cout << endl; }else{ if(r.imag() == 0){ cout << 0 << endl; }else{ if(r.imag() ==-1) cout << "-i" << endl; else if(r.imag() == 1) cout << "i" << endl; else cout << r.imag() << "i" << endl; } } }else{ cout << "overflow" << endl; } } }
a.cc: In function 'P formula()': a.cc:26:24: error: call of overloaded 'abs(long long int)' is ambiguous 26 | if( abs(ans.real()) > 10000 || abs(ans.imag()) > 10000 ) f = 1; | ~~~^~~~~~~~~~~~ In file included from /usr/include/c++/14/cstdlib:79, from /usr/include/c++/14/ext/string_conversions.h:43, from /usr/include/c++/14/bits/basic_string.h:4154, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ a.cc:9:11: note: candidate: 'long long int abs(long long int)' 9 | long long abs(long long x){ return x < 0 ? -x : x; } | ^~~ In file included from /usr/include/c++/14/cstdlib:81: /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ a.cc:26:51: error: call of overloaded 'abs(long long int)' is ambiguous 26 | if( abs(ans.real()) > 10000 || abs(ans.imag()) > 10000 ) f = 1; | ~~~^~~~~~~~~~~~ /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ a.cc:9:11: note: candidate: 'long long int abs(long long int)' 9 | long long abs(long long x){ return x < 0 ? -x : x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ a.cc: In function 'P term()': a.cc:39:32: error: call of overloaded 'abs(long long int)' is ambiguous 39 | if( abs(r.real()) > 10000 || abs(r.imag()) > 10000 ) f = 1; | ~~~^~~~~~~~~~ /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ a.cc:9:11: note: candidate: 'long long int abs(long long int)' 9 | long long abs(long long x){ return x < 0 ? -x : x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ a.cc:39:57: error: call of overloaded 'abs(long long int)' is ambiguous 39 | if( abs(r.real()) > 10000 || abs(r.imag()) > 10000 ) f = 1; | ~~~^~~~~~~~~~ /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ a.cc:9:11: note: candidate: 'long long int abs(long long int)' 9 | long long abs(long long x){ return x < 0 ? -x : x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ a.cc: In function 'P factor()': a.cc:52:24: error: call of overloaded 'abs(long long int)' is ambiguous 52 | if( abs(r.real()) > 10000 || abs(r.imag()) > 10000 ) f = 1; | ~~~^~~~~~~~~~ /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ a.cc:9:11: note: candidate: 'long long int abs(long long int)' 9 | long long abs(long long x){ return x < 0 ? -x : x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ a.cc:52:49: error: call of overloaded 'abs(long long int)' is ambiguous 52 | if( abs(r.real()) > 10000 || abs(r.imag()) > 10000 ) f = 1; | ~~~^~~~~~~~~~ /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ a.cc:9:11: note: candidate: 'long long int abs(long long int)' 9 | long long abs(long long x){ return x < 0 ? -x : x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: n
s060003057
p00684
C++
#include <iostream> #include <algorithm> #include <complex> #include <cassert> long long abs(long long x){ return x<0?-x:x; } using namespace std; typedef complex<long long> P; int pos; string ln; bool f = 0; P term(); P factor(); P formula(){ P ans = term(); while(ln[pos] == '+' || ln[pos] == '-'){ if(ln[pos] == '+'){ pos++; ans += term(); }else{ pos++; ans -= term(); } if( abs(ans.real()) > 10000 || abs(ans.imag()) > 10000 ) f = 1; } return ans; } P term(){ P r = factor(); while(ln[pos] == '*' || ln[pos] == '('){ if(ln[pos]=='*')pos++; r *= factor(); if( abs(r.real()) > 10000 || abs(r.imag()) > 10000 ) f = 1; } return r; } P factor(){ bool minus = 0; while(ln[pos] == '-') minus ^= 1 , pos++; if(ln[pos] == '('){ pos++; P r = formula(); pos++; if(ln[pos] == 'i') r *= P(0,1) , pos++; if( abs(r.real()) > 10000 || abs(r.imag()) > 10000 ) f = 1; return r * (minus?P(-1,0):P(1,0)); }else{ P r(0,0); while(ln[pos] == '-') minus ^= 1 , pos++; if(ln[pos] != 'i'){ while( (ln[pos] <= '9' && ln[pos] >= '0') || ln[pos] == 'i'){ if(ln[pos] == 'i') r *= P(0,1); else r = P(r.real() * 10 + ln[pos]-'0',0); if( abs(r.real()) > 10000 || abs(r.imag()) > 10000 ) f = 1; //cout << r << " " << ln[pos] << endl; pos++; } return r * (minus?P(-1,0):P(1,0)); }else{ pos++; return P(0,1) * (minus?P(-1,0):P(1,0)); } } } int main(){ while(cin >> ln){ ln += "~"; pos = 0; f = 0; P r = formula(); if(!f){ if(r.real() != 0){ cout << r.real(); if(r.imag()<0){ if(r.imag() == -1) cout << "-i"; else cout << r.imag() << "i"; }else if(r.imag()>0){ if(r.imag() == 1) cout << "+i"; else cout << "+" << r.imag() << "i"; } cout << endl; }else{ if(r.imag() == 0){ cout << 0 << endl; }else{ if(r.imag() ==-1) cout << "-i" << endl; else if(r.imag() == 1) cout << "i" << endl; else cout << r.imag() << "i" << endl; } } }else{ cout << "overflow" << endl; } assert(pos >= ln.size()-1); } }
a.cc: In function 'P formula()': a.cc:25:24: error: call of overloaded 'abs(long long int)' is ambiguous 25 | if( abs(ans.real()) > 10000 || abs(ans.imag()) > 10000 ) f = 1; | ~~~^~~~~~~~~~~~ In file included from /usr/include/c++/14/cstdlib:79, from /usr/include/c++/14/ext/string_conversions.h:43, from /usr/include/c++/14/bits/basic_string.h:4154, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ a.cc:5:11: note: candidate: 'long long int abs(long long int)' 5 | long long abs(long long x){ return x<0?-x:x; } | ^~~ In file included from /usr/include/c++/14/cstdlib:81: /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ a.cc:25:51: error: call of overloaded 'abs(long long int)' is ambiguous 25 | if( abs(ans.real()) > 10000 || abs(ans.imag()) > 10000 ) f = 1; | ~~~^~~~~~~~~~~~ /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ a.cc:5:11: note: candidate: 'long long int abs(long long int)' 5 | long long abs(long long x){ return x<0?-x:x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ a.cc: In function 'P term()': a.cc:35:24: error: call of overloaded 'abs(long long int)' is ambiguous 35 | if( abs(r.real()) > 10000 || abs(r.imag()) > 10000 ) f = 1; | ~~~^~~~~~~~~~ /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ a.cc:5:11: note: candidate: 'long long int abs(long long int)' 5 | long long abs(long long x){ return x<0?-x:x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ a.cc:35:49: error: call of overloaded 'abs(long long int)' is ambiguous 35 | if( abs(r.real()) > 10000 || abs(r.imag()) > 10000 ) f = 1; | ~~~^~~~~~~~~~ /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ a.cc:5:11: note: candidate: 'long long int abs(long long int)' 5 | long long abs(long long x){ return x<0?-x:x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ a.cc: In function 'P factor()': a.cc:47:24: error: call of overloaded 'abs(long long int)' is ambiguous 47 | if( abs(r.real()) > 10000 || abs(r.imag()) > 10000 ) f = 1; | ~~~^~~~~~~~~~ /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ a.cc:5:11: note: candidate: 'long long int abs(long long int)' 5 | long long abs(long long x){ return x<0?-x:x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ a.cc:47:49: error: call of overloaded 'abs(long long int)' is ambiguous 47 | if( abs(r.real()) > 10000 || abs(r.imag()) > 10000 ) f = 1; | ~~~^~~~~~~~~~ /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ a.cc:5:11: note: candidate: 'long long int abs(long long int)' 5 | long long abs(long long x){ return x<0?-x:x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i
s617108945
p00684
C++
#include <iostream> #include <complex> using namespace std; #define COMP complex<long long> #define abs(a) (a<0?-a:a) char *p, buf[150]; COMP expr(); COMP fact(){ COMP ret; if(*p == '('){ p++; ret=expr(); p++; }else if(*p == 'i'){ ret=COMP(0,1); p++; }else{ while(isdigit(*p)){ ret = ret * 10 + int(*p - '0'); p ++; if(abs(ret.real()) > 10000 || abs(ret.imag()) > 10000) throw 0; } } return ret; } COMP term(){ COMP ret = fact(); while(*p=='*'){ p++; ret *= fact(); if(abs(ret.real()) > 10000 || abs(ret.imag()) > 10000) throw 0; } return ret; } COMP expr(){ COMP ret = term(); while(*p=='+' || *p=='-'){ char ope = *p++; if(ope=='+') ret += term(); if(ope=='-') ret -= term(); if(abs(ret.real()) > 10000 || abs(ret.imag()) > 10000) throw 0; } return ret; } int main(){ COMP ret; while(cin>>buf){ p = buf; try{ ret = expr(); if(ret.real() || !ret.imag()) cout << ret.real(); if(ret.imag()>0 && ret.real()) cout << '+'; if(ret.imag()) cout<<ret.imag()<<"i"; cout << endl; }catch(...){ cout<<"overflow"<<endl; } } }
a.cc: In function 'std::complex<long long int> fact()': a.cc:24:35: error: no match for 'operator*' (operand types are 'std::complex<long long int>' and 'int') 24 | ret = ret * 10 + int(*p - '0'); | ~~~ ^ ~~ | | | | | int | std::complex<long long int> In file included from a.cc:2: /usr/include/c++/14/complex:400:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const complex<_Tp>&)' 400 | operator*(const complex<_Tp>& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:400:5: note: template argument deduction/substitution failed: a.cc:24:37: note: mismatched types 'const std::complex<_Tp>' and 'int' 24 | ret = ret * 10 + int(*p - '0'); | ^~ /usr/include/c++/14/complex:409:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const complex<_Tp>&, const _Tp&)' 409 | operator*(const complex<_Tp>& __x, const _Tp& __y) | ^~~~~~~~ /usr/include/c++/14/complex:409:5: note: template argument deduction/substitution failed: a.cc:24:37: note: deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int') 24 | ret = ret * 10 + int(*p - '0'); | ^~ /usr/include/c++/14/complex:418:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator*(const _Tp&, const complex<_Tp>&)' 418 | operator*(const _Tp& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:418:5: note: template argument deduction/substitution failed: a.cc:24:37: note: mismatched types 'const std::complex<_Tp>' and 'int' 24 | ret = ret * 10 + int(*p - '0'); | ^~
s053353059
p00684
C++
#include <iostream> #include <complex> using namespace std; #define COMP complex<int> int abs(int a) {return (a<0) ?-a:a} char *p, buf[11000]; COMP expr(); COMP fact(){ COMP ret; if(*p == '('){ p++; ret=expr(); p++; }else if(*p == 'i'){ ret=COMP(0,1); p++; }else{ while(isdigit(*p)){ ret = ret * 10 + int(*p - '0'); p ++; if(abs(ret.real()) > 10000 || abs(ret.imag()) > 10000) throw 0; } } return ret; } COMP term(){ COMP ret = fact(); while(*p=='*'){ p++; ret *= fact(); if(abs(ret.real()) > 10000 || abs(ret.imag()) > 10000) throw 0; } return ret; } COMP expr(){ COMP ret = term(); while(*p=='+' || *p=='-'){ char ope = *p++; if(ope=='+') ret += term(); if(ope=='-') ret -= term(); if(abs(ret.real()) > 10000 || abs(ret.imag()) > 10000) throw 0; } return ret; } int main(){ COMP ret; while(cin>>buf){ p = buf; try{ ret = expr(); if(ret.real() || !ret.imag()) cout << ret.real(); if(ret.imag()>0 && ret.real()) cout << '+'; if(ret.imag()) cout<<ret.imag()<<"i"; cout << endl; }catch(...){ cout<<"overflow"<<endl; } } }
a.cc: In function 'int abs(int)': a.cc:7:35: error: expected ';' before '}' token 7 | int abs(int a) {return (a<0) ?-a:a} | ^ | ;
s053499838
p00684
C++
#include <iostream> #include <string> #include <complex> #include <cstdlib> #include <cctype> using namespace std; int p; string str; bool v; complex<int> expr(); complex<int> factor(); complex<int> term(); bool isValid(complex<int>& c) { if(abs(c.real()) > 10000 || abs(c.imag()) > 10000) return false; return true; } complex<int> parseInt() { int res = 0; while(isdigit(str[p])) { res *= 10; res += str[p] - '0'; p++; v &= isValid(complex<int>(res, 0)); } return complex<int>(res, 0); } complex<int> expr() { complex<int> l = factor(); while(str[p] == '+' || str[p] == '-') { char op = str[p++]; complex<int> r = factor(); if(op == '+') l += r; if(op == '-') l -= r; v &= isValid(l); } return l; } complex<int> factor() { complex<int> l = term(); while(str[p] == '*') { p++; complex<int> r = term(); l *= r; v &= isValid(l); } return l; } complex<int> term() { complex<int> l; if(str[p] == '(') { p++; l = expr(); p++; } else if(str[p] == 'i') { l = complex<int>(0, 1); p++; } else { l = parseInt(); } v &= isValid(l); return l; } int main() { while(cin >> str) { v = true; str += '$'; p = 0; complex<int> res = expr(); if(v == false) cout << "overflow" << endl; else { if(res.real() == 0 && res.imag() == 0) { cout << res.real() << endl; } else if(res.real() == 0) { cout << res.imag() << "i" << endl; } else if(res.imag() == 0) { cout << res.real() << endl; } else { cout << res.real() << (res.imag() > 0 ? "+" : "-") << abs(res.imag()) << "i" << endl; } } } }
a.cc: In function 'std::complex<int> parseInt()': a.cc:30:30: error: cannot bind non-const lvalue reference of type 'std::complex<int>&' to an rvalue of type 'std::complex<int>' 30 | v &= isValid(complex<int>(res, 0)); | ^~~~~~~~~~~~~~~~~~~~ a.cc:16:28: note: initializing argument 1 of 'bool isValid(std::complex<int>&)' 16 | bool isValid(complex<int>& c) | ~~~~~~~~~~~~~~^
s000757064
p00684
C++
#define _USE_MATH_DEFINES #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <climits> #include <cfloat> #include <ctime> #include <cassert> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> #include <numeric> #include <list> #include <iomanip> #include <iterator> using namespace std; typedef long long ll; typedef pair<int,int> Pii; typedef pair<ll,ll> Pll; #define FOR(i,n) for(int i = 0; i < (n); i++) #define sz(c) ((int)c.size()) typedef unsigned long long ull; const int INF = (int)1e8; typedef complex<int> P; bool er; void is_error(P& p){ er |= !(abs(p.real()) <= 10000 && abs(p.imag()) <= 10000); } P expr(const char *& s); P val(const char *& s){ if(*s == '('){ s++; P ret = expr(s); s++; return ret; } if(*s == 'i'){ s++; return P(0,1); } int v = 0; while(*s >= '0' && *s <= '9'){ v *= 10; v += *s - '0'; s++; is_error(P(v,0)); } P ret = P(v,0); return ret; } P pri(const char *& s){ if(*s == '-'){ s++; return -1 * pri(s); } P l = val(s); while(true){ char ope = *s; if(ope != '*' && ope != '/') return l; s++; P r = val(s); if(ope == '*') l *= r; else l /= r; is_error(l); } } P expr(const char *& s){ P l = pri(s); while(true){ char ope = *s; if(ope != '+' && ope != '-') return l; s++; P r = pri(s); if(ope == '+') l+=r; else l-=r; is_error(l); } } int main(){ string s; while(cin>>s){ const char *p = s.c_str(); er = false; P ans = expr(p); if(er){ puts("overflow"); }else{ if(ans.imag() == 0) printf("%d\n",ans.real()); else if(ans.real() == 0){ printf("%di\n",ans.imag()); } else { printf("%d%+di\n",ans.real(),ans.imag()); } } } return 0; }
a.cc: In function 'P val(const char*&)': a.cc:66:26: error: cannot bind non-const lvalue reference of type 'P&' {aka 'std::complex<int>&'} to an rvalue of type 'P' {aka 'std::complex<int>'} 66 | is_error(P(v,0)); | ^~~~~~ a.cc:44:18: note: initializing argument 1 of 'void is_error(P&)' 44 | void is_error(P& p){ | ~~~^
s561561765
p00684
C++
#include <iostream> #include <string> #include <cstdio> #include <cstdlib> using namespace std; struct complex{ int re, im; complex(int r, int i): re(r), im(i){ if(abs(r) > 10000 || abs(i) > 10000) throw 0; } complex operator+ (const complex &c) const{ return complex(re + c.re, im + c.im); } complex operator- (const complex &c) const{ return complex(re - c.re, im - c.im); } complex operator* (const complex &c) const{ int r = re * c.re - im * c.im; int i = re * c.im + im * c.re; return complex(r, i); } }; const char *p; complex expr(); complex factor(){ if(*p == '+'){ ++p; return factor(); } if(*p == '-'){ ++p; return complex(0, 0) - factor(); } if(*p == '('){ ++p; complex c = expr(); ++p; return c; } if(*p == 'i'){ ++p; return complex(0, 1); } char *endp; int r = strtol(p, &endp, 10); p = endp; return complex(r, 0); } complex term(){ complex c = factor(); while(*p == '*'){ ++p; c = c * factor(); } return c; } complex expr(){ complex c = term(); while(1){ if(*p == '+'){ ++p; c = c + term(); } else if(*p == '-'){ ++p; c = c - term(); } else{ break; } } return c; } int main(){ string s; while(cin >> s){ p = s.c_str(); try{ complex c = expr(); if(c.re != 0){ printf("%d", c.re); if(c.im != 0){ printf("%+di", c.im); } } else{ if(c.im == 0){ printf("0"); } else{ printf("%di", c.im); } } puts(""); } catch(...){ puts("overflow"); } }
a.cc: In function 'int main()': a.cc:111:2: error: expected '}' at end of input 111 | } | ^ a.cc:86:11: note: to match this '{' 86 | int main(){ | ^
s799067086
p00684
C++
#include <iostream> #include <sstream> #include <cstdio> #include <cstdlib> #include <cmath> #include <ctime> #include <cstring> #include <climits> #include <algorithm> #include <map> #include <set> #include <stack> #include <vector> #include <queue> #include <string> #include <complex> using namespace std; #define rep(i,n) for(int i=0; i<n; i++) #define repa(i,s,e) for(int i=s; i<=e; i++) #define repd(i,s,e) for(int i=s; i>=e; i--) #define mp(a,b) make_pair(a, b) typedef vector<int> vi; typedef long long ll; typedef complex<int> C; char eq[128]; int index; bool of; C number(); C eval1(); C eval2(); C eval3(); C eval(); void check(C v) { if(abs(v.real()) > 10000 || abs(v.imag()) > 10000) { of = true; } } C number() { if(eq[index] == 'i') { index++; return C(0, 1); } int value = 0; while(isdigit(eq[index])) { value = value * 10 + (eq[index] - '0'); index++; } return C(value, 0); } C eval3() { if(eq[index] == '(') { index++; C value = eval1(); if(eq[index] == ')') { index++; return value; } } else { return number(); } cout << "Error" << endl; return C(0, 0); } C eval2() { C value = eval3(); for(;;) { if(eq[index] == '*') { index++; value *= eval3(); } else { break; } } return value; } C eval1() { C value = eval2(); for(;;) { if(eq[index] == '+') { index++; value += eval2(); } else if(eq[index] == '-') { index++; value -= eval2(); } else { break; } } check(value); return value; } C eval() { index = 0; of = false; return eval1(); } void print(C v) { if(of) { printf("overflow\n"); return; } if(v.real() == 0 && v.imag() == 0) { printf("0\n"); return; } if(v.real() != 0 && v.imag() == 0) { printf("%d\n", v.real()); return; } if(v.real() == 0 && v.imag() != 0) { printf("%di\n", v.imag()); return; } if(v.imag() > 0) { printf("%d+%di\n", v.real(), v.imag()); return; } if(v.imag() < 0) { printf("%d%di\n", v.real(), v.imag()); return; } cout << "unknown expression" << endl; } int main() { while(scanf("%s", eq)!=EOF) { C value = eval(); print(value); } }
a.cc:29:5: error: 'int index' redeclared as different kind of entity 29 | int index; | ^~~~~ In file included from /usr/include/string.h:462, from /usr/include/c++/14/cstring:43, from a.cc:7: /usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)' 50 | extern const char *index (const char *__s, int __c) | ^~~~~ a.cc: In function 'C number()': a.cc:45:14: error: invalid types 'char [128][<unresolved overloaded function type>]' for array subscript 45 | if(eq[index] == 'i') { | ^ a.cc:46:22: error: no post-increment operator for type 46 | index++; | ^~ a.cc:51:25: error: invalid types 'char [128][<unresolved overloaded function type>]' for array subscript 51 | while(isdigit(eq[index])) { | ^ a.cc:52:41: error: invalid types 'char [128][<unresolved overloaded function type>]' for array subscript 52 | value = value * 10 + (eq[index] - '0'); | ^ a.cc:53:22: error: no post-increment operator for type 53 | index++; | ^~ a.cc: In function 'C eval3()': a.cc:59:14: error: invalid types 'char [128][<unresolved overloaded function type>]' for array subscript 59 | if(eq[index] == '(') { | ^ a.cc:60:22: error: no post-increment operator for type 60 | index++; | ^~ a.cc:63:22: error: invalid types 'char [128][<unresolved overloaded function type>]' for array subscript 63 | if(eq[index] == ')') { | ^ a.cc:64:30: error: no post-increment operator for type 64 | index++; | ^~ a.cc: In function 'C eval2()': a.cc:78:22: error: invalid types 'char [128][<unresolved overloaded function type>]' for array subscript 78 | if(eq[index] == '*') { | ^ a.cc:79:30: error: no post-increment operator for type 79 | index++; | ^~ a.cc: In function 'C eval1()': a.cc:92:22: error: invalid types 'char [128][<unresolved overloaded function type>]' for array subscript 92 | if(eq[index] == '+') { | ^ a.cc:93:30: error: no post-increment operator for type 93 | index++; | ^~ a.cc:96:27: error: invalid types 'char [128][<unresolved overloaded function type>]' for array subscript 96 | else if(eq[index] == '-') { | ^ a.cc:97:30: error: no post-increment operator for type 97 | index++; | ^~ a.cc: In function 'C eval()': a.cc:109:17: error: overloaded function with no contextual type information 109 | index = 0; | ^
s299520002
p00684
C++
#include <iostream> #include <string> #include <complex> using namespace std; // typedef complex<int> comp; class comp : public complex<int> { public: comp() : complex<int>() {} comp(complex<int> const& c) { real(c.real()), imag(c.imag()); } bool overflow; }; int const lim = 10000; comp operate(const comp &a, const comp &b, char o) { comp c; if (o == '+') { c=a+b; } else if (o == '-') { c=a-b; } else /* if (0 == '*') */ { c=a*b; } bool t = c.real() > lim || c.real() < -lim || c.imag() > lim || c.imag() < -lim; c.overflow = a.overflow || b.overflow ? true : t; return c; } comp expr(string const&); comp term(string const&); comp fctr(string const&); comp expr(string &s) { comp a = term(s); while (s[0] == '+' || s[0] == '-') { char o = s[0]; s.erase(0, 1); comp b = term(s); a = operate(a, b, o); } return a; } comp term(string &s) { comp a = fctr(s); while (s[0] == '*') { s.erase(0, 1); comp b = fctr(s); a = operate(a, b, '*'); } return a; } comp fctr(string &s) { comp z; z.overflow = false; if (s[0] == '(') { s.erase(0, 1); z = expr(s); s.erase(0, 1); return z; } int sign = 1; if (s[0] == '+') s.erase(0, 1); else if (s[0] == '-') { s.erase(0, 1); sign = -1; } if (s[0] == 'i') { s.erase(0, 1); z.imag(sign); return z; } int i = 0; while (s[i] >= '0' && s[i] <= '9') { z.real(z.real() * 10 + s[i] - '0'); i++; if (z.real() > lim) z.overflow = true; } z.real(z.real()*sign); s.erase(0, i); return z; } void print(const comp &z) { if (z.imag() == 0){ cout << z.real() << endl; } else if (z.real() == 0) { cout << z.imag() << "i" << endl; } else { cout << z.real(); if (z.imag() > 0) cout << "+"; cout << z.imag() << "i" << endl; } } int main() { string s; while (cin >> s) { comp z = expr(s); if (z.overflow) puts("overflow"); else print(z); } }
/usr/bin/ld: /tmp/ccMTruPL.o: in function `expr(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)': a.cc:(.text+0x197): undefined reference to `term(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' /usr/bin/ld: a.cc:(.text+0x1e1): undefined reference to `term(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' /usr/bin/ld: /tmp/ccMTruPL.o: in function `term(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&)': a.cc:(.text+0x29b): undefined reference to `fctr(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' /usr/bin/ld: a.cc:(.text+0x2ce): undefined reference to `fctr(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)' collect2: error: ld returned 1 exit status
s009620523
p00684
C++
// Calculation of Expressions import java.util.*; public class Main { static String formula; static int pos; static boolean overflow; public static void main(String[] args) { Scanner sc = new Scanner(System.in); formula = sc.next(); pos = 0; overflow = false; Complex c = parse(); if (overflow) System.out.println("overflow"); else System.out.println(c); sc.close(); } static Complex parse() { Complex result = term(); while (pos < formula.length()) { if (formula.charAt(pos++) == '+') result = result.add(term()); else result = result.sub(term()); } return result; } static Complex term() { Complex result = mul(); while (pos < formula.length() && formula.charAt(pos) == '*') { pos++; result = result.mul(mul()); } return result; } static Complex mul() { Complex result; if (Character.isDigit(formula.charAt(pos))) return new Complex(number(), 0); if (formula.charAt(pos++) == 'i') return new Complex(0, 1); result = term(); while(pos < formula.length()&&formula.charAt(pos) != ')'){ if(formula.charAt(pos++) == '+') result = result.add(term()); else result = result.sub(term()); } pos++; return result; } static int number() { int result = 0; while (pos < formula.charAt(pos) && Character.isDigit(formula.charAt(pos))) { result *= 10; result += formula.charAt(pos++) - '0'; } return result; } static class Complex { int real, imaginary; Complex(int r, int i) { real = r; imaginary = i; checkOverflow(); } Complex add(Complex anotherComplex) { return new Complex(this.real + anotherComplex.real, this.imaginary + anotherComplex.imaginary); } Complex sub(Complex anotherComplex) { return new Complex(this.real - anotherComplex.real, this.imaginary - anotherComplex.imaginary); } Complex mul(Complex anotherComplex) { return new Complex(this.real * anotherComplex.real - this.imaginary * anotherComplex.imaginary, this.real * anotherComplex.imaginary + this.imaginary * anotherComplex.real); } @Override public String toString() { StringBuilder sb = new StringBuilder(); if (real == 0) { if (imaginary == 0) return sb.append("0").toString(); return sb.append(imaginary).append("i").toString(); } sb.append(real); if (imaginary == 0) return sb.toString(); if (imaginary < 0) return sb.append(imaginary).append("i").toString(); return sb.append("+").append(imaginary).append("i").toString(); } void checkOverflow() { if (Math.abs(real) <= 10000 && Math.abs(imaginary) <= 10000) return; pos = formula.length(); overflow = true; } } }
a.cc:95:17: error: stray '@' in program 95 | @Override | ^ a.cc:2:1: error: 'import' does not name a type 2 | import java.util.*; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: expected unqualified-id before 'public' 4 | public class Main { | ^~~~~~
s398049153
p00685
Java
import java.util.Scanner; public class AOJ_1103{ int HEIGHT = 4; int WIDTH = 4; int[][] relationXY; void run(){ Scanner sc = new Scanner(System.in); //int[][] temp = { { -2, 1},{ -1, 1},{ 1, 1},{ 1, 2}}; while(true){ int[][] temp = new int[4][2]; int x = sc.nextInt(); if(x > 4){ break; } int y = sc.nextInt(); temp[0][0] = x; temp[0][1] = y; for(int i = 1;i < 4;i++){ temp[i][0] = sc.nextInt(); temp[i][1] = sc.nextInt(); } relationXY = temp; boolean[][] visited = new boolean[HEIGHT][WIDTH]; System.out.println(dfs(visited,HEIGHT*WIDTH,0)); } } int dfs(boolean[][] visited,int remain,int next){ /* System.out.println("remain "+remain); for(int i = 0;i < HEIGHT;i++){ for(int ii = 0;ii < WIDTH;ii++){ System.out.print(visited[i][ii]? 1: 0); } System.out.println(); } */ if(remain == 0){ return 1; } if(next >= HEIGHT*WIDTH){ return 0; } int count = 0; int y = next / HEIGHT; int x = next % WIDTH; if( visited[y][x]){ count+=dfs(visited,remain,next+1); } else{ for(int i = 0;i < relationXY.length;i++){ int rx = x + relationXY[i][0]; int ry = y + relationXY[i][1]; if(rx < 0 || WIDTH <= rx || ry < 0 || HEIGHT <= ry){ continue; } if(!visited[ry][rx]){ visited[y][x] = true; visited[ry][rx] = true; count += dfs(visited,remain-2,next+1); visited[y][x] = false; visited[ry][rx] = false; } } } return count; } public static void main(String[] args) { new AOJ_1103().run(); } }
Main.java:3: error: class AOJ_1103 is public, should be declared in a file named AOJ_1103.java public class AOJ_1103{ ^ 1 error
s734022720
p00685
C++
#include "stdafx.h" #include <stdio.h> // #include <windows.h> int ans = 0; int x[4],y[4]; int depth = 0; int put_map(int m[4][4],int current){ if(depth == 8){ ans++; return 0; } int i,j,k,a,b,pointer; int next1,next2; int copy[4][4]; for(pointer = current; pointer < 15; pointer++){ i = pointer / 4; j = pointer % 4; if(m[i][j] == 0){ for(k = 0; k < 4; k++){ next1 = i + x[k]; next2 = j + y[k]; if(0 <= next1 && next1 <= 3 && 0 <= next2 && next2 <= 3){ if(m[next1][next2] == 0){ for(a = 0; a < 4; a++){ for(b = 0; b < 4; b++){ copy[a][b] = m[a][b]; } } copy[i][j] = 1; copy[next1][next2] = 1; depth++; // for(a = 0; a < 4; a++){ // for(b = 0; b < 4; b++){ // printf("%d",copy[b][a]); // } // printf("\n"); // } put_map(copy,pointer); depth--; copy[i][j] = 0; copy[next1][next2] = 0; } } next1 = i - x[k]; next2 = j - y[k]; if(0 <= next1 && next1 <= 3 && 0 <= next2 && next2 <= 3){ if(m[next1][next2] == 0){ for(a = 0; a < 4; a++){ for(b = 0; b < 4; b++){ copy[a][b] = m[a][b]; } } copy[i][j] = 1; copy[next1][next2] = 1; depth++; for(a = 0; a < 4; a++){ for(b = 0; b < 4; b++){ printf("%d",copy[b][a]); } printf("\n"); } put_map(copy,pointer); depth--; copy[i][j] = 0; copy[next1][next2] = 0; } } } return 0; } } return 0; } int main() { int map[4][4]; int i,j; scanf("%d",&x[0]); while(x[0] < 4){ scanf("%d",&y[0]); for(i = 1; i < 4; i++){ scanf("%d %d",&x[i],&y[i]); // x,yの読み取り } ans = 0; // 解の個数を0に戻す depth = 0; // 探索中の深さを0に戻す for(i = 0; i < 4; i++){ for(j = 0; j < 4; j++){ map[i][j] = 0; // マップの初期化 } } i = put_map(map,0); printf("%d\n",ans); // 解の出力 scanf("%d",&x[0]); } return 0; }
a.cc:1:10: fatal error: stdafx.h: No such file or directory 1 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s269900901
p00685
C++
#include "stdafx.h" #include <stdio.h> int ans = 0; int x[4],y[4]; int depth = 0; int put_map(int m[4][4],int current){ if(depth == 8){ ans++; return 0; } int i,j,k,a,b,pointer; int next1,next2; int copy[4][4]; for(pointer = current; pointer < 15; pointer++){ i = pointer / 4; j = pointer % 4; if(m[i][j] == 0){ for(k = 0; k < 4; k++){ next1 = i + x[k]; next2 = j + y[k]; if(0 <= next1 && next1 <= 3 && 0 <= next2 && next2 <= 3){ if(m[next1][next2] == 0){ for(a = 0; a < 4; a++){ for(b = 0; b < 4; b++){ copy[a][b] = m[a][b]; } } copy[i][j] = 1; copy[next1][next2] = 1; depth++; put_map(copy,pointer); depth--; copy[i][j] = 0; copy[next1][next2] = 0; } } next1 = i - x[k]; next2 = j - y[k]; if(0 <= next1 && next1 <= 3 && 0 <= next2 && next2 <= 3){ if(m[next1][next2] == 0){ for(a = 0; a < 4; a++){ for(b = 0; b < 4; b++){ copy[a][b] = m[a][b]; } } copy[i][j] = 1; copy[next1][next2] = 1; depth++; for(a = 0; a < 4; a++){ for(b = 0; b < 4; b++){ printf("%d",copy[b][a]); } printf("\n"); } put_map(copy,pointer); depth--; copy[i][j] = 0; copy[next1][next2] = 0; } } } return 0; } } return 0; } int main() { int map[4][4]; int i,j; scanf("%d",&x[0]); while(x[0] < 4){ scanf("%d",&y[0]); for(i = 1; i < 4; i++){ scanf("%d %d",&x[i],&y[i]); } ans = 0; depth = 0; for(i = 0; i < 4; i++){ for(j = 0; j < 4; j++){ map[i][j] = 0; } } i = put_map(map,0); printf("%d\n",ans); scanf("%d",&x[0]); } return 0; }
a.cc:1:10: fatal error: stdafx.h: No such file or directory 1 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s398880643
p00685
C++
using namespace std; #include <iostream> #include <vector> #define REP(i, n) for(int i=0; i<n; i++) typedef vector<int> VI; int cnt; int num[8]; void solve(VI board, int depth) { //end check if(depth == 8) { bool is_end = true; REP(i, board.size()) { if(board[i] == 0) { is_end = false; break; } } if(is_end){ cnt++; return; } } //normal procedure bool is_set = false; REP(y, 4) { REP(x, 4) { if(board[y*4+x] == 0) { REP(i, 4) { int dx = num[i*2+0]; int dy = num[i*2+1]; int xx = x + dx; int yy = y + dy; if(xx>=0 && yy>=0 && xx<4 && yy<4) { if(board[yy*4+xx] == 0) { VI v = VI(16); memcpy(&v[0], &board[0], sizeof(int)*16); v[y*4+x] = depth+1; v[yy*4+xx] = depth+1; solve(v, depth+1); } } } is_set = true; break; } } if(is_set) break; } } int main() { while( 1 ) { scanf("%d", &num[0]); if(num[0] > 4) break; for(int i=1; i<8; i++) { scanf("%d", &num[i]); } cnt = 0; VI v = VI(16); memset(&v[0], 0, sizeof(int)*16); solve(v, 0); printf("%d\n", cnt); } }
a.cc: In function 'void solve(VI, int)': a.cc:52:57: error: 'memcpy' was not declared in this scope 52 | memcpy(&v[0], &board[0], sizeof(int)*16); | ^~~~~~ a.cc:4:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <vector> +++ |+#include <cstring> 4 | a.cc: In function 'int main()': a.cc:81:17: error: 'memset' was not declared in this scope 81 | memset(&v[0], 0, sizeof(int)*16); | ^~~~~~ a.cc:81:17: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
s867694389
p00686
Java
import java.util.*; class Main{ public static void main(String[] args){ Scanner sc=new Scanner(System.in); int mX,mY; int ang=0; String[] puts=new String[50]; do{ int x=sc.nextInt(); int y=sc.nextInt(); String s=sc.next(); while(!(s.equals("STOP"))){ if(s.equals("FORWARD"){ int f=sc.nextInt(); switch(ang){ case 0: for(int i=0;i<f;i++){ if(x!=100){ x++; } } break; case 1: for(int i=0;i<f;i++){ if(y!=100){ y++; } } break; case 2: for(int i=0;i<f;i++){ if(x!=0){ x--; } } break; case 3: for(int i=0;i<f;i++){ if(y!=0){ y--; } } break; } }else if(s.equals("RIGHT"){ if(ang!=3){ ang++; }else{ ang=0; } }else if(s.equals("LEFT"){ if(ang!=0){ ang--; }else{ ang=3; } } } System.out.println(mX+" "+mY); }while((x!=0)&&(y!=0)); } }
Main.java:15: error: ')' expected if(s.equals("FORWARD"){ ^ Main.java:47: error: ')' expected }else if(s.equals("RIGHT"){ ^ Main.java:53: error: ')' expected }else if(s.equals("LEFT"){ ^ 3 errors
s843018629
p00686
Java
import java.util.*; public class AOJ1104{ public static void main(String[] args){ int Walk,x,y,w,h; Scanner in = new Scanner(System.in); final int[] dx = {0,1,0,-1}; final int[] dy = {1,0,-1,0}; int dir; while(true){ w = in.nextInt(); h = in.nextInt(); if(w+h == 0)break; dir = 0; x=y=1; while(true){ String op = in.next(); if(op.equals("STOP"))break; if(op.equals("RIGHT")){ ++dir; if(dir == 4)dir = 0; } else if(op.equals("LEFT")){ --dir; if(dir == -1)dir = 3; } else if(op.equals("FORWARD")){ Walk = in.nextInt(); x = x + Walk*dx[dir]; if(x > w)x = w; if(x <= 0)x=1; y = y + Walk*dy[dir]; if(y > h)y = h; if(y <= 0)y=1; } else if(op.equals("BACKWARD")){ Walk = in.nextInt(); x = x - Walk*dx[dir]; if(x > w)x = w; else if(x < 0)x = 1; y = y - Walk*dy[dir]; if(y > h)y = h; else if(y <= 0)y = 1; } } System.out.println(x + " " + y); } } }
Main.java:3: error: class AOJ1104 is public, should be declared in a file named AOJ1104.java public class AOJ1104{ ^ 1 error
s461787113
p00686
C
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);int[][]ds={{0,1},{1,0},{0,-1},{-1,0}};for(int[]n={0,0};(n[0]=s.nextInt())>0;){n[1]=s.nextInt();int[]p={1,1};int d=0,i,x;for(String y;!(y=s.next()).equals("STOP");System.out.println(p[0]+" "+p[1])){if(y.endsWith("D"))for(i=2,x=s.nextInt();i-->0;)p[i]=Math.min(n[i],Math.max(1,p[i]+ds[d][i]*x*(y.charAt(0)==70?1:-1)));if(y.charAt(0)==76)d=(d+3)%4;if(y.charAt(0)==82)d=(d+1)%4;}}}}
main.c:1:1: error: unknown type name 'import' 1 | import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);int[][]ds={{0,1},{1,0},{0,-1},{-1,0}};for(int[]n={0,0};(n[0]=s.nextInt())>0;){n[1]=s.nextInt();int[]p={1,1};int d=0,i,x;for(String y;!(y=s.next()).equals("STOP");System.out.println(p[0]+" "+p[1])){if(y.endsWith("D"))for(i=2,x=s.nextInt();i-->0;)p[i]=Math.min(n[i],Math.max(1,p[i]+ds[d][i]*x*(y.charAt(0)==70?1:-1)));if(y.charAt(0)==76)d=(d+3)%4;if(y.charAt(0)==82)d=(d+1)%4;}}}} | ^~~~~~ main.c:1:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token 1 | import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);int[][]ds={{0,1},{1,0},{0,-1},{-1,0}};for(int[]n={0,0};(n[0]=s.nextInt())>0;){n[1]=s.nextInt();int[]p={1,1};int d=0,i,x;for(String y;!(y=s.next()).equals("STOP");System.out.println(p[0]+" "+p[1])){if(y.endsWith("D"))for(i=2,x=s.nextInt();i-->0;)p[i]=Math.min(n[i],Math.max(1,p[i]+ds[d][i]*x*(y.charAt(0)==70?1:-1)));if(y.charAt(0)==76)d=(d+3)%4;if(y.charAt(0)==82)d=(d+1)%4;}}}} | ^ main.c:1:20: error: unknown type name 'class' 1 | import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);int[][]ds={{0,1},{1,0},{0,-1},{-1,0}};for(int[]n={0,0};(n[0]=s.nextInt())>0;){n[1]=s.nextInt();int[]p={1,1};int d=0,i,x;for(String y;!(y=s.next()).equals("STOP");System.out.println(p[0]+" "+p[1])){if(y.endsWith("D"))for(i=2,x=s.nextInt();i-->0;)p[i]=Math.min(n[i],Math.max(1,p[i]+ds[d][i]*x*(y.charAt(0)==70?1:-1)));if(y.charAt(0)==76)d=(d+3)%4;if(y.charAt(0)==82)d=(d+1)%4;}}}} | ^~~~~ main.c:1:30: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token 1 | import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);int[][]ds={{0,1},{1,0},{0,-1},{-1,0}};for(int[]n={0,0};(n[0]=s.nextInt())>0;){n[1]=s.nextInt();int[]p={1,1};int d=0,i,x;for(String y;!(y=s.next()).equals("STOP");System.out.println(p[0]+" "+p[1])){if(y.endsWith("D"))for(i=2,x=s.nextInt();i-->0;)p[i]=Math.min(n[i],Math.max(1,p[i]+ds[d][i]*x*(y.charAt(0)==70?1:-1)));if(y.charAt(0)==76)d=(d+3)%4;if(y.charAt(0)==82)d=(d+1)%4;}}}} | ^
s095544594
p00686
C
#include<stdio.h> #include<string.h> int main(void){ &#160; struct place{ &#160; &#160; char x,y,dir; &#160; } now; &#160; unsigned int m,n; &#160; int k; &#160; char input[32],command[16]; &#160; while(scanf("%u%u%*c",&m,&n) && m && n){ &#160; &#160; now=(struct place){1,1,0}; &#160; &#160;&#160; &#160; &#160; while(scanf("%31[^\n]%*c",input) && strcmp(input,"STOP")){ &#160; &#160; &#160; if(!strcmp(input,"RIGHT")){ now.dir+=1; now.dir%=4; continue; &#160; &#160; &#160; }else if(!strcmp(input,"LEFT")){ now.dir+=3; now.dir%=4; continue; &#160; &#160; &#160; } &#160; &#160; &#160; sscanf(input,"%15s%d",command,&k); &#160; &#160; &#160; if(!strcmp(command,"BACKWARD")) k*=-1; &#160; &#160; &#160; if(now.dir%2){ k*=(now.dir==3)?-1:1; now.x+=k; if(now.x<1) now.x=1; else if(now.x>m) now.x=m; &#160; &#160; &#160; }else{ k*=(now.dir==2)?-1:1; now.y+=k; if(now.y<1) now.y=1; else if(now.y>n) now.y=n; &#160; &#160; &#160; } &#160; &#160; } &#160; &#160; printf("%d %d\n",now.x,now.y); &#160; } &#160; return 0; }
main.c: In function 'main': main.c:8:2: error: stray '#' in program 8 | &#160; struct place{ | ^ main.c:8:1: error: lvalue required as unary '&' operand 8 | &#160; struct place{ | ^ main.c:9:1: error: expected specifier-qualifier-list before '&' token 9 | &#160; &#160; char x,y,dir; | ^ main.c:9:2: error: stray '#' in program 9 | &#160; &#160; char x,y,dir; | ^ main.c:9:9: error: stray '#' in program 9 | &#160; &#160; char x,y,dir; | ^ main.c:10:2: error: stray '#' in program 10 | &#160; } now; | ^ main.c:11:2: error: stray '#' in program 11 | &#160; unsigned int m,n; | ^ main.c:11:1: error: lvalue required as unary '&' operand 11 | &#160; unsigned int m,n; | ^ main.c:12:2: error: stray '#' in program 12 | &#160; int k; | ^ main.c:12:1: error: lvalue required as unary '&' operand 12 | &#160; int k; | ^ main.c:13:2: error: stray '#' in program 13 | &#160; char input[32],command[16]; | ^ main.c:13:1: error: lvalue required as unary '&' operand 13 | &#160; char input[32],command[16]; | ^ main.c:18:2: error: stray '#' in program 18 | &#160; while(scanf("%u%u%*c",&m,&n) && m && n){ | ^ main.c:18:1: error: lvalue required as unary '&' operand 18 | &#160; while(scanf("%u%u%*c",&m,&n) && m && n){ | ^ main.c:19:2: error: stray '#' in program 19 | &#160; &#160; now=(struct place){1,1,0}; | ^ main.c:19:1: error: lvalue required as unary '&' operand 19 | &#160; &#160; now=(struct place){1,1,0}; | ^ main.c:19:9: error: stray '#' in program 19 | &#160; &#160; now=(struct place){1,1,0}; | ^ main.c:19:8: error: lvalue required as unary '&' operand 19 | &#160; &#160; now=(struct place){1,1,0}; | ^ main.c:19:34: warning: excess elements in struct initializer 19 | &#160; &#160; now=(struct place){1,1,0}; | ^ main.c:19:34: note: (near initialization for '(anonymous)') main.c:19:36: warning: excess elements in struct initializer 19 | &#160; &#160; now=(struct place){1,1,0}; | ^ main.c:19:36: note: (near initialization for '(anonymous)') main.c:19:38: warning: excess elements in struct initializer 19 | &#160; &#160; now=(struct place){1,1,0}; | ^ main.c:19:38: note: (near initialization for '(anonymous)') main.c:20:2: error: stray '#' in program 20 | &#160; &#160;&#160; | ^ main.c:20:1: error: lvalue required as unary '&' operand 20 | &#160; &#160;&#160; | ^ main.c:20:9: error: stray '#' in program 20 | &#160; &#160;&#160; | ^ main.c:20:8: error: lvalue required as unary '&' operand 20 | &#160; &#160;&#160; | ^ main.c:20:15: error: stray '#' in program 20 | &#160; &#160;&#160; | ^ main.c:20:14: error: lvalue required as unary '&' operand 20 | &#160; &#160;&#160; | ^ main.c:21:2: error: stray '#' in program 21 | &#160; &#160; while(scanf("%31[^\n]%*c",input) && strcmp(input,"STOP")){ | ^ main.c:21:1: error: lvalue required as unary '&' operand 21 | &#160; &#160; while(scanf("%31[^\n]%*c",input) && strcmp(input,"STOP")){ | ^ main.c:21:9: error: stray '#' in program 21 | &#160; &#160; while(scanf("%31[^\n]%*c",input) && strcmp(input,"STOP")){ | ^ main.c:21:8: error: lvalue required as unary '&' operand 21 | &#160; &#160; while(scanf("%31[^\n]%*c",input) && strcmp(input,"STOP")){ | ^ main.c:22:2: error: stray '#' in program 22 | &#160; &#160; &#160; if(!strcmp(input,"RIGHT")){ | ^ main.c:22:1: error: lvalue required as unary '&' operand 22 | &#160; &#160; &#160; if(!strcmp(input,"RIGHT")){ | ^ main.c:22:9: error: stray '#' in program 22 | &#160; &#160; &#160; if(!strcmp(input,"RIGHT")){ | ^ main.c:22:8: error: lvalue required as unary '&' operand 22 | &#160; &#160; &#160; if(!strcmp(input,"RIGHT")){ | ^ main.c:22:16: error: stray '#' in program 22 | &#160; &#160; &#160; if(!strcmp(input,"RIGHT")){ | ^ main.c:22:15: error: lvalue required as unary '&' operand 22 | &#160; &#160; &#160; if(!strcmp(input,"RIGHT")){ | ^ main.c:23:12: error: 'struct place' has no member named 'dir' 23 | now.dir+=1; | ^ main.c:24:12: error: 'struct place' has no member named 'dir' 24 | now.dir%=4; | ^ main.c:26:2: error: stray '#' in program 26 | &#160; &#160; &#160; }else if(!strcmp(input,"LEFT")){ | ^ main.c:26:1: error: lvalue required as unary '&' operand 26 | &#160; &#160; &#160; }else if(!strcmp(input,"LEFT")){ | ^ main.c:26:9: error: stray '#' in program 26 | &#160; &#160; &#160; }else if(!strcmp(input,"LEFT")){ | ^ main.c:26:8: error: lvalue required as unary '&' operand 26 | &#160; &#160; &#160; }else if(!strcmp(input,"LEFT")){ | ^ main.c:26:16: error: stray '#' in program 26 | &#160; &#160; &#160; }else if(!strcmp(input,"LEFT")){ | ^ main.c:26:15: error: lvalue required as unary '&' operand 26 | &#160; &#160; &#160; }else if(!strcmp(input,"LEFT")){ | ^ main.c:27:12: error: 'struct place' has no member named 'dir' 27 | now.dir+=3; | ^ main.c:28:12: error: 'struct place' has no member named 'dir' 28 | now.dir%=4; | ^ main.c:30:2: error: stray '#' in program 30 | &#160; &#160; &#160; } | ^ main.c:30:1: error: lvalue required as unary '&' operand 30 | &#160; &#160; &#160; } | ^ main.c:30:9: error: stray '#' in program 30 | &#160; &#160; &#160; } | ^ main.c:30:8: error: lvalue required as unary '&' operand 30 | &#160; &#160; &#160; } | ^ main.c:30:16: error: stray '#' in program 30 | &#160; &#160; &#160; } | ^ main.c:30:15: error: lvalue required as unary '&' operand 30 | &#160; &#160; &#160; } | ^ main.c:31:2: error: stray '#' in program 31 | &#160; &#160; &#160; sscanf(input,"%15s%d",command,&k); | ^ main.c:31:1: error: lvalue required as unary '&' operand 31 | &#160; &#160; &#160; sscanf(input,"%15s%d",command,&k); | ^ main.c:31:9: error: stray '#' in program 31 | &#160; &#160; &#160; sscanf(input,"%15s%d",command,&k); | ^ main.c:31:8: error: lvalue required as unary '&' operand 31 | &#160; &#160; &#160; sscanf(input,"%15s%d",command,&k); | ^ main.c:31:16: error: stray '#' in program 31 | &#160; &#160; &#160; sscanf(input,"%15s%d",command,&k); | ^ main.c:31:15: error: lvalue required as unary '&' operand 31 | &#160; &#160; &#160; sscanf(input,"%15s%d",command,&k); | ^ main.c:32:2: error: stray '#' in program 32 | &#160; &#160; &#160; if(!strcmp(command,"BACKWARD")) k*=-1; | ^ main.c:32:1: error: lvalue required as unary '&' operand 32 | &#160; &#160; &#160; if(!strcmp(command,"BACKWARD")) k*=-1; | ^ main.c:32:9: error: stray '#' in program 32 | &#160; &#160; &#160; if(!strcmp(command,"BACKWARD")) k*=-1; | ^ main.c:32:8: error: lvalue required as unary '&' operand 32 | &#160; &#160; &#160; if(!strcmp(command,"BACKWARD")) k*=-1; | ^ main.c:32:16: error: stray '#' in program 32 | &#160; &#160; &#160; if(!strcmp(command,"BACKWARD")) k*=-1; | ^ main.c:32:15: error: lvalue required as unary '&' operand 32 | &#160; &#160; &#160; if(!strcmp(command,"BACKWARD")) k*=-1; | ^ main.c:33:2: error: stray '#' in program 33 | &#160; &#160; &#160; if(now.dir%2){ | ^ main.c:33:1: error: lvalue required as unary '&' operand 33 | &#160; &#160; &#160; if(now.dir%2){ | ^ main.c:33:9: error: stray '#' in program 33 | &#160; &#160; &#160; if(now.dir%2){ | ^ main.c:33:8: error: lvalue required as unary '&' operand 33 | &#160; &#160; &#160; if(now.dir%2){ | ^ main.c:33:16: error: stray '#' in program 33 | &#160; &#160; &#160; if(now.dir%2){ | ^ main.c:33:15: error: lvalue required as unary '&' operand 33 | &#160; &#160; &#160; if(now.dir%2){ | ^ main.c:33:28: error: 'struct place' has no member named 'dir' 33 | &#160; &#160; &#160; if(now.dir%2){ | ^ main.c:34:16: error: 'struct place' has no member named 'dir' 34 | k*=(now.dir==3)?-1:1; | ^ main.c:35:12: error: 'struct place' has no member named 'x' 35 | now.x+=k; | ^ main.c:36:15: error: 'struct place' has no member named 'x' 36 | if(now.x<1) now.x=1; | ^ main.c:36:24: error: 'struct place' has no member named 'x' 36 | if(now.x<1) now.x=1; | ^ main.c:37:20: error: 'struct place' has no member named 'x' 37 | else if(now.x>m) now.x=m; | ^ main.c:37:29: error: 'struct place' has no member named 'x' 37 | else if(now.x>m) now.x=m; | ^ main.c:38:2: error: stray '#' in program 38 | &#160; &#160; &#160; }else{ | ^ main.c:38:1: error: lvalue required as unary '&' operand 38 | &#160; &#160; &#160; }else{ | ^ main.c:38:9: error: stray '#' in program 38 | &#160; &#160; &#160; }else{ | ^ main.c:38:8: error: lvalue required as unary '&' operand 38 | &#160; &#160; &#160; }else{ | ^ main.c:38:16: error: stray '#' in program 38 | &#160; &#160; &#160; }else{ | ^ main.c:38:15: error: lvalue required as unary '&' operand 38 | &#160; &#160; &#160; }else{ | ^ main.c:39:16: error: 'struct place' has no member named 'dir' 39 | k*=(now.dir==2)?-1:1; | ^ main.c:40:12: error: 'struct place' has no member named 'y' 40 | now.y+=k; | ^ main.c:41:15: error: 'struct place' has no member named 'y' 41 | if(now.y<1) now.y=1
s400466871
p00686
C++
#include<iostream> #include<cstring> #include<algorithm> #include<cstdlib> #include<vector> #include<cmath> #include<stdlib.h> #include<iomanip> #include<list> #include<deque> #include<map> #include <stdio.h> #include <queue> #include <stack> #define maxn 10000+5 #define ull unsigned long long #define ll long long #define reP(i,n) for(i=1;i<=n;i++) #define rep(i,n) for(i=0;i<n;i++) #define cle(a) memset(a,0,sizeof(a)) #define mod 90001 #define PI 3.141592657 #define INF 1<<30 const ull inf = 1LL << 61; const double eps=1e-5; using namespace std; bool cmp(int a,int b) { return a>b; } int flag; int x,y,n,m; int getbool(int i){ if(i==1){ return (flag+1)%4; } else { flag--; if(flag==-1){ return 3; return flag; } } void getval(int num) { if(flag==0){ y+=num; } if(flag==1){ x+=num; } if(flag==2){ y-=num; } if(flag==3){ x-=num; } if(y>n)y=n; if(y<=0)y=1; if(x<=0)x=1; if(x>m)x=m; } int main() { #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin); #endif while(cin>>m>>n){ if((n+m)==0)break; flag=0; x=y=1; string s; while(cin>>s){ if(s[0]=='S')break; else if(s[0]=='R'){ flag=getbool(1); } else if(s[0]=='L')flag=getbool(2); else { int len; cin>>len; if(s[0]=='F') getval(len); else getval(-len); } } cout<<x<<" "<<y<<endl; } return 0; }
a.cc: In function 'int getbool(int)': a.cc:48:1: error: a function-definition is not allowed here before '{' token 48 | { | ^ a.cc:66:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 66 | int main() | ^~ a.cc:66:9: note: remove parentheses to default-initialize a variable 66 | int main() | ^~ | -- a.cc:66:9: note: or replace parentheses with braces to value-initialize a variable a.cc:67:1: error: a function-definition is not allowed here before '{' token 67 | { | ^ a.cc:94:2: error: expected '}' at end of input 94 | } | ^ a.cc:35:19: note: to match this '{' 35 | int getbool(int i){ | ^ a.cc:94:2: warning: control reaches end of non-void function [-Wreturn-type] 94 | } | ^
s304471525
p00686
C++
#include<iostream> #include<math.h> #include<iomanip> #include<String> using namespace std; int main(){ int n,m,x,y,num; int di=0; string order; while(1){ cin>>n>>m; x=1;y=1; if(n==0 && m==0)break; while(1){ cin>>order; if(order=="FORWARD"){ cin>>num; if(di==0){ y=min(y+num,m); }else if(di==1){ x=min(x+num,n); }else if(di==2){ y=max(y-num,1); }else if(di==3){ x=max(x-num,1); } }else if(order=="BACKWARD"){ cin>>num; if(di==2){ y=min(y+num,m); }else if(di==3){ x=min(x+num,n); }else if(di==0){ y=max(y-num,1); }else if(di==1){ x=max(x-num,1); } }else if(order=="RIGHT"){ di=(di+1)%4; }else if(order=="LEFT"){ di=(di-1)%4; }else if(order=="STOP"){ cout << x <<" "<<y<<endl; break; }else{ cout << "ERROR "<<order<<endl; return 0; } } } }
a.cc:4:9: fatal error: String: No such file or directory 4 | #include<String> | ^~~~~~~~ compilation terminated.
s131794166
p00686
C++
#include<algorithm> #include<cstring> #include<map> #include<set> #define rep(i,n) for(int i=0;i<n;i++) #define INF 1<<29 using namespace std; int main(){ int mv[4][3]= {{0,1,1}, //forward {-1,0,0},//left {0,-1,0},//backward {1,0,0}};//right int n,m,num,x,y; string op; while(true){ cin >> n >> m; if(n == 0 && m == 0)break; x=1;y=1; while(true){ cin >> op; if(op == "STOP")break; else if(op == "LEFT") { for(int i=0;i<4;i++) { if(mv[i][2] == 1) { if(i != 3){ mv[i][2]=0; mv[i+1][2]=1; } else if(i == 3) { mv[0][2]=1; mv[3][2]=0; } else cout << "********arienai********" << endl; break; } } } else if(op == "RIGHT") {// for(int i=0;i<4;i++) { if(mv[i][2] == 1) { if(i == 0) { mv[0][2]=0; mv[3][2]=1; } else { mv[i][2]=0; mv[i-1][2]=1; } break; } } }// else if(op == "FORWARD") { cin >> num; for(int i=0;i<4;i++) { if(mv[i][2] == 1) { if(i == 0) { if(y+num > m) { // y=m; } else { y+=num; } //break; } else if(i == 1) { if(x-num < 0) { // x=1; } else { x-=num; } //break; } else if(i == 2) { if(y-num < 0) { //y=1; } else { y-=num; } //break; } else if(i == 3) { //cout << "x = " << x << ", num = " << num << endl; if(x+num > n) { //x=n; } else { x+=num; } //break; } break; } } } else if(op == "BACKWARD") { cin >> num; for(int i=0;i<4;i++) { if(mv[i][2] == 1) { if(i == 0) { if(y-num < 0) { //y=1; } else { y-=num; } //break; } else if(i == 1) { if(x+num > n) { //x=n; } else { x+=num; } //break; } else if(i == 2) { if(y+num > m) { //y=m; } else { y+=num; } //break; } else if(i == 3) { if(x-num < 0) { //x=1; } else { x-=num; } //break; } break; } } } //for(int i=0;i<4;i++)if(mv[i][2] == 1)cout << "i= " << i << endl; // cout << "op = " << op << ",num = " << num << ", " << x << " " << y << endl; } cout << x << " " << y << endl; } }
a.cc: In function 'int main()': a.cc:16:3: error: 'string' was not declared in this scope 16 | string op; | ^~~~~~ a.cc:5:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>' 4 | #include<set> +++ |+#include <string> 5 | #define rep(i,n) for(int i=0;i<n;i++) a.cc:19:5: error: 'cin' was not declared in this scope 19 | cin >> n >> m; | ^~~ a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 4 | #include<set> +++ |+#include <iostream> 5 | #define rep(i,n) for(int i=0;i<n;i++) a.cc:24:14: error: 'op' was not declared in this scope 24 | cin >> op; | ^~ a.cc:42:24: error: 'cout' was not declared in this scope 42 | else cout << "********arienai********" << endl; | ^~~~ a.cc:42:24: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:42:61: error: 'endl' was not declared in this scope 42 | else cout << "********arienai********" << endl; | ^~~~ a.cc:5:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 4 | #include<set> +++ |+#include <ostream> 5 | #define rep(i,n) for(int i=0;i<n;i++) a.cc:198:5: error: 'cout' was not declared in this scope 198 | cout << x << " " << y << endl; | ^~~~ a.cc:198:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:198:30: error: 'endl' was not declared in this scope 198 | cout << x << " " << y << endl; | ^~~~ a.cc:198:30: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
s402386936
p00686
C++
#include <iostream> #include <string> using namespace std; int dx[4] = {0, 1, 0, -1}; int dy[4] = {1, 0, -1, 0}; int main(){ int n, m; while(cin >> n >> m, n+m){ int mx = 1, my = 1; int direction = 0; while(1){ string command; int step; cin >> command; if(command == "FORWARD"){ cin >> step; if(mx+dx[direction]*step <= n) mx += dx[direction]*step; else mx = n; if(my+dy[direction]*step <= m) my += dy[direction]*step; else my = m; } else if(command == "BACKWARD"){ cin >> step; if(0 <= mx-dx[direction]*step) mx -= dx[direction]*step; else mx = 0; if(0 <= my-dy[direction]*step) my -= dy[direction]*step; else my = 0; } else if(command == "RIGHT")direction = (direction+1)%4; else if(command == "LEFT"){ direction--; if(direction == -1) direction = 3; } else if(command == "STOP"
a.cc: In function 'int main()': a.cc:35:38: error: expected ')' at end of input 35 | else if(command == "STOP" | ~ ^ | ) a.cc:35:38: error: expected statement at end of input a.cc:35:38: error: expected '}' at end of input a.cc:12:17: note: to match this '{' 12 | while(1){ | ^ a.cc:35:38: error: expected '}' at end of input 35 | else if(command == "STOP" | ^ a.cc:9:30: note: to match this '{' 9 | while(cin >> n >> m, n+m){ | ^ a.cc:35:38: error: expected '}' at end of input 35 | else if(command == "STOP" | ^ a.cc:7:11: note: to match this '{' 7 | int main(){ | ^
s240137546
p00686
C++
#include<iostream> #include<vector> #include<algorithm> #define loop(i,a,b) for(int i=a;i<b;i++) #define rep(i,a) loop(i,0,a) #define all(in) in.begin(),in.end() #define pb(in,a) in.push_back(a) using namespace std; int a[4]={0,1,0,-1}; int b[4]={1,0,-1,0}; int main(){ int n,m; while(cin>>n>>m,n||m){ int to=0; string s; int x=1,y=1; while(1){ if(s=="FORWARD"){ int tmp; cin>>tmp; x+=tmp*a[to]; y+=tmp*b[to]; }else{ int tmp; cin>>tmp; x-=tmp*a[to]; y-=tmp*b[to]; }else if(s=="STOP")break; else if(s=="LEFT")to--; else to++; if(to>3)to=0; else if(to<0)to=3; if(x>n)x=n; else if(x<1)x=1; if(y>m)y=m; else if(y<1)y=1; } cout<<x<<" "<<y<<endl; } }
a.cc: In function 'int main()': a.cc:28:8: error: 'else' without a previous 'if' 28 | }else if(s=="STOP")break; | ^~~~
s963721834
p00687
C
/* */ #include<stdio.h> int Main(); int main(int argc, char *argv[]){ while( Main() == 0 ); return 0; } int Main(){ int n = 0, a = 0, b = 0, count = 0, i = 0, j = 0; //?????????????????\????????????a??¨b???????????§?????????????????°??? if( scanf("%d %d %d", &n, &a, &b) != 3 ){ return -1; } char list[n+1]; //????????§????????????????????????????????????0????????????????????????1??? for( i = 0; i < n+1; i++ ){ list[i] = 1; } for( i = 0; a * i <= n; i++ ){ for( j = 0; a * i + b * j <= n; j++ ){ list[a*i+b*j] = 0; } } for( i = 1; i <= n; i++ ){ count += (int)list[i]; printf("%d\n", count); return 0; }
main.c: In function 'Main': main.c:27:1: error: expected declaration or statement at end of input 27 | } | ^
s589515638
p00687
C
/* */ #include<stdio.h> int Main(); int main(int argc, char *argv[]){ while( Main() == 0 ); return 0; } int Main(){ int n = 0, a = 0, b = 0, count = 0, i = 0, j = 0; //?????????????????\????????????a??¨b???????????§?????????????????°??? if( scanf("%d %d %d", &n, &a, &b) != 3 ){ return -1; } char list[n+1]; //????????§????????????????????????????????????0????????????????????????1??? for( i = 0; i < n+1; i++ ){ list[i] = 1; } for( i = 0; a * i <= n; i++ ){ for( j = 0; a * i + b * j <= n; j++ ){ list[a*i+b*j] = 0; } } for( i = 1; i <= n; i++ ){ count += (int)list[i]; printf("%d\n", count); return 0; }
main.c: In function 'Main': main.c:27:1: error: expected declaration or statement at end of input 27 | } | ^
s899961245
p00687
C
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<cassert> #include<iostream> #include<sstream> #include<string> #include<vector> #include<queue> #include<set> #include<map> #include<utility> #include<numeric> #include<algorithm> #include<bitset> #include<complex> #include<stack> using namespace std; typedef long long Int; typedef vector<int> vint; typedef pair<int,int> pint; typedef vector<string> vstring; typedef vector<pint> vpint; typedef stringstream SS; template<class T> void chmin(T &t, T f) { if (t > f) t = f; } template<class T> void chmax(T &t, T f) { if (t < f) t = f; } #define rep(i,n) for(int i=0;i<(n);++i) #define repn(i,m,n) for(int i=(m);i<(n);++i) #define repd(i,n) for(int i=(n)-1;i>=0;--i) #define repnd(i,m,n) for(int i=(n)-1;i>=(m);--i) #define rep0(i,n) for(i=0;i<(n);++i) #define repn0(i,m,n) for(i=(m);i<(n);++i) #define repd0(i,n) for(i=(n)-1;i>=0;--i) #define repnd0(i,m,n) for(i=(n)-1;i>=(m);--i) #define repc(i,n) for(int i=0;i<=(n);++i) #define repcn(i,m,n) for(int i=(m);i<=(n);++i) #define repcd(i,n) for(int i=(n);i>=0;--i) #define repcnd(i,m,n) for(int i=(n);i>=(m);--i) #define repc0(i,n) for(i=0;i<=(n);++i) #define repcn0(i,m,n) for(i=(m);i<=(n);++i) #define repcd0(i,n) for(i=(n);i>=0;--i) #define repcnd0(i,m,n) for(i=(n);i>=(m);--i) #define all(n) n.begin(),n.end() #define sz(n) ((int)(n).size()) #define IL for(;;) #define MP make_pair #define PB push_back #define X second #define Y first #define p_queue(n) priority_queue<n,vector<n>,greater<n> > #define PUTLINE cout<<"LINE:"<<__LINE__<<endl; const int INF = 2147483647/3; const double EPS = 1e-10; const double PI = acos(-1.0); const int dx[]={1,-1,0,0,1,1,-1,-1,0}; const int dy[]={0,0,1,-1,1,-1,1,-1,0}; int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a%b); } int main() { int n, a, b, g, res; IL { cin >> n >> a >> b; if (n == 0 && a == 0 && b == 0) break; if (a > b) swap(a, b); g = gcd(a, b); res = 0; if (g > 1) { res += n - n / g; n /= g; a /= g; b /= g; } repn (i, 1, a) { rep (j, a) { if (b * j % a == i) { res += b * j / a; break; } } } cout << res << endl; } return 0; }
main.c:1:9: fatal error: cstdio: No such file or directory 1 | #include<cstdio> | ^~~~~~~~ compilation terminated.
s076275394
p00687
C++
#include<iostream> #include<string> #define r(i,n) for(int i=0;i<n;i++) using namespace std; int n,a,b; bool used[1000004]; int main(){ while(cin>>n>>a>>b,n){ int sum=0; memset(used,0,sizeof(used)); for(int i=a;i<=n;i+=a)used[i]=1; for(int j=b;j<=n;j+=b)used[j]=1; r(i,n+1)if(used[i]&&i+a<=n)used[i+a]=1; r(i,n+1)if(used[i]&&i+b<=n)used[i+b]=1; r(i,n)if(!used[i+1])sum++; cout<<sum<<endl; } }
a.cc: In function 'int main()': a.cc:10:5: error: 'memset' was not declared in this scope 10 | memset(used,0,sizeof(used)); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include<iostream> +++ |+#include <cstring> 2 | #include<string>
s110371419
p00687
C++
include<iostream> using namespace std; typedef long long int lli; lli gcd(lli a, lli b){ if(a%b==0)return b; return gcd(b,a%b); } lli lcm(lli a, lli b){ if(a<b)swap(a,b); lli g=gcd(a,b); return b*(a/g); } int main(){ while(true){ int ableCount = 0; int n,a,b; cin >> n >> a >> b; if(n==0&&a==0&&b==0)break; for(int k = 1; k <= n; k++){ bool cond1 = ((k%a)%b)==0; bool cond2 = ((k%b)%a)==0; //if(cond1&&cond2)continue; if(cond1||cond2)++ableCount; } cout <<n-(n%lcm(a,b)==0?0:1)-ableCount << endl; } return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | include<iostream> | ^~~~~~~ a.cc: In function 'lli lcm(lli, lli)': a.cc:13:10: error: 'swap' was not declared in this scope 13 | if(a<b)swap(a,b); | ^~~~ a.cc: In function 'int main()': a.cc:22:5: error: 'cin' was not declared in this scope 22 | cin >> n >> a >> b; | ^~~ a.cc:30:5: error: 'cout' was not declared in this scope 30 | cout <<n-(n%lcm(a,b)==0?0:1)-ableCount << endl; | ^~~~ a.cc:30:47: error: 'endl' was not declared in this scope 30 | cout <<n-(n%lcm(a,b)==0?0:1)-ableCount << endl; | ^~~~
s796877058
p00687
C++
#include<iostream> int n,a,b,i,j,f[1000001];main(){ for(;std::cin>>n>>a>>b,n|a|b;printf("%d\n",j)){for(i=0;i<n;i++)f[i]=1;for(i=0;i<=n;i+=a)if(f[i])for(j=i;j<=n;j+=b)f[j]=0;j=0;for(i=1;i<=n;)f[i++]&&j++;}
a.cc:2:26: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 2 | int n,a,b,i,j,f[1000001];main(){ for(;std::cin>>n>>a>>b,n|a|b;printf("%d\n",j)){for(i=0;i<n;i++)f[i]=1;for(i=0;i<=n;i+=a)if(f[i])for(j=i;j<=n;j+=b)f[j]=0;j=0;for(i=1;i<=n;)f[i++]&&j++;} | ^~~~ a.cc: In function 'int main()': a.cc:2:186: error: expected '}' at end of input 2 | int n,a,b,i,j,f[1000001];main(){ for(;std::cin>>n>>a>>b,n|a|b;printf("%d\n",j)){for(i=0;i<n;i++)f[i]=1;for(i=0;i<=n;i+=a)if(f[i])for(j=i;j<=n;j+=b)f[j]=0;j=0;for(i=1;i<=n;)f[i++]&&j++;} | ~ ^
s121038704
p00687
C++
I would, if I could,
a.cc:1:5: error: 'I' does not name a type 1 | I would, if I could, | ^
s735812911
p00687
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main(void){ int n,a,b; while(cin >> n >> a >> b,n|a|b){ vector<int>cnt(n+1); fill(cnt,cnt+n+1,1); for(int i=0;i<=n;i++){ for(int j=0;min(a*i+b*j,j*j)<=n;j++){ cnt[a*i+b*j]=0; } } int ans=0; for(int i=0;i<=n;i++)ans+=cnt[i]; cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:12:29: error: no match for 'operator+' (operand types are 'std::vector<int>' and 'int') 12 | fill(cnt,cnt+n+1,1); | ~~~^~ | | | | | int | std::vector<int> In file included from /usr/include/c++/14/string:48, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)' 627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed: a.cc:12:30: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 12 | fill(cnt,cnt+n+1,1); | ^ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)' 1798 | operator+(typename move_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed: a.cc:12:30: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 12 | fill(cnt,cnt+n+1,1); | ^ In file included from /usr/include/c++/14/string:54: /usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed: a.cc:12:30: note: 'std::vector<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 12 | fill(cnt,cnt+n+1,1); | ^ /usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3616 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed: a.cc:12:30: note: mismatched types 'const _CharT*' and 'std::vector<int>' 12 | fill(cnt,cnt+n+1,1); | ^ /usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed: a.cc:12:30: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int' 12 | fill(cnt,cnt+n+1,1); | ^ /usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed: a.cc:12:30: note: 'std::vector<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 12 | fill(cnt,cnt+n+1,1); | ^ /usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)' 3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed: a.cc:12:30: note: 'std::vector<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 12 | fill(cnt,cnt+n+1,1); | ^ /usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed: a.cc:12:30: note: 'std::vector<int>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 12 | fill(cnt,cnt+n+1,1); | ^ /usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed: a.cc:12:30: note: 'std::vector<int>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 12 | fill(cnt,cnt+n+1,1); | ^ /usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3696 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3696:5: note: template argument deduction/substitution failed: a.cc:12:30: note: 'std::vector<int>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 12 | fill(cnt,cnt+n+1,1); | ^ /usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3719 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3719:5: note: template argument deduction/substitution failed: a.cc:12:30: note: mismatched types 'const _CharT*' and 'std::vector<int>' 12 | fill(cnt,cnt+n+1,1); | ^ /usr/include/c++/14/bits/basic_string.h:3726:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3726 | operator+(_CharT __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3726:5: note: template argument deduction/substitution failed: a.cc:12:30: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int' 12 | fill(cnt,cnt+n+1,1); | ^ /usr/include/c++/14/bits/basic_string.h:3733:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const _CharT*)' 3733 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3733:5: note: template argument deduction/substitution failed: a.cc:12:30: note: 'std::vector<int>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 12 | fill(cnt,cnt+n+1,1); | ^ /usr/include/c++/14/bits/basic_string.h:3740:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, _CharT)' 3740 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3740:5: note: template argument deduction/substitution failed: a.cc:12:30: note: 'std::vector<int>' is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 12 | fill(cnt,cnt+n+1,1); | ^
s216904611
p00688
C++
from fractions import gcd while True: a, b, c = map(int, input().split()) if not a: break d = (b ** 2 - 4 * a * c) ** 0.5 if isinstance(d, complex) or d - int(d) > 1e-6: print('Impossible') continue num1, num2 = -b + int(d), -b - int(d) den = 2 * a cmn1, cmn2 = gcd(num1, den), gcd(num2, den) print(den // cmn1, -num1 // cmn1, den // cmn2, -num2 // cmn2)
a.cc:9:15: warning: multi-character literal with 10 characters exceeds 'int' size of 4 bytes 9 | print('Impossible') | ^~~~~~~~~~~~ a.cc:1:1: error: 'from' does not name a type 1 | from fractions import gcd | ^~~~
s403651549
p00688
C++
#include<bits/stdc++.h> using namespace std; int main(){ long long a,b,c; while(cin>>a>>b>>c,a){ if(c==0){ if(a==1&&b<0)cout<<a<<' '<<0<<' '<<1<<' '<<b<<endl; else cout<<a<<' '<<b<<' '<<1<<' '<<0<<endl; } else{for(int j=1;j<=a;j++){ if(a%j==0){ if(a/j>=j) for(int i=10000;i>=-10000;i--){ long long t,p=0; if(i*j+a/j*p==b&&p*i==c){ cout<<a/j<<' '<<i<<' '<<j<<' '<<p<<endl; goto L; } if(i!=0){ if(c%abs(i)==0)t=c/i; else continue; } else continue; if(i*j+a/j*t==b&&t*i==c){ if(j*j==a&&i<t)?????? cout<<a/j<<' '<<t<<' '<<j<<' '<<i<<endl; else cout<<a/j<<' '<<i<<' '<<j<<' '<<t<<endl; goto L; } } else break; } } cout<<"Impossible"<<endl;L:; } } }
a.cc: In function 'int main()': a.cc:25:30: error: expected primary-expression before '?' token 25 | if(j*j==a&&i<t)?????? cout<<a/j<<' '<<t<<' '<<j<<' '<<i<<endl; | ^ a.cc:25:31: error: expected primary-expression before '?' token 25 | if(j*j==a&&i<t)?????? cout<<a/j<<' '<<t<<' '<<j<<' '<<i<<endl; | ^ a.cc:25:32: error: expected primary-expression before '?' token 25 | if(j*j==a&&i<t)?????? cout<<a/j<<' '<<t<<' '<<j<<' '<<i<<endl; | ^ a.cc:25:33: error: expected primary-expression before '?' token 25 | if(j*j==a&&i<t)?????? cout<<a/j<<' '<<t<<' '<<j<<' '<<i<<endl; | ^ a.cc:25:34: error: expected primary-expression before '?' token 25 | if(j*j==a&&i<t)?????? cout<<a/j<<' '<<t<<' '<<j<<' '<<i<<endl; | ^ a.cc:25:35: error: expected primary-expression before '?' token 25 | if(j*j==a&&i<t)?????? cout<<a/j<<' '<<t<<' '<<j<<' '<<i<<endl; | ^ a.cc:25:76: error: expected ':' before ';' token 25 | if(j*j==a&&i<t)?????? cout<<a/j<<' '<<t<<' '<<j<<' '<<i<<endl; | ^ | : a.cc:25:76: error: expected primary-expression before ';' token a.cc:25:76: error: expected ':' before ';' token 25 | if(j*j==a&&i<t)?????? cout<<a/j<<' '<<t<<' '<<j<<' '<<i<<endl; | ^ | : a.cc:25:76: error: expected primary-expression before ';' token a.cc:25:76: error: expected ':' before ';' token 25 | if(j*j==a&&i<t)?????? cout<<a/j<<' '<<t<<' '<<j<<' '<<i<<endl; | ^ | : a.cc:25:76: error: expected primary-expression before ';' token a.cc:25:76: error: expected ':' before ';' token 25 | if(j*j==a&&i<t)?????? cout<<a/j<<' '<<t<<' '<<j<<' '<<i<<endl; | ^ | : a.cc:25:76: error: expected primary-expression before ';' token a.cc:25:76: error: expected ':' before ';' token 25 | if(j*j==a&&i<t)?????? cout<<a/j<<' '<<t<<' '<<j<<' '<<i<<endl; | ^ | : a.cc:25:76: error: expected primary-expression before ';' token a.cc:25:76: error: expected ':' before ';' token 25 | if(j*j==a&&i<t)?????? cout<<a/j<<' '<<t<<' '<<j<<' '<<i<<endl; | ^ | : a.cc:25:76: error: expected primary-expression before ';' token
s608794039
p00688
C++
#include<bits/stdc++.h> using namespace std; int main(){ long long a,b,c; while(cin>>a>>b>>c,a){ if(c==0){ if(a==1&&b<0)cout<<a<<' '<<0<<' '<<1<<' '<<b<<endl; else cout<<a<<' '<<b<<' '<<1<<' '<<0<<endl; } else{for(int j=1;j<=a;j++){ if(a%j==0){ if(a/j>=j) for(int i=10000;i>=-10000;i--){ long long t,p=0; if(i*j+a/j*p==b&&p*i==c){ cout<<a/j<<' '<<i<<' '<<j<<' '<<p<<endl; goto L; } if(i!=0){ if(c%abs(i)==0)t=c/i; else continue; } else continue; if(i*j+a/j*t==b&&t*i==c){ if(j*j==a&&i<t)cout<<a/j<<' '<<t<<' '<<j<<' '<<i<<endl; else cout<<a/j<<' '<<i<<' '<<j<<' '<<t<<endl; goto L; } } else break; } } cout<<"Impossible"<<endl;L:; } }
a.cc: In function 'int main()': a.cc:35:4: error: expected '}' at end of input 35 | } | ^ a.cc:3:11: note: to match this '{' 3 | int main(){ | ^
s948906393
p00688
C++
<iostream> #include <math.h> #include <stdlib.h> using namespace std; typedef long long int lli; lli a, b, c; lli p, q, r, s; bool solve() { if(a == 0) return false; if(c == 0) { if(a != 1) { p = a; q = b; r = 1; s = 0; return true; } else { p = 1; q = max(b, (lli)0); r = 1; s = min(b, (lli)0); return true; } } for(lli i=1; i<=a; i++) { if(i * i > a) break; if(a%i==0) { p = a / i; r = i; for(lli j=1; j<=abs(c); j++) { if(c%j==0) { lli qt = c / j; lli st = j; if(p * st + r * qt == b) { q = qt; s = st; if(p == r) q = max(qt, st), s = min(qt, st); return true; } else if(p * qt + r * st == b) { q = st; s = qt; if(p == r) q = max(qt, st), s = min(qt, st); return true; } else if(- p * st - r * qt == b) { q = -qt; s = -st; if(p == r) q = max(-qt, -st), s = min(-qt, -st); return true; } else if(- p * qt - r * st == b) { q = -st; s = -qt; if(p == r) q = max(-qt, -st), s = min(-qt, -st); return true; } } } } } return false; } int main() { while( 1 ) { cin >> a >> b >> c; if(a==0 && b==0 && c==0) break; if(solve()) printf("%lld %lld %lld %lld\n", p, q, r, s); else printf("Impossible\n"); } }
a.cc:2:2: error: expected unqualified-id before '<' token 2 | <iostream> | ^ In file included from /usr/include/c++/14/cmath:45, from /usr/include/c++/14/math.h:36, from a.cc:3: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/bits/specfun.h:43, from /usr/include/c++/14/cmath:3906: /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ In file included from /usr/include/stdlib.h:32, from /usr/include/c++/14/bits/std_abs.h:38, from /usr/include/c++/14/cmath:49: /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'? 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here 214 | typedef __SIZE_TYPE__ size_t; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared 2086 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope 2087 | struct remove_extent<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid 2087 | struct remove_extent<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared 2099 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope 2100 | struct remove_all_extents<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid 2100 | struct remove_all_extents<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared 2171 | template<std::size_t _Len> | ^~~ /usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope 2176 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared 2194 | template<std::size_t _Len, std::size_t _Align = | ^~~ /usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^~~~ /usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid 2195 | __alignof__(typename __aligned_storage_msa<_Len>::__type)> | ^ /usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope 2202 | unsigned char __data[_Len]; | ^~~~ /usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope 2203 | struct __attribute__((__aligned__((_Align)))) { } __align; | ^~~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:65: /usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type 125 | template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t, | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' +++ |+#include <cstddef> 1 | // Types used in iterator implementation -*- C++ -*- /usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: error: 'ptrdiff_t' does not name a type 214 | typedef ptrdiff_t difference_type; | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: error: 'ptrdiff_t' does not name a type 225 | typedef ptrdiff_t difference_type; | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' In file included from /usr/include/c++/14/bits/stl_algobase.h:66: /usr/include/c++/14/bits/stl_iterator_base_funcs.h:112:5: error: 'ptrdiff_t' does not name a type 112 | ptrdiff_t | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 65 | #include <debug/assertions.h> +++ |+#include <cstddef> 66 | #include <bits/stl_iterator_base_types.h> /usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: error: 'ptrdiff_t' does not name a type 118 | ptrdiff_t | ^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' In file included from /usr/include/c++/14/bits/stl_iterator.h:67, from /usr/include/c++
s345421908
p00688
C++
#include <vector> #include <map> #include <set> #include <stack> #include <queue> #include <algorithm> #include <utility> #include <functional> #include <sstream> #include <iostream> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <ctime> #include <climits> #include <fstream> using namespace std; inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;} template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();} typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef pair<int, int> pii; typedef long long ll; #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define FOR(i,a,b) for(int i=(a);i<=(b);++i) #define REP(i,n) FOR(i,0,(n)-1) const double EPS = 1e-12; const double PI = acos(-1.0); const int INF = INT_MAX/10; bool ok(int p, int q, int r, int s) { return (p>r || (p==r && q>=s)); } int main() { int a, b, c; while(cin >> a >> b >> c, a) { FOR(p, 1, a) { int r = a/p; if(p*r != a) continue; if(c != 0) { int st = min(-c, c), en = max(-c, c); FOR(q, st, en) { if(q == 0) continue; int s = c/q; if(q*s != c) continue;
a.cc: In function 'int main()': a.cc:54:58: error: expected '}' at end of input 54 | continue; | ^ a.cc:49:48: note: to match this '{' 49 | FOR(q, st, en) { | ^ a.cc:54:58: error: expected '}' at end of input 54 | continue; | ^ a.cc:47:36: note: to match this '{' 47 | if(c != 0) { | ^ a.cc:54:58: error: expected '}' at end of input 54 | continue; | ^ a.cc:43:30: note: to match this '{' 43 | FOR(p, 1, a) { | ^ a.cc:54:58: error: expected '}' at end of input 54 | continue; | ^ a.cc:42:38: note: to match this '{' 42 | while(cin >> a >> b >> c, a) { | ^ a.cc:54:58: error: expected '}' at end of input 54 | continue; | ^ a.cc:40:12: note: to match this '{' 40 | int main() { | ^
s091706918
p00689
C++
#include <iostream> #include <iomanip> #include <cmath> using namespace std; const double PI = 3.14159265; bool eq(double a, double b){ return fabs(a-b) < 1e-7; } double angle(double cur, double next){ double r = cur - next + 2*PI; while( r >= 2*PI ) r -= 2*PI; return r; } double dist(double x1, double y1, double x2, double y2){ return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2); } int main(){ int n; double x[400], y[400]; while( cin >> n && n ){ for(int i = 0; i < n; i++){ cin >> x[i] >> y[i]; } double cx = 0, cy = 0, cang = atan2(0,-1); double lv, ld, sum = 0.0; int ln; for(int i = 0; i < n; i++){ lv = 100; ld = 1000; for(int j = 0; j < n; j++){ if( x[j] < 0 ) continue; double ang = angle( cang, atan2(y[j]-cy, x[j]-cx) ); if( ang < lv || ( eq(ang, lv) && dist(cx, cy, x[j], y[j]) < ld ) ){ lv = ang; ln = j; ld = dist(cx, cy, x[j], y[j]); } } sum += ld; cang = atan2(y[ln]-cy, x[ln]-cx); cx = x[ln]; cy = y[ln]; x[ln] = -1; } cout << fixed << setprecision(1) << (int)(sum*10+0.5)/10.0 << endl; } return 0; }
a.cc: In function 'double dist(double, double, double, double)': a.cc:19:51: error: expected ')' before ';' token 19 | return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2); | ~ ^ | )
s310351458
p00689
C++
#include <iostream> #include <vector> #include <complex> #include <iterator> #include <iomanip> using namespace std; int main() { int n; while (cin>>n) { vector<complex<float>> vs; complex<float> next_point, last_vector; float min = 10.0f; for (int i = 0; i < n; i++) { int x, y; cin >> x >> y; vs.push_back(complex<float>(y, x)); if (arg(complex<float>(y,x)) < min) {next_point = complex<float>(y, x); min = arg(next_point);} } cout<<next_point<<endl; float length = abs(next_point); auto last_point = last_vector = next_point; vs.erase(find(begin(vs), end(vs), next_point)); for (int i = 1; i < n; i++) { next_point = complex<float>(500,0); auto _it = begin(vs); float max = -abs(last_vector); for (auto it = begin(vs); it != end(vs); it++) { float temp = ((*it - last_point) * conj(last_vector)).real() / abs(*it - last_point); if (temp > max) {max = temp; _it = it;} } next_point = *_it; cout<<next_point<<endl; vs.erase(_it); last_vector = next_point - last_point; length += abs(last_vector); last_point = next_point; } cout<<fixed<<setprecision(1)<<length<<endl; } }
a.cc: In function 'int main()': a.cc:24:22: error: no matching function for call to 'find(std::vector<std::complex<float> >::iterator, std::vector<std::complex<float> >::iterator, std::complex<float>&)' 24 | vs.erase(find(begin(vs), end(vs), next_point)); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/bits/locale_facets.h:48, from /usr/include/c++/14/bits/basic_ios.h:37, from /usr/include/c++/14/ios:46, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: candidate: 'template<class _CharT2> typename __gnu_cxx::__enable_if<std::__is_char<_CharT2>::__value, std::istreambuf_iterator<_CharT> >::__type std::find(istreambuf_iterator<_CharT>, istreambuf_iterator<_CharT>, const _CharT2&)' 435 | find(istreambuf_iterator<_CharT> __first, | ^~~~ /usr/include/c++/14/bits/streambuf_iterator.h:435:5: note: template argument deduction/substitution failed: a.cc:24:22: note: '__gnu_cxx::__normal_iterator<std::complex<float>*, std::vector<std::complex<float> > >' is not derived from 'std::istreambuf_iterator<_CharT>' 24 | vs.erase(find(begin(vs), end(vs), next_point)); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
s453408956
p00689
C++
#include<iostream> #include<vector> #include<cstring> #include<cmath> #include<cstdlib> #include<cstdio> #define X first #define Y second using namespace std; const int MAX = 450; const double EPS = 1e-9; typedef pair<int,int> P; vector<P> V; bool come[MAX]; double dot(P a, P b){ return a.X*b.X+a.Y*b.Y; } double cross(P a, P b){ return a.X*b.Y-a.Y*b.X; } double getLength(P pre, P nex){ return sqrt((pre.X-nex.X)*(pre.X-nex.X)+(pre.Y-nex.Y)*(pre.Y-nex.Y)); } double getAngle(P pre, P nex){ return acos(dot(pre,nex)/(getLength(pre,P(0,0))*getLength(nex,P(0,0)))); } bool ccw(P p0, P p1, P p2){ P a = P(p1.first-p0.first,p1.second-p0.second); P b = P(p2.first-p0.first,p2.second-p0.second); return (cross(a,b) > EPS); } P Pminus(P a, P b){ a.first -= b.first; a.second -= b.second; return a; } void solve(){ sort(V.begin(),V.end()); double ans = getLength(P(0,0),V[0]); P pre = P(0,0); P now = V[0]; int roop = V.size()-1; while(roop--){ int nex = -1; double nexTheta; for(int i = 1; i < V.size(); i++){ if(come[i]) continue; // if(ccw(pre,now,V[i])) continue; if(nex == -1){ nex = i; nexTheta = getAngle(Pminus(V[i],now),Pminus(now,pre)); continue; } double theta = getAngle(Pminus(now,pre),Pminus(V[i],now)); if(fabs(nexTheta-theta) > EPS && nexTheta > theta){ nex = i; nexTheta = theta; } if(fabs(nexTheta-theta) < EPS && getLength(now,V[nex]) > getLength(now,V[i])){ nex = i; nexTheta = theta; } } //cout << nex << endl; // cout <<nex << " " << V[nex].X << " " << V[nex].Y << endl; come[nex] = true; ans += getLength(now,V[nex]); pre = now; now = V[nex]; } printf("%.1f\n",ans); } int main(){ int n; while(cin >> n && n){ memset(come,false,sizeof(come)); V.resize(n); for(int i = 0; i < n; i++) cin >> V[i].X >> V[i].Y; solve(); } return 0; }
a.cc: In function 'void solve()': a.cc:53:3: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 53 | sort(V.begin(),V.end()); | ^~~~ | sqrt
s433369436
p00689
C++
#include <iostream> #include <cfloat> #include <cmath> #include <vector> #include <algorithm> using namespace std; #define EPS (1e-10) #define equals(a,b) (fabs((a)-(b)) < EPS) #define dle(a,b) (equals(a, b) || a < b) static const double PI = acos(-1); class Point { public: double x, y; Point (double x = 0, double y = 0): x(x), y(y){} Point operator + ( Point p ){ return Point(x + p.x, y + p.y); } Point operator - ( Point p ){ return Point(x - p.x, y - p.y); } Point operator * ( double a ){ return Point(x*a, y*a); } double abs() { return sqrt(norm()); } double norm() { return x*x+y*y; } bool operator < ( const Point &p ) const { return x != p.x ? x < p.x : y < p.y; } bool operator == ( const Point &p ) const { return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS; } }; typedef Point Vector; class Segment { public: Point p1, p2; Segment(Point s = Point(), Point t = Point()): p1(s), p2(t) {} }; double norm( Vector a ) { return a.x*a.x + a.y*a.y; } double abs( Vector a ) { return sqrt(norm(a)); } double getDistance( Vector a, Vector b ) { return a.x*b.x + a.y*b.y; } double dot( Vector a, Vector b ) { return a.x*b.x + a.y*b.y; } double cross( Vector a, Vector b ) { return a.x*b.y - a.y*b.x; } static const int COUNTER_CLOCKWISE = 1; static const int CLOCKWISE = -1; static const int ONLINE_BACK = 2; static const int ONLINE_FRONT = -2; static const int ON_SEGMENT = 0; int ccw( Point p0, Point p1, Point p2 ) { Vector a = p1 - p0; Vector b = p2 - p0; if( cross(a, b) > EPS ) return COUNTER_CLOCKWISE; if( cross(a, b) < -EPS ) return CLOCKWISE; if( dot(a, b) < -EPS ) return ONLINE_BACK; if( norm(a) < norm(b) ) return ONLINE_FRONT; return ON_SEGMENT; } int main() { Point p[401]; int n; while(cin >> n, n){ for(int i = 0; i < n; i++) { cin >> p[i].x >> p[i].y; } bool flag=true; int i, j, k; for(i = 0; i < n; i++) { flag = true; for(j = 0; j < n; j++) { if(i == j) continue; for(k = 0; k < n; k++) { if(i == k || j == k) continue; if(ccw(p[i],p[j],p[k]) == COUNTER_CLOCKWISE || ccw(p[i],p[j],p[k]) == ONLINE_BACK) swap(p[j],p[k]) } if(flag) break; } if (flag) break; } double d = 0; for(int m = 1; m < n; m++) { d += getDistance(p[m-1],p[m]); } cout << d << endl; } return 0; }
a.cc: In function 'int main()': a.cc:82:109: error: expected ';' before '}' token 82 | if(ccw(p[i],p[j],p[k]) == COUNTER_CLOCKWISE || ccw(p[i],p[j],p[k]) == ONLINE_BACK) swap(p[j],p[k]) | ^ | ; 83 | } | ~
s073652471
p00690
Java
import java.util.Scanner; public class AOJ_1108{ int ans_dict,num_of_stations,num_of_routes; int[][] node; boolean[][] visited; String ans_routes; void run(){ Scanner sc = new Scanner(System.in); while(true){ num_of_stations = sc.nextInt(); num_of_routes = sc.nextInt(); if(num_of_stations == 0 && num_of_routes == 0){ break; } node = new int[num_of_stations+1][num_of_stations+1]; for(int i = 0;i < num_of_routes;i++){ int a = sc.nextInt(); int b = sc.nextInt(); int len = sc.nextInt(); node[a][b] = len; node[b][a] = len; } ans_routes = ""; /* for(int i = 0;i < num_of_stations;i++){ for(int ii = 0;ii < num_of_stations;ii++){ System.out.print(node[i][ii] + " "); } System.out.println(); } */ visited = new boolean[num_of_stations+1][num_of_stations+1]; for(int i = 1;i < num_of_stations + 1;i++){ for(int ii = 1;ii < num_of_stations;ii++){ visited[i][ii] = node[i][ii] > 0; } } for(int cur_node = 1;cur_node < num_of_stations + 1;cur_node++){ DFS(cur_node,""+cur_node,0); } System.out.println(ans_dict); System.out.println(ans_routes); } } void DFS(int cur_node,String routes,int total_dist){ //System.out.println(cur_node+" "+routes+" "+total_dist); if(ans_dict == total_dist){ ans_routes = ans_routes.compareTo(routes) < 0 ? ans_routes : routes; } if(ans_dict < total_dist){ ans_routes = routes; ans_dict = total_dist; } for(int next_node = 1;next_node < num_of_stations;next_node++){ if(visited[cur_node][next_node]){ visited[cur_node][next_node] = false; visited[next_node][cur_node] = false; DFS(next_node,routes+" "+next_node,total_dist+node[cur_node][next_node]); visited[cur_node][next_node] = true; visited[next_node][cur_node] = true; } } } public static void main(String[] args){ new AOJ_1108().run(); } }
Main.java:2: error: class AOJ_1108 is public, should be declared in a file named AOJ_1108.java public class AOJ_1108{ ^ 1 error
s319550474
p00690
C++
#include <stdio.h> #include <vector> using namespace std; int RB[11][11],j,N;bool used[11][11];vector<int>a,x; void dfs(int here, int prev, int cost) {used[here][prev]=used[prev][here]=0;x.push_back(here);for (int i=1,k=0;i<=N;i++) if (used[here][i] && RB[here][i]) k++,dfs(i,here,cost+RB[here][i]);if (!k) if (j<cost) j=cost,a=x;x.pop_back();used[here][prev]=used[prev][here]=1;} int main() {int i,k,f;for (i=0;i<11;i++) for (j=0;j<11;used[i][j++]=1);while (1) {a.clear(),x.clear();scanf("%d %d",&N,&k);if (!N && !k) return 0;for (i=1;i<=N;i++) for (j=1;j<=N;RB[i][j++]=0);while (k--) {scanf("%d %d %d",&i,&j,&f);RB[i][j]=RB[j][i]=f;}for (i=1,j=0;i<=N;i++) dfs(i,i,0);printf("%d\n",j);for (printf("%d",a[0]),i=1,j=a.size();i<j;printf(" %d",a[i++]));puts("");}}
a.cc: In function 'void dfs(int, int, int)': a.cc:5:194: error: 'k' was not declared in this scope 5 | void dfs(int here, int prev, int cost) {used[here][prev]=used[prev][here]=0;x.push_back(here);for (int i=1,k=0;i<=N;i++) if (used[here][i] && RB[here][i]) k++,dfs(i,here,cost+RB[here][i]);if (!k) if (j<cost) j=cost,a=x;x.pop_back();used[here][prev]=used[prev][here]=1;} | ^
s968557262
p00690
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; #define NIL -1 vector< vector<int> > edge; vector<int> answer; class Result { public: vector<int> path; int cost; }; Result rec(int v, vector< vector<int> > visited, int cost) { Result result; result.cost = cost; int maxCost = cost; for(int i=0; i<edge.size(); i++) { if(visited[v][i]) continue; if(edge[v][i]==NIL) continue; visited[v][i] = visited[i][v] = 1; Result r = rec(i, visited, cost+edge[v][i]); if(maxCost >= r.cost) continue; maxCost = r.cost; result = r; result.path.insert(result.path.begin(), i); } return result; } void solve() { Result result; int maxCost = NIL; vector< vector<int> > visited(edge.size(), vector<int>(edge.size(), 0)); for(int i=0; i<edge.size(); i++) { Result r = rec(i, visited, 0); if(maxCost >= r.cost) continue; maxCost = r.cost; result = r; result.path.insert(result.path.begin(), i); } cout<<result.cost<<endl; for(vector<int>::iterator i=result.path.begin(); i!=result.path.end(); i++) { if(i!=result.path.begin()) cout<<" "; cout<<*i+1; } cout<<endl; }
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s486132026
p00691
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; テつ? ll calc(ll x,ll y,ll z){ テつ?つ?l A=x*x*x+y*y*y; テつ?つ?eturn (A<=z*z*z) ? A:0; } テつ? int main(){ テつ?つ?l z; テつ?つ?hile(cin>>z,z){ テつ? テつ?つ?つ?つ?l mx=0; テつ?つ?つ?つ?or(int i=1;i<2000;i++) テつ?つ?つ?つ?つ?つ?or(int j=1;j<2000;j++)mx=max(mx,calc(i,j,z)); テつ?つ?つ?つ?out<<z*z*z-mx<<endl; テつ?つ? テつ?つ?eturn 0; }
a.cc:4:1: error: '\U000030c6\U00003064' does not name a type 4 | テつ? | ^~~~ a.cc:9:1: error: '\U000030c6\U00003064' does not name a type 9 | テつ? | ^~~~
s679458919
p00691
C++
#include <iostream> #include <cmath> #include <algorithm> using namespace std; int main(){ long long int n; while(cin >> n, n){ long long int ans = 100000; for(long long int i=1; pow(i,3) <= pow(n, 3); i++){ for(long long int j=1; pow(i,3)+pow(j,3) <= pow(n,3); j++){ long long int m = pow(n,3)-pow(i, 3)-pow(j, 3); if(ans > m) ans = m; } }
a.cc: In function 'int main()': a.cc:15:10: error: expected '}' at end of input 15 | } | ^ a.cc:8:23: note: to match this '{' 8 | while(cin >> n, n){ | ^ a.cc:15:10: error: expected '}' at end of input 15 | } | ^ a.cc:6:11: note: to match this '{' 6 | int main(){ | ^
s675694045
p00692
Java
import java.util.*; import java.lang.Math; public class AOJ1110 { /* static int[][] d={{-5,-4,-3,-1,0,1,3,4,5}, {-4,-1,+1,+4}};*/ static int[] d={-5,-4,-3,-1,0,1,3,4,5}; static int[] a={0,2,5,7,8,10,13,15,16,18}; public static void main(String[] args) { ArrayList<Integer> layout; Scanner sc=new Scanner(System.in); int attend=sc.nextInt(); for(int i=0;i<attend;i++){ layout =new ArrayList<Integer>(); for(int j=0;j<4*5;j++){ layout.add(sc.nextInt()); } System.out.println((20-2*solve(layout,0))); } } static int solve(ArrayList<Integer> layout,int step) { int rem=step; for(int current=0;current<20;current++){ int currentCard =layout.get(current); if(currentCard==0)break; /*for(int n=0;n<5;n++){ for(int m=0;m<4;m++){ System.out.print(layout.get(n*4+m)+" "); } System.out.println(); } System.out.println(); System.out.println("current="+current+"currentCard="+currentCard); */ for(int k=0;k<d.length;k++){ if((current%4==0&&k%3==0)||(current%4==3&&k%3==2)||k==4)continue; if((current<4&&k<3)||(current>=16&&k>5))continue; int next=current+d[k]; int nextCard=layout.get(next); if(nextCard==0)break; //System.out.print("next="+next); //System.out.println("nextCard="+nextCard); if(currentCard==nextCard){ ArrayList<Integer> nextLayout=new ArrayList<Integer>(layout); nextLayout.remove(Math.max(current,next)); nextLayout.remove(Math.min(current,next)); nextLayout.add(0); nextLayout.add(0); // System.out.println("rem="+rem); rem=Math.max(rem,solve(nextLayout,step+1)); if(rem==10)return 10; } } /* if(i%8<4){ for(int k=0;k<d[0].length;k++){ if((current%4==0&&k%3==0)||(current%4==3&&k%3==2)||k==4)continue; if((current<4&&k<3)||(current>=16&&k>=5))continue; int next=current+d[0][k]; int nextCard=layout.get(next); if(nextCard==0)break; System.out.println("0 next="+next); System.out.println("0 nextCard="+nextCard); if(currentCard==nextCard){ ArrayList<Integer> nextLayout=new ArrayList<Integer>(layout); nextLayout.remove(Math.max(current,next)); nextLayout.remove(Math.min(current,next)); nextLayout.add(0); nextLayout.add(0); System.out.println("0 rem="+rem); rem=Math.max(rem,solve(nextLayout,step+1)); if(rem==10)return 10; } } } else{ for(int k=0;k<d[1].length;k++){ int next=current+d[1][k]; int nextCard=layout.get(next); if(nextCard==0)break; System.out.println("1 next="+next); System.out.println("1 nextCard="+nextCard); if(currentCard==nextCard){ ArrayList<Integer> nextLayout=new ArrayList<Integer>(layout); nextLayout.remove(Math.max(current,next)); nextLayout.remove(Math.min(current,next)); nextLayout.add(0); nextLayout.add(0); System.out.println("1 rem="+rem); rem=Math.max(rem,solve(nextLayout,step+1)); if(rem==10)return 10; } } } */ } return rem; } }
Main.java:4: error: class AOJ1110 is public, should be declared in a file named AOJ1110.java public class AOJ1110 ^ 1 error
s532544507
p00692
Java
import java.util.*; import java.lang.Math; public class AOJ1110 { static int[] d={-5,-4,-3,-1,0,1,3,4,5}; static int[] a={0,2,5,7,8,10,13,15,16,18}; public static void main(String[] args) { ArrayList<Integer> layout; Scanner sc=new Scanner(System.in); int attend=sc.nextInt(); for(int i=0;i<attend;i++){ layout =new ArrayList<Integer>(); for(int j=0;j<4*5;j++){ layout.add(sc.nextInt()); } System.out.println((20-2*solve(layout,0))); } } static int solve(ArrayList<Integer> layout,int step) { int rem=step; for(int current=0;current<20;current++){ int currentCard =layout.get(current); if(currentCard==0)break; for(int k=0;k<d.length;k++){ if((current%4==0&&k%3==0)||(current%4==3&&k%3==2)||k==4)continue; if((current<4&&k<3)||(current>=16&&k>5))continue; int next=current+d[k]; int nextCard=layout.get(next); if(nextCard==0)break; if(currentCard==nextCard){ ArrayList<Integer> nextLayout=new ArrayList<Integer>(layout); nextLayout.remove(Math.max(current,next)); nextLayout.remove(Math.min(current,next)); nextLayout.add(0); nextLayout.add(0); rem=Math.max(rem,solve(nextLayout,step+1)); if(rem==10)return 10; } } } return rem; } }
Main.java:4: error: class AOJ1110 is public, should be declared in a file named AOJ1110.java public class AOJ1110 ^ 1 error
s321772051
p00692
C++
4 1 4 5 2 3 1 4 3 5 4 2 2 4 5 2 3 1 1 3 5 5 1 5 1 4 5 3 2 3 2 1 4 1 4 5 3 2 3 4 2 1 2 1 2 5 4 5 4 2 1 2 1 3 5 3 4 3 3 5 4 4 2 3 1 2 5 3 1 3 5 4 2 1 5 4 1 4 5 3 2
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 4 | ^
s981091899
p00693
C
#include <iostream> #include <cstdio> #include <memory.h> #include <cmath> #include <cstring> #include <algorithm> #include <queue> #include <map> #include <vector> using namespace std; char a1[1100][60],b1[1100][60],c1[1100][60],a2[1100][60],b2[1100][60],c2[1100][60]; int a[1100],c[1100]; int main() { int n,m; while(cin>>n>>m&&n+m) { int j=0,b=0; bool flag; for(int i=1;i<=n;i++) { scanf("%s",a1[i]); scanf("%s",b1[i]); scanf("%s",c1[i]); if(strcmp(a1[i],"deny")==0) { c[j++]=i; } } for(int i=1;i<=m;i++) { scanf("%s",a2[i]); scanf("%s",b2[i]); scanf("%s",c2[i]); } for(int i=1;i<=m;i++) { flag=0; for(int k=0;k<=j;k++) { int l; for(l=0;l<8;l++) { if(b1[k][l]!=a2[i][l]&&b1[k][l]!='?') break; if(c1[k][l]!=b2[i][l]&&c1[k][l]!='?') break; } if(l==8) { flag=1; break; } } if(flag==1) { continue; } for(int k=1;k<=n;k++) { flag=0; for(int l=0;l<j;l++) { if(c[l]==k) { flag=1; break; } } if(flag) continue; int l; for(l=0;l<8;l++) { if(b1[k][l]!=a2[i][l]&&b1[k][l]!='?') break; if(c1[k][l]!=b2[i][l]&&c1[k][l]!='?') break; } if(l==8) a[b++]=i; } } cout<<b<<endl; for(int i=0;i<b;i++) { cout<<a2[a[i]]<<" "<<b2[a[i]]<<" "<<c2[a[i]]<<endl; } } return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s160064702
p00693
C
#include <cstdio> int father[1010]; int n,m; void init(int val){ for(int i=1;i<=val;i++){ father[i]=i; } } int find(int val){ if(father[val]==val) return val; return find(father[val]); } void combine(int x,int y){ int tx = find(x); int ty = find(y); if(tx!=ty) father[tx]=ty; } int main(){ while(scanf("%d",&n)!=EOF&&n){ scanf("%d",&m); init(n); int a,b; for(int i=0;i<m;i++){ scanf("%d%d",&a,&b); combine(a,b); } int ans = 0; for(int i=1;i<=n;i++){ if(father[i]==i) ans++; } printf("%d\n",ans-1); } return 0; }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s911539106
p00693
C
#include <cstdio> int father[1010]; int n,m; void init(int val){ for(int i=1;i<=val;i++){ father[i]=i; } } int find(int val){ if(father[val]==val) return val; return find(father[val]); } void combine(int x,int y){ int tx = find(x); int ty = find(y); if(tx!=ty) father[tx]=ty; } int main(){ while(scanf("%d",&n)!=EOF&&n){ scanf("%d",&m); init(n); int a,b; for(int i=0;i<m;i++){ scanf("%d%d",&a,&b); combine(a,b); } int ans = 0; for(int i=1;i<=n;i++){ if(father[i]==i) ans++; } printf("%d\n",ans-1); } return 0; }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s859447135
p00693
C++
#include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define rep(i,n) FOR(i,0,n) #define pb push_back #define mp make_pair typedef long long ll; typedef pair<int,int> pint; string s[1024][3],ans[1024][3]; bool ck(string c1,string c2){ bool flag=true; rep(i,8){ if(c2[i]=='?') continue; if(c1[i]!=c2[i]){ flag =false;break; } } return flag; } int main(){ int n,m; while(cin>>n>>m,n){ int cnt=0; rep(i,n) cin>>s[i][0]>>s[i][1]>>s[i][2]; rep(i,m){ string t1, t2,t3; cin>>t1>>t2>>t3; for(int j=n-1;j>=0;--j){ if(ck(t1,s[j][1])&&ck(t2,s[j][2])){ if(s[j][0][0]=='p'&&!flag){ ans[cnt][0]=t1,ans[cnt][1]=t2,ans[cnt][2]=t3; ++cnt; } break; } } } cout<<cnt<<endl; rep(i,cnt) cout<<ans[i][0]<<' '<<ans[i][1]<<' '<<ans[i][2]<<endl;; } return 0; }
a.cc: In function 'int main()': a.cc:31:42: error: 'flag' was not declared in this scope 31 | if(s[j][0][0]=='p'&&!flag){ | ^~~~
s640540808
p00693
C++
#include <iostream> #include <vector> using namespace std; struct rule { bool permit; string src; string dst; rule(bool p, const string& s, const string& d) : permit(p), src(s), dst(d) {} }; bool match(const string& pat, const string& addr) { const int N = min(pat.size(), addr.size()); for (int i = 0; i < N; i++) { if (pat[i] != '?' && pat[i] != addr[i]) { return false; } } return true; } bool legal(const vector<rule>& rules, const string& src, const string& dst) { for (vector<rule>::const_iterator it(rules.begin()); it != rules.end(); ++it) { if (it->permit && match(it->src, src) && match(it->dst, dst)) { return true; } if (!it->permit && match(it->src, src) && match(it->dst, dst)) { return false; } } return false; } int main() { int n, m; while (cin >> n >> m && n != 0 && m != 0) { vector<rule> rules; for (int i = 0; i < n; i++) { string p, s, d; cin >> p >> s >> d; rules.push_back(rule(p == "permit", s, d)); } reverse(rules.begin(), rules.end()); vector<string> ans; for (int i = 0; i < m; i++) { string s, d, p; cin >> s >> d >> p; if (legal(rules, s, d)) { ans.push_back(s + " " + d + " " + p); } } cout << ans.size() << endl; for (vector<string>::const_iterator it(ans.begin()); it != ans.end(); ++it) { cout << *it << endl; } } return 0; }
a.cc: In function 'int main()': a.cc:48:5: error: 'reverse' was not declared in this scope 48 | reverse(rules.begin(), rules.end()); | ^~~~~~~
s388805144
p00693
C++
ICPC Domestic 2000
a.cc:1:1: error: 'ICPC' does not name a type 1 | ICPC Domestic 2000 | ^~~~
s639659137
p00693
C++
#include<iosrteam> #include<algorithm> using namespace std; int main(){ int a[10]; for(int i=0;i<10;i++)cin >> a[i]; sort(a,a+10); for(int i=9;i>6;i--)cout << a[i] << endl; }
a.cc:1:9: fatal error: iosrteam: No such file or directory 1 | #include<iosrteam> | ^~~~~~~~~~ compilation terminated.
s925957182
p00693
C++
#include<iosrteam> #include<algorithm> using namespace std; int main(){ int a[10]; for(int i=0;i<10;i++)cin >> a[i]; sort(a,a+10); for(int i=9;i>6;i--)cout << a[i] << endl; }
a.cc:1:9: fatal error: iosrteam: No such file or directory 1 | #include<iosrteam> | ^~~~~~~~~~ compilation terminated.
s479009805
p00694
C++
#include<map> #include<cstdio> #include<vector> #include<algorithm> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; struct point{ int x,y,z; point operator+(const point &a)const{ return (point){x+a.x,y+a.y,z+a.z}; } point operator-(const point &a)const{ return (point){x-a.x,y-a.y,z-a.z}; } bool operator==(const point &a)const{ return x==a.x && y==a.y && z==a.z; } }; struct edge{ point u,v; bool operator==(const edge &e)const{ return u==e.u && v==e.v || u==e.v && v==e.u; } }; struct key{ int n; edge E[300]; }; key getkey(){ key K={}; point p={0,0,0}; map<int,point> f; int n; scanf("%d",&n); while(n--){ char s[8]; scanf("%s",s); if(isdigit(s[0])){ int a; sscanf(s,"%d",&a); if(f.count(a)) p=f[a]; else f[a]=p; } else{ point q=p; if(s[0]=='+' && s[1]=='x') q.x++; if(s[0]=='-' && s[1]=='x') q.x--; if(s[0]=='+' && s[1]=='y') q.y++; if(s[0]=='-' && s[1]=='y') q.y--; if(s[0]=='+' && s[1]=='z') q.z++; if(s[0]=='-' && s[1]=='z') q.z--; K.E[K.n++]=(edge){p,q}; p=q; } } return K; } struct matrix{ int a[3][3]; point operator*(const point &p)const{ int x=a[0][0]*p.x+a[0][1]*p.y+a[0][2]*p.z; int y=a[1][0]*p.x+a[1][1]*p.y+a[1][2]*p.z; int z=a[2][0]*p.x+a[2][1]*p.y+a[2][2]*p.z; return (point){x,y,z}; } matrix operator*(const matrix &A)const{ matrix B={}; rep(i,3) rep(j,3) rep(k,3) B.a[i][j]+=a[i][k]*A.a[k][j]; return B; } bool operator==(const matrix &A)const{ rep(i,3) rep(j,3) if(a[i][j]!=A.a[i][j]) return false; return true; } }; vector<matrix> R; bool issame(const key &K1,const key &K2){ if(K1.n!=K2.n) return false; point shift1=K1.E[0].u; point dir1=K1.E[0].v-shift1; rep(i,K2.n){ point shift2,dir2; rep(t,2){ if(t==0) shift2=K2.E[i].u, dir2=K2.E[i].v-shift2; if(t==1) shift2=K2.E[i].v, dir2=K2.E[i].u-shift2; rep(j,R.size()) if(R[j]*dir1==dir2) { bool ok=true; rep(k,K1.n){ edge e=K1.E[k]; e=(edge){e.u-shift1,e.v-shift1}; e=(edge){R[j]*e.u,R[j]*e.v}; e=(edge){e.u+shift2,e.v+shift2}; if(count(K2.E,K2.E+K2.n,e)!=1){ ok=false; break; } } if(ok) return true; } } } return false; } int main(){ matrix I,X,Y,Z; I.a[0][0]= 1; I.a[0][1]= 0; I.a[0][2]= 0; I.a[1][0]= 0; I.a[1][1]= 1; I.a[1][2]= 0; I.a[2][0]= 0; I.a[2][1]= 0; I.a[2][2]= 1; X.a[0][0]= 1; X.a[0][1]= 0; X.a[0][2]= 0; X.a[1][0]= 0; X.a[1][1]= 0; X.a[1][2]=-1; X.a[2][0]= 0; X.a[2][1]= 1; X.a[2][2]= 0; Y.a[0][0]= 0; Y.a[0][1]= 0; Y.a[0][2]=-1; Y.a[1][0]= 0; Y.a[1][1]= 1; Y.a[1][2]= 0; Y.a[2][0]= 1; Y.a[2][1]= 0; Y.a[2][2]= 0; Z.a[0][0]= 0; Z.a[0][1]=-1; Z.a[0][2]= 0; Z.a[1][0]= 1; Z.a[1][1]= 0; Z.a[1][2]= 0; Z.a[2][0]= 0; Z.a[2][1]= 0; Z.a[2][2]= 1; R.push_back(I); while(1){ bool change=false; rep(i,R.size()){ rep(j,3){ matrix A=(j==0?X*R[i]:j==1?Y*R[i]:Z*R[i]); if(count(R.begin(),R.end(),A)==0){ R.push_back(A); change=true; } } } if(!change) break; } while(1){ key K1=getkey(); if(K1.n==0) break; key K2=getkey(); puts(issame(K1,K2)?"SAME":"DIFFERENT"); } return 0; }
a.cc: In function 'key getkey()': a.cc:35:20: error: 'isdigit' was not declared in this scope 35 | if(isdigit(s[0])){ | ^~~~~~~
s070431903
p00695
Java
import java.util.Scanner; public class Mian { public static void main(String arg[]) { Scanner in = new Scanner(System.in); int a[][]=new int[5][5]; int n=in.nextInt(); while(n-->0) { for(int i=0; i<5; i++) for(int j=0; j<5; j++) a[i][j]=in.nextInt(); int max=0; for(int i=0; i<5; i++) { for(int j=0; j<5; j++) //ここまで始点決定の記述 { for(int h=i;h<5;h++) { for(int w=j;w<5;w++) { boolean flag =true; int co=0; for(int x=i;x<=h;x++) for(int y=j;y<=w;y++) { if(a[x][y]==0) flag = false; else co++; } if(flag) max=Math.max(max, co); } } } } System.out.println(max); } } }
Main.java:2: error: class Mian is public, should be declared in a file named Mian.java public class Mian ^ 1 error
s179379904
p00695
Java
import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.Scanner; import java.util.Stack; public class Main_Fast { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int m = sc.nextInt(); for(int tt = 0; tt < m; tt++){ int[][] sum = new int[5][5]; for(int i = 0; i < 5; i++){ for(int j = 0; j < 5; j++){ sum[i][j] = sc.nextInt(); } } /* for(int i = 0; i < 5; i++){ for(int j = 1; j < 5; j++){ sum[i][j] += sum[i][j-1]; } } */ for(int j = 0; j < 5; j++){ for(int i = 1; i < 5; i++){ if(sum[i][j] == 0){ continue; }else if(sum[i-1][j] == 0){ continue; }else{ sum[i][j] += sum[i-1][j]; } } } /* for(int i = 0; i < 5; i++){ for(int j = 0; j < 5; j++){ System.out.print(sum[i][j] + " "); } System.out.println(); } */ int max = Integer.MIN_VALUE; Stack<Integer> stack = new Stack<Integer>(); Stack<Integer> number = new Stack<Integer>(); for(int i = 0; i < 5; i++){ stack.clear(); number.clear(); for(int j = 0; j < 5; j++){ //System.out.println(stack); //System.out.println(number); if(stack.isEmpty()){ stack.push(sum[i][j]); number.push(j); }else if(stack.peek() <= sum[i][j]){ stack.push(sum[i][j]); number.push(j); }else{ while(!stack.isEmpty() && stack.peek() > sum[i][j]){ final int high = stack.pop(); final int dist = j - number.pop(); max = Math.max(max, high * dist); } stack.push(sum[i][j]); number.push(j); } } while(!stack.isEmpty()){ final int high = stack.pop(); final int dist = 5 - number.pop(); max = Math.max(max, high * dist); } } System.out.println(max); } } }
Main.java:8: error: class Main_Fast is public, should be declared in a file named Main_Fast.java public class Main_Fast { ^ 1 error
s906111903
p00695
Java
import java.util.ArrayList; import java.util.Iterator; import java.util.LinkedList; import java.util.Scanner; import java.util.Stack; public class Main_Fast { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final int m = sc.nextInt(); for(int tt = 0; tt < m; tt++){ int[][] sum = new int[5][5]; for(int i = 0; i < 5; i++){ for(int j = 0; j < 5; j++){ sum[i][j] = sc.nextInt(); } } /* for(int i = 0; i < 5; i++){ for(int j = 1; j < 5; j++){ sum[i][j] += sum[i][j-1]; } } */ for(int j = 0; j < 5; j++){ for(int i = 1; i < 5; i++){ if(sum[i][j] == 0){ continue; }else{ sum[i][j] += sum[i-1][j]; } } } /* for(int i = 0; i < 5; i++){ for(int j = 0; j < 5; j++){ System.out.print(sum[i][j] + " "); } System.out.println(); } */ int max = Integer.MIN_VALUE; Stack<Integer> stack = new Stack<Integer>(); Stack<Integer> number = new Stack<Integer>(); for(int i = 0; i < 5; i++){ stack.clear(); number.clear(); for(int j = 0; j < 5; j++){ //System.out.println(i + " " + j + " " + stack); //System.out.println(i + " " + j + " " + number); if(stack.isEmpty()){ stack.push(sum[i][j]); number.push(j); }else if(stack.peek() < sum[i][j]){ stack.push(sum[i][j]); number.push(j); }else{ int num = j; while(!stack.isEmpty() && stack.peek() > sum[i][j]){ final int high = stack.pop(); final int place = number.pop(); num = Math.min(num, place); final int dist = j - place; //System.out.println("<" + dist + " " + high + ">"); max = Math.max(max, high * dist); } if(stack.isEmpty() || stack.peek() < sum[i][j]){ stack.push(sum[i][j]); number.push(num); } } } //System.out.println(i + " " + 5 + " " + stack); //System.out.println(i + " " + 5 + " " + number); while(!stack.isEmpty()){ final int high = stack.pop(); final int dist = 5 - number.pop(); //System.out.println("<" + dist + " " + high + ">"); max = Math.max(max, high * dist); } } System.out.println(max); } } }
Main.java:8: error: class Main_Fast is public, should be declared in a file named Main_Fast.java public class Main_Fast { ^ 1 error
s998553720
p00695
C++
#include<stdio.h> int main(){ int a[7][7],m,i,j,k,l,n,o,not,max,my,mx; scanf("%d",&m); for(i=0;i<m;i++){ //syokika for(j=0;j<7;j++){ for(k=0;k<7;k++){ a[j][k]=0; } } max=0; //in for(j=0;j<5;j++){ for(k=0;k<5;k++){ scanf("%d",&a[j][k]); } } //syori for(j=0;j<5;j++){ for(k=0;k<5;k++){ if(a[j][k]==1){ for(l=0;k+l<6;l++){ if(a[j][k+l]==1){ mx=l+1; for(n=0;j+n<6;n++){ not=0; for(o=0;o<=l;o++){ if(a[j+n][k+o]==0)not=1; } if(not==1){ my=n; if(max<my*mx){ max=my*mx; } break; } } } else{ break; } } } } } printf("%d\n",max); } return 0; }
a.cc: In function 'int main()': a.cc:3:29: error: expected unqualified-id before 'not' token 3 | int a[7][7],m,i,j,k,l,n,o,not,max,my,mx; | ^~~ a.cc:12:5: error: 'max' was not declared in this scope 12 | max=0; | ^~~ a.cc:25:15: error: 'mx' was not declared in this scope; did you mean 'm'? 25 | mx=l+1; | ^~ | m a.cc:27:20: error: expected primary-expression before '=' token 27 | not=0; | ^ a.cc:29:40: error: expected primary-expression before '=' token 29 | if(a[j+n][k+o]==0)not=1; | ^ a.cc:31:23: error: expected primary-expression before '==' token 31 | if(not==1){ | ^~ a.cc:32:19: error: 'my' was not declared in this scope; did you mean 'm'? 32 | my=n; | ^~ | m
s223494113
p00695
C++
#include<stdio.h> int main(){ int a[7][7],m,i,j,k,l,n,o,not,max,my,mx; scanf("%d",&m); for(i=0;i<m;i++){ //syokika for(j=0;j<7;j++){ for(k=0;k<7;k++){ a[j][k]=0; } } max=0; //in for(j=0;j<5;j++){ for(k=0;k<5;k++){ scanf("%d",&a[j][k]); } } //syori for(j=0;j<5;j++){ for(k=0;k<5;k++){ if(a[j][k]==1){ for(l=0;k+l<6;l++){ if(a[j][k+l]==1){ mx=l+1; for(n=0;j+n<6;n++){ not=0; for(o=0;o<=l;o++){ if(a[j+n][k+o]==0)not=1; } if(not==1){ my=n; if(max<my*mx){ max=my*mx; } break; } } } else{ break; } } } } } printf("%d\n",max); } return 0; }
a.cc: In function 'int main()': a.cc:3:29: error: expected unqualified-id before 'not' token 3 | int a[7][7],m,i,j,k,l,n,o,not,max,my,mx; | ^~~ a.cc:12:5: error: 'max' was not declared in this scope 12 | max=0; | ^~~ a.cc:25:15: error: 'mx' was not declared in this scope; did you mean 'm'? 25 | mx=l+1; | ^~ | m a.cc:27:20: error: expected primary-expression before '=' token 27 | not=0; | ^ a.cc:29:40: error: expected primary-expression before '=' token 29 | if(a[j+n][k+o]==0)not=1; | ^ a.cc:31:23: error: expected primary-expression before '==' token 31 | if(not==1){ | ^~ a.cc:32:19: error: 'my' was not declared in this scope; did you mean 'm'? 32 | my=n; | ^~ | m
s602322890
p00696
C++
#include <cstring> #include <cstdlib> #include <string> #include <cmath> #include <queue> using namespace std; #define REP(i,n) for(int i=0;i<(int)n;++i) #define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i) #define ALL(c) (c).begin(), (c).end() const int INF = 1<<29; string buf[101]; int main() { string input; vector<string> vs; int plen,cnum,width,cspace; while(cin>>plen, plen) { cin>>cnum>>width>>cspace; cin.ignore(); vs.clear(); while(true) { getline(cin, input); if(input == "?") break; vs.push_back(input); } vector<string> normalized; for(int i=0; i<vs.size(); ++i) { while(vs[i].length() > width) { normalized.push_back(vs[i].substr(0,width)); vs[i] = vs[i].substr(width); } normalized.push_back(vs[i]); } for(int i=0; i<normalized.size(); ++i) { if(normalized[i].length() < width) normalized[i] += string(width-normalized[i].length(), '.'); } if(normalized.size()%(plen*cnum) > 0) { for(int i=0; i<normalized.size()%(plen*cnum); ++i) { normalized.push_back(string(width, '.')); } } vector<vector<string> > pages; for(int i=0; i<normalized.size(); i += plen * cnum) { vector<string> op; for(int j=0; j<plen*cnum; ++j) op.push_back(normalized[i+j]); pages.push_back(op); } for(int i=0; i<pages.size(); ++i) { for(int j=0; j<100; ++j) buf[j] = ""; for(int j=0; j<pages[i].size(); ++j) { buf[j%plen] += (j>=plen?".":"") + pages[i][j]; } for(int i=0; i<plen; ++i) cout<<buf[i]<<endl; cout<<"#"<<endl; } cout<<"?"<<endl; } }
a.cc: In function 'int main()': a.cc:19:9: error: 'cin' was not declared in this scope 19 | while(cin>>plen, plen) { | ^~~ a.cc:6:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 5 | #include <queue> +++ |+#include <iostream> 6 | using namespace std; a.cc:62:33: error: 'cout' was not declared in this scope 62 | for(int i=0; i<plen; ++i) cout<<buf[i]<<endl; | ^~~~ a.cc:62:33: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:62:47: error: 'endl' was not declared in this scope 62 | for(int i=0; i<plen; ++i) cout<<buf[i]<<endl; | ^~~~ a.cc:6:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 5 | #include <queue> +++ |+#include <ostream> 6 | using namespace std; a.cc:63:7: error: 'cout' was not declared in this scope 63 | cout<<"#"<<endl; | ^~~~ a.cc:63:7: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:63:18: error: 'endl' was not declared in this scope 63 | cout<<"#"<<endl; | ^~~~ a.cc:63:18: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' a.cc:65:5: error: 'cout' was not declared in this scope 65 | cout<<"?"<<endl; | ^~~~ a.cc:65:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:65:16: error: 'endl' was not declared in this scope 65 | cout<<"?"<<endl; | ^~~~ a.cc:65:16: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
s837347439
p00697
Java
import java.util.Scanner; public class Jigsaw { static char[][] input = new char[9][4]; static char[][] puzzles = new char[9][4]; public static void main(String[] args) { Scanner s = new Scanner(System.in); int cnt = Integer.parseInt(s.nextLine()); for(int i=0 ; i<cnt ; i++) { String[] tmp = s.nextLine().split(" "); for(int j=0 ; j<9 ; j++) { input[j] = tmp[j].toCharArray(); } boolean[] isUsed = new boolean[9]; System.out.println(solve(0, isUsed)); } } public static int solve(int position, boolean[] isUsed) { if(position == 9) return 1; int cnt = 0; for(int i=0 ; i<9 ; i++) { // ??¢???????±?????????????????????????????????´??? if(isUsed[i]) continue; char[] puzzle = input[i]; puzzles[position] = puzzle; for(int j=0 ; j<4 ; j++) { if(check(position)) { isUsed[i] = true; cnt += solve(position+1, isUsed); isUsed[i] = false; } rotate(position); } } puzzles[position] = null; return cnt; } public static boolean check(int position) { boolean result = false; return result; } public static void rotate(int position) { char[] tmp = puzzles[position]; char tm = tmp[0]; for(int i=1 ; i<tmp.length ; i++) { tmp[i-1] = tmp[i]; } tmp[tmp.length-1] = tm; } }
Main.java:4: error: class Jigsaw is public, should be declared in a file named Jigsaw.java public class Jigsaw { ^ 1 error
s540927990
p00697
Java
import java.util.*; class Main{ String[][] puzzle; String[][] field; boolean[] used; void run(){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); for(int attend=0;attend<n;attend++){ field =new String[3][3]; puzzle=new String[9][4]; used=new boolean[9]; for(int i=0;i<9;i++){ setPuzzle(i,sc.next()); } System.out.println(dfs(0)); } } void setPuzzle(int num,String pu){ for(int i=0;i<4;i++){ puzzle[num][i]=pu.substring(i,pu.length())+pu.substring(0,i); } } int dfs(int step){ if(step==9) return 1; int ans=0; for(int i=0;i<9;i++){ if(used[i]==true)continue; for(int j=0;j<4;j++){ if(step>2){ if(!puzzleCompare(field[step/3-1][step%3].charAt(2),puzzle[i][j].charAt(0)))continue; } if(step%3!=0){ if(!puzzleCompare(field[step/3][step%3-1].charAt(3),puzzle[i][j].charAt(1)))continue; } field[step/3][step%3]=puzzle[i][j]; used[i]=true; ans+=dfs(step+1); used[i]=false; } } return ans; } boolean puzzleCompare(char puz1,char puz2){ if(puz1-'a'+'A'==puz2)return true; else if(puz2-'a'+'A'==puz1)return true; else return false; } public static void Main(String[] args){ new AOJ1116().run(); } }
Main.java:50: error: cannot find symbol new AOJ1116().run(); ^ symbol: class AOJ1116 location: class Main 1 error
s149264787
p00697
C++
#include<bits/stdc++.h> #define rep(i,n)for(int i=0;i<(n);i++) using namespace std; char s[9][5], t[3][3][5]; int dx[]{ -1,0,1,0 }, dy[]{ 0,1,0,-1 }; int dfs(int p) { int res = 0; rep(i, 3)rep(j, 3) { if (t[i][j][0])continue; rep(k, 4) { rep(l, 4) { int nx = i + dx[l], ny = j + dy[l]; if (nx < 0 || 3 <= nx || ny < 0 || 3 <= ny || !t[nx][ny][0])continue; if (abs(s[p][(l + k) % 4] - t[nx][ny][(l + 2) % 4]) != 'a' - 'A')goto g; } if (p == 8)res++; else { rep(l, 4)t[i][j][l] = s[p][(l + k) % 4]; res += dfs(p + 1); t[i][j][0] = 0; }g:; } } return res; } int main() { int n; scanf("%d", &n); rep(i, n) { scanf("%s", s[j]); printf("%d\n", dfs(0)); } }
a.cc: In function 'int main()': a.cc:29:31: error: 'j' was not declared in this scope 29 | scanf("%s", s[j]); | ^
s813325885
p00697
C++
#include<iostream> #include<string> #include<vector> using namespace std; class P{ public: int d,r; }; int data,res; vector<string>sv; int dy[] = {-1,0,1,0}; int dx[] = {0,1,0,-1}; void input(){ string tmp; sv.clear(); for(int i = 0 ; i < 9 ; i++)cin >> tmp,sv.push_back(tmp); } bool check(int x,int y){ if(!(0 <= x && x < 3))return false; if(!(0 <= y && y < 3))return false; return true; } void dfs(int pos,int data,vector<P>v){ //cout << "pos = " << pos << endl;// //cout << "res = " << res << endl;// if(pos == 9){ res++; return; } for(int i = 0 ; i < 9 ; i++){ if(data & (1 << i))continue; int ndata = (data | (1 << i)); string str = sv[i]; for(int j = 0 ; j < 4 ; j++){ vector<P>nv = v; char u,r,d,l; u = str[j]; r = str[(j+1)%4]; d = str[(j+2)%4]; l = str[(j+3)%4]; int x,y; x = pos%3; y = pos/3; int nx,ny,npos; // up ny = y + dy[0]; nx = x + dx[0]; if(check(nx,ny)){ npos = ny * 3 + nx; if(abs(v[npos].d - u) != abs('A'- 'a'))continue; } // left ny = y + dy[3]; nx = x + dx[3]; if(check(nx,ny)){ npos = ny * 3 + nx; if(abs(v[npos].r - l) != abs('A'- 'a'))continue; } P p; p.r = r; p.d = d; nv.push_back(p); dfs(pos+1,ndata,nv); } } } void solve(){ input(); data = 0; res = 0; vector<P>v; dfs(0,data,v); cout << res << endl; } int main(){ int n; cin >> n; for(int i = 0 ; i < n ; i++)solve(); return 0; }
a.cc: In function 'void solve()': a.cc:87:3: error: reference to 'data' is ambiguous 87 | data = 0; | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:12:5: note: 'int data' 12 | int data,res; | ^~~~ a.cc:90:9: error: reference to 'data' is ambiguous 90 | dfs(0,data,v); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:12:5: note: 'int data' 12 | int data,res; | ^~~~
s170074008
p00697
C++
#include <vector> #include <list> #include <map> #include <set> #include <stack> #include <queue> #include <deque> #include <algorithm> #include <utility> #include <functional> #include <sstream> #include <iostream> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <ctime> #include <climits> #include <cassert> using namespace std; inline int toInt (string s) {int v; istringstream sin(s); sin>>v; return v;} template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();} typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef pair<int,int> pii; typedef long long ll; #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define EACH(t,i,c) for(t::iterator i=(c).begin();i!=(c).end();++i) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) const double EPS=1e-10; const double PI=acos(-1.0); struct P{ string sides; P(string sides):sides(sides){} }; typedef vector<P> vP; typedef vector<vP> vvP; int dx[]={0,1,0,-1},dy[]={-1,0,1,0}; bool match(char l,char r){ if(l==' '||r==' '){ return true; } if(l>r){ swap(l,r); } switch(l){ case 'R': return r=='r'; case 'G': return r=='g'; case 'B': return r=='b'; case 'W': return r=='w'; default: assert(r!='R'&&r!='G'&&r!='B'&&r!='W'); return false; } } bool ok(vvP &board,P piece,int x,int y){ REP(i,4){ int xx=x+dx[i],yy=y+dy[i]; if(xx>=0&&xx<3&&yy>=0&&yy<3){ if(!match(board[xx][yy].sides[(i+2)%4],piece.sides[i])){ return false; } } } return true; } P rotate(P &p,int a){ P ret(" "); REP(i,4){ ret.sides[i]=p.sides[(i+a)%4]; } return ret; } int aaaa=0; int dfs(vvP &board,vi used,int n,vP &pieces){ if(n==9){ return 1; } int res=0; int x=n%3,y=n/3; REP(i,9){ if(!used[i]){ REP(j,4){ P piece=rotate(pieces[i],j); if(ok(board,piece,x,y)){ vi newUsed(used); newUsed[i]=1; vvP newBoard(board); newBoard[x][y]=piece; res+=dfs(newBoard,newUsed,n+1,pieces); } } } } aaaa=max(aaaa,res); return res; } int main(){ int N; cin>>N; REP(i,N){ vP pieces; REP(j,9){ string sides; cin>>sides; pieces.push_back(P(sides)); } cout<<dfs(vvP(3,vP(3,P(" "))),vi(9),0,pieces)<<endl; } }
a.cc: In function 'int main()': a.cc:123:27: error: cannot bind non-const lvalue reference of type 'vvP&' {aka 'std::vector<std::vector<P> >&'} to an rvalue of type 'vvP' {aka 'std::vector<std::vector<P> >'} 123 | cout<<dfs(vvP(3,vP(3,P(" "))),vi(9),0,pieces)<<endl; | ^~~~~~~~~~~~~~~~~~~~~~ a.cc:89:14: note: initializing argument 1 of 'int dfs(vvP&, vi, int, vP&)' 89 | int dfs(vvP &board,vi used,int n,vP &pieces){ | ~~~~~^~~~~
s566856758
p00698
C++
#include <vector> #include <list> #include <map> #include <set> #include <stack> #include <queue> #include <deque> #include <algorithm> #include <utility> #include <functional> #include <sstream> #include <iostream> #include <cstdio> #include <cmath> #include <cstdlib> #include <cctype> #include <string> #include <cstring> #include <ctime> #include <climits> #include <cassert> using namespace std; inline int toInt (string s) {int v; istringstream sin(s); sin>>v; return v;} template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();} typedef vector<int> vi; typedef vector<vi> vvi; typedef vector<string> vs; typedef pair<int,int> pii; typedef long long ll; #define ALL(a) (a).begin(),(a).end() #define RALL(a) (a).rbegin(),(a).rend() #define EACH(t,i,c) for(t::iterator i=(c).begin();i!=(c).end();++i) #define EXIST(s,e) ((s).find(e)!=(s).end()) #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) const double EPS=1e-10; const double PI=acos(-1.0); const int UNDEF=INT_MAX; int main(){ int p,s; int cc=0; while(cin>>p,p){ if(cc){ cout<<endl<<endl; } cin>>s; vvi cells(p+1,vi(s+1,UNDEF)); vector<pii> undefs; REP(i,p+1){ REP(j,s+1){ string s; cin>>s; if(s=="?"){ cells[i][j]=UNDEF; undefs.push_back(make_pair(i,j)); }else{ cells[i][j]=toInt(s); } } } vi ans(undefs.size()); bool flag=true; vi used(undefs.size(),0); while(flag){ flag=false; REP(kk,undefs.size()){ if(used[kk])continue; pii u=undefs[kk]; int sum2=0; REP(i,s){ if(cells[u.first][i]==UNDEF){ if(i!=u.second){ goto ng_s; } }else{ sum2+=cells[u.first][i]; } } ans[kk]=(cells[u.first][s]-sum2); cells[u.first][u.second]=ans[kk]; used[kk]=1; flag=true; goto ng_p; ng_s:; int sum1=0; REP(i,p){ if(cells[i][u.second]==UNDEF){ if(i!=u.first){ goto ng_p; } }else{ sum1+=cells[i][u.second]; } } ans[kk]=(cells[p][u.second]-sum1); cells[u.first][u.second]=ans[kk]; used[kk]=1; flag=true; ng_p:; } } if(find(ALL(used),0)==used.end()){ REP(i,ans.size()){ if(i==ans.size()-1){ cout<<ans[i]; }else{ cout<<ans[i]<<endl; } } }else{ cout<<"NO"; } cc++; } }
a.cc: In function 'int main()': a.cc:104:9: error: jump to label 'ng_p' 104 | ng_p:; | ^~~~ a.cc:88:38: note: from here 88 | goto ng_p; | ^~~~ a.cc:90:37: note: crosses initialization of 'int sum1' 90 | int sum1=0; | ^~~~
s424181652
p00700
Java
Last login: Thu May 30 19:04:59 on ttys000 cmccl04:~ rigaku$ vim Main.java cmccl04:~ rigaku$ vim Main.java cmccl04:~ rigaku$ javac Main.java Main.java:44: class?Ainterface?A?&#1794;??? enum ??????&#1794;???B } ^ ?G???[ 1 ?? cmccl04:~ rigaku$ vim Main.java cmccl04:~ rigaku$ javac Main.java Main.java:13: ?&#1866;????&#770;&#514;??^ ???o?l : java.lang.String ???&#1170;l : int n=kbd.next(); ^ ?G???[ 1 ?? cmccl04:~ rigaku$ vim Main.java cmccl04:~ rigaku$ javac Main.java Main.java:30: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B if(x>xmax){ ^ Main.java:36: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B System.out.println(xmax+" "+ymax); ^ Main.java:36: ?&#976;? ymax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B System.out.println(xmax+" "+ymax); ^ ?G???[ 3 ?? cmccl04:~ rigaku$ vim Main.java cmccl04:~ rigaku$ javac Main.java cmccl04:~ rigaku$ java Main 1 1 0 -1 0 0 0 1 0 cmccl04:~ rigaku$ java Main 1 2 0 0 1 -1 0 0 1 -1 0 0 -2 0 0 2 1 cmccl04:~ rigaku$ vim sample.txt cmccl04:~ rigaku$ java Main <sample.txt 6 5 6 5 6 5 cmccl04:~ rigaku$ vim Main.java cmccl04:~ rigaku$ javac Main.java cmccl04:~ rigaku$ java Main <sample.txt 6 5 1 0 2 1 cmccl04:~ rigaku$ vim Main.java public class Main{ public static void main(String[] args){ int n; int x,y,dx,dy; int xmax,ymax; int d,dmax; Scanner kbd=new Scanner(System.in); n=kbd.nextInt(); x=0; y=0; d=0; for(int i=0; i<n; i++){ dmax=0; xmax=0; ymax=0; while(true){ dx=kbd.nextInt(); dy=kbd.nextInt(); x+=dx; y+=dy; d=x*x+y*y; if(dmax<d){ dmax=d; xmax=x; ymax=y; } else if(dmax==d){ if(x>xmax){ xmax=x; ymax=y; } } if(dx==0 && dy==0){ System.out.println(xmax+" "+ymax); break; } } } } }
Main.java:1: error: class, interface, enum, or record expected Last login: Thu May 30 19:04:59 on ttys000 ^ Main.java:26: error: <identifier> expected Main.java:44: class?Ainterface?A?&#1794;??? enum ??????&#1794;???B ^ Main.java:26: error: illegal character: '#' Main.java:44: class?Ainterface?A?&#1794;??? enum ??????&#1794;???B ^ Main.java:26: error: class, interface, enum, or record expected Main.java:44: class?Ainterface?A?&#1794;??? enum ??????&#1794;???B ^ Main.java:26: error: <identifier> expected Main.java:44: class?Ainterface?A?&#1794;??? enum ??????&#1794;???B ^ Main.java:26: error: enum constant expected here Main.java:44: class?Ainterface?A?&#1794;??? enum ??????&#1794;???B ^ Main.java:26: error: illegal character: '#' Main.java:44: class?Ainterface?A?&#1794;??? enum ??????&#1794;???B ^ Main.java:26: error: illegal start of type Main.java:44: class?Ainterface?A?&#1794;??? enum ??????&#1794;???B ^ Main.java:28: error: class, interface, enum, or record expected ^ ^ Main.java:32: error: illegal character: '#' Main.java:13: ?&#1866;????&#770;&#514;??^ ^ Main.java:32: error: class, interface, enum, or record expected Main.java:13: ?&#1866;????&#770;&#514;??^ ^ Main.java:32: error: illegal character: '#' Main.java:13: ?&#1866;????&#770;&#514;??^ ^ Main.java:32: error: class, interface, enum, or record expected Main.java:13: ?&#1866;????&#770;&#514;??^ ^ Main.java:32: error: illegal character: '#' Main.java:13: ?&#1866;????&#770;&#514;??^ ^ Main.java:32: error: class, interface, enum, or record expected Main.java:13: ?&#1866;????&#770;&#514;??^ ^ Main.java:34: error: illegal character: '#' ???&#1170;l : int ^ Main.java:34: error: class, interface, enum, or record expected ???&#1170;l : int ^ Main.java:36: error: class, interface, enum, or record expected ^ ^ Main.java:40: error: illegal character: '#' Main.java:30: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:40: error: class, interface, enum, or record expected Main.java:30: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:40: error: illegal character: '#' Main.java:30: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:40: error: class, interface, enum, or record expected Main.java:30: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:40: error: illegal character: '#' Main.java:30: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:40: error: class, interface, enum, or record expected Main.java:30: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:40: error: illegal character: '#' Main.java:30: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:40: error: class, interface, enum, or record expected Main.java:30: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:40: error: illegal character: '#' Main.java:30: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:40: error: illegal character: '\' Main.java:30: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:40: error: class, interface, enum, or record expected Main.java:30: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:40: error: illegal character: '#' Main.java:30: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:40: error: class, interface, enum, or record expected Main.java:30: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:43: error: illegal character: '#' Main.java:36: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:43: error: class, interface, enum, or record expected Main.java:36: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:43: error: illegal character: '#' Main.java:36: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:43: error: class, interface, enum, or record expected Main.java:36: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:43: error: illegal character: '#' Main.java:36: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:43: error: class, interface, enum, or record expected Main.java:36: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:43: error: illegal character: '#' Main.java:36: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:43: error: class, interface, enum, or record expected Main.java:36: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:43: error: illegal character: '#' Main.java:36: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:43: error: illegal character: '\' Main.java:36: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:43: error: class, interface, enum, or record expected Main.java:36: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:43: error: illegal character: '#' Main.java:36: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:43: error: class, interface, enum, or record expected Main.java:36: ?&#976;? xmax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:45: error: class, interface, enum, or record expected ^ ^ Main.java:46: error: illegal character: '#' Main.java:36: ?&#976;? ymax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:46: error: class, interface, enum, or record expected Main.java:36: ?&#976;? ymax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:46: error: illegal character: '#' Main.java:36: ?&#976;? ymax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:46: error: class, interface, enum, or record expected Main.java:36: ?&#976;? ymax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:46: error: illegal character: '#' Main.java:36: ?&#976;? ymax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:46: error: class, interface, enum, or record expected Main.java:36: ?&#976;? ymax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:46: error: illegal character: '#' Main.java:36: ?&#976;? ymax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:46: error: class, interface, enum, or record expected Main.java:36: ?&#976;? ymax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:46: error: illegal character: '#' Main.java:36: ?&#976;? ymax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:46: error: illegal character: '\' Main.java:36: ?&#976;? ymax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:46: error: class, interface, enum, or record expected Main.java:36: ?&#976;? ymax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:46: error: illegal character: '#' Main.java:36: ?&#976;? ymax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:46: error: class, interface, enum, or record expected Main.java:36: ?&#976;? ymax ?&#847;?????????&#258;??&#514;??&#148;\????????&#1794;??B ^ Main.java:48: error: class, interface, enum, or record expected ^ ^ 59 errors
s410760358
p00700
Java
public class Main{ public static void main(String[] args){ int n; int x,y,dx,dy; int xmax,ymax; int d,dmax; Scanner kbd=new Scanner(System.in); n=kbd.nextInt(); x=0; y=0; d=0; for(int i=0; i<n; i++){ dmax=0; xmax=0; ymax=0; while(true){ dx=kbd.nextInt(); dy=kbd.nextInt(); x+=dx; y+=dy; d=x*x+y*y; if(dmax<d){ dmax=d; xmax=x; ymax=y; } else if(dmax==d){ if(x>xmax){ xmax=x; ymax=y; } } if(dx==0 && dy==0){ System.out.println(xmax+" "+ymax); break; } } } } }
Main.java:9: error: cannot find symbol Scanner kbd=new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:9: error: cannot find symbol Scanner kbd=new Scanner(System.in); ^ symbol: class Scanner location: class Main 2 errors
s934797005
p00700
C
#include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<cassert> #include<iostream> #include<sstream> #include<string> #include<vector> #include<queue> #include<set> #include<map> #include<utility> #include<numeric> #include<algorithm> #include<bitset> #include<complex> #include<stack> using namespace std; typedef long long Int; typedef vector<int> vint; typedef pair<int,int> pint; typedef vector<string> vstring; typedef vector<pint> vpint; typedef stringstream SS; template<class T> void chmin(T &t, T f) { if (t > f) t = f; } template<class T> void chmax(T &t, T f) { if (t < f) t = f; } #define rep(i,n) for(int i=0;i<(n);++i) #define repn(i,m,n) for(int i=(m);i<(n);++i) #define repd(i,n) for(int i=(n)-1;i>=0;--i) #define repnd(i,m,n) for(int i=(n)-1;i>=(m);--i) #define rep0(i,n) for(i=0;i<(n);++i) #define repn0(i,m,n) for(i=(m);i<(n);++i) #define repd0(i,n) for(i=(n)-1;i>=0;--i) #define repnd0(i,m,n) for(i=(n)-1;i>=(m);--i) #define repc(i,n) for(int i=0;i<=(n);++i) #define repcn(i,m,n) for(int i=(m);i<=(n);++i) #define repcd(i,n) for(int i=(n);i>=0;--i) #define repcnd(i,m,n) for(int i=(n);i>=(m);--i) #define repc0(i,n) for(i=0;i<=(n);++i) #define repcn0(i,m,n) for(i=(m);i<=(n);++i) #define repcd0(i,n) for(i=(n);i>=0;--i) #define repcnd0(i,m,n) for(i=(n);i>=(m);--i) #define all(n) n.begin(),n.end() #define sz(n) ((int)(n).size()) #define IL for(;;) #define MP make_pair #define PB push_back #define X second #define Y first #define p_queue(n) priority_queue<n,vector<n>,greater<n> > #define PUTLINE cout<<"LINE:"<<__LINE__<<endl; const int INF = 2147483647/3; const double EPS = 1e-10; const double PI = acos(-1.0); const int dx[]={1,-1,0,0,1,1,-1,-1,0}; const int dy[]={0,0,1,-1,1,-1,1,-1,0}; int main() { int n; cin >> n; rep (iii, n) { int x = 0, y = 0; int resx = 0, resy = 0, dis = 0; int dx, dy; IL { cin >> dx >> dy; if (dx == 0 && dy == 0) break; x += dx; y += dy; if (dis < x * x + y * y || dis == x * x + y * y && resx < x) { resx = x; resy = y; dis = x * x + y * y; } } cout << resx << " " << resy << endl; } return 0; }
main.c:1:9: fatal error: cstdio: No such file or directory 1 | #include<cstdio> | ^~~~~~~~ compilation terminated.
s255104465
p00700
C++
#include <iostream> #include <algorithm> using namespace std; int n, dx, dy; int main() { cin >> n; for(int i = 0; i < n; i++) { int x = 0, y = 0, px = 0, py = 0; while(cin >> dx >> dy, dx | dy) { x += dx, y += dy; if((10000LL * (px * px + py * py) + px) < 10000LL * (x * x + y * y) + x)) px = x, py = y; } cout << px << ' ' << py << endl; } }
a.cc: In function 'int main()': a.cc:11:97: error: expected primary-expression before ')' token 11 | if((10000LL * (px * px + py * py) + px) < 10000LL * (x * x + y * y) + x)) px = x, py = y; | ^
s750620929
p00700
C++
#include <iostream> #include <cmath> using namespace std; int main(){ int n, dx, dy; int px, py; long long int mdis, dis; int mpx, mpy; cin>> n; for(int i = 0;i < n;i++){ px = py = 0; mdis = 0; do{ cin >> dx >> dy; px += dx; py += dy; dis = pow(px,2)+pow(py,2); if( mdis < dis){ mpx = px;mpy = py; mdis = dis; } }while(dx||dy); cout << mpx << " " << mpy << endl; } return 0;
a.cc: In function 'int main()': a.cc:27:12: error: expected '}' at end of input 27 | return 0; | ^ a.cc:6:11: note: to match this '{' 6 | int main(){ | ^