submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s825248778
p00595
Java
import java.io.*; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String str1 = scan.next(); String str2 = scan.next(); if(Integer.parseInt(str1)>10000 || Integer.parseInt(str2)>10000) { System.out.println("??°??????100000????????§??\?????????????????????"); } System.out.println(getGreatest(Integer.parseInt(str1),Integer.parseInt(str2))); } public static int getGreatest(int a,int b) { int r; if(a<b) { int temp = a; a = b; b = temp; } while(b>0) { r = a % b; a = b; b = r; return r; } return 0; }
Main.java:13: error: illegal escape character System.out.println("?????????100000???????????\?????????????????????"); ^ Main.java:39: error: reached end of file while parsing } ^ 2 errors
s474810024
p00595
Java
import java.io.*; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String str1 = scan.next(); String str2 = scan.next(); if(Integer.parseInt(str1)>10000 || Integer.parseInt(str2)>10000) { System.out.println("??°??????100000????????§??\?????????????????????"); } System.out.println(getGreatest(Integer.parseInt(str1),Integer.parseInt(str2))); } public static int getGreatest(int a,int b) { int r; if(a<b) { int temp = a; a = b; b = temp; } while(b>0) { r = a % b; a = b; b = r; return r; } return 0; }
Main.java:13: error: illegal escape character System.out.println("?????????100000???????????\?????????????????????"); ^ Main.java:39: error: reached end of file while parsing } ^ 2 errors
s408499823
p00595
Java
class Main { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); StringTokenizer st = new StringTokenizer(line, " "); while(line != "") { int x = Integer.parseInt(st.nextToken()); int y = Integer.parseInt(st.nextToken()); if(x < y) { x = x + y; y = x - y; x = x - y; } while(y > 0) { int r = x % y; x = y; y = r; } System.out.println(x); } } catch (Exception e) { e.printStackTrace(); } }
Main.java:29: error: reached end of file while parsing } ^ 1 error
s857927290
p00595
Java
public class Main{ public static void main(String[] args) throws IOException{ InputStreamReader inputStreamReader = new InputStreamReader(System.in); BufferedReader bufferedReader = new BufferedReader(inputStreamReader); StringBuilder stringBuilder = new StringBuilder(); while(true){ String dataSet = bufferedReader.readLine(); if(dataSet.length()==0) break; String[] dataList = dataSet.split(" "); int x = Integer.parseInt(dataList[0]); int y = Integer.parseInt(dataList[1]); if(x>y){ stringBuilder.append(gcd(x, y) + "\n"); }else stringBuilder.append(gcd(y, x) + "\n"); } System.out.print(stringBuilder); } static int gcd(int x, int y){ if(y==0){ return x; }else{ return gcd(y, x%y); } } }
Main.java:3: error: cannot find symbol public static void main(String[] args) throws IOException{ ^ symbol: class IOException location: class Main Main.java:4: error: cannot find symbol InputStreamReader inputStreamReader = new InputStreamReader(System.in); ^ symbol: class InputStreamReader location: class Main Main.java:4: error: cannot find symbol InputStreamReader inputStreamReader = new InputStreamReader(System.in); ^ symbol: class InputStreamReader location: class Main Main.java:5: error: cannot find symbol BufferedReader bufferedReader = new BufferedReader(inputStreamReader); ^ symbol: class BufferedReader location: class Main Main.java:5: error: cannot find symbol BufferedReader bufferedReader = new BufferedReader(inputStreamReader); ^ symbol: class BufferedReader location: class Main 5 errors
s640318000
p00595
Java
class Main { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); System.out.println(getCubicOf(line)); } catch (Exception e) { e.printStackTrace(); } } /** * @param line * ??´??°x?????\??? * @return x???3??? */ private static long getCubicOf(String line) { long x = Long.parseLong(line); return (long)Math.pow(x, 3); } }
Main.java:5: error: cannot find symbol BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class Main Main.java:5: error: cannot find symbol BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class Main Main.java:5: error: cannot find symbol BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class InputStreamReader location: class Main 3 errors
s833133055
p00595
Java
class Main { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); StringTokenizer st = new StringTokenizer(line, " "); while(st.hasMoreTokens()) { int x = Integer.parseInt(st.nextToken()); int y = Integer.parseInt(st.nextToken()); if(x < y) { x = x + y; y = x - y; x = x - y; } while(y > 0) { int r = x % y; x = y; y = r; } System.out.println(x); } } catch (Exception e) { e.printStackTrace(); } } }
Main.java:4: error: cannot find symbol BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class Main Main.java:4: error: cannot find symbol BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class Main Main.java:4: error: cannot find symbol BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class InputStreamReader location: class Main Main.java:6: error: cannot find symbol StringTokenizer st = new StringTokenizer(line, " "); ^ symbol: class StringTokenizer location: class Main Main.java:6: error: cannot find symbol StringTokenizer st = new StringTokenizer(line, " "); ^ symbol: class StringTokenizer location: class Main 5 errors
s496414355
p00595
Java
class Main { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); StringTokenizer st = new StringTokenizer(line, " "); while(st.hasMoreTokens()) { int x = Integer.parseInt(st.nextToken()); int y = Integer.parseInt(st.nextToken()); if(x < y) { x = x + y; y = x - y; x = x - y; } while(y > 0) { int r = x % y; x = y; y = r; } System.out.println(x); } } catch (Exception e) { e.printStackTrace(); } } }
Main.java:4: error: cannot find symbol BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class Main Main.java:4: error: cannot find symbol BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class BufferedReader location: class Main Main.java:4: error: cannot find symbol BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); ^ symbol: class InputStreamReader location: class Main Main.java:6: error: cannot find symbol StringTokenizer st = new StringTokenizer(line, " "); ^ symbol: class StringTokenizer location: class Main Main.java:6: error: cannot find symbol StringTokenizer st = new StringTokenizer(line, " "); ^ symbol: class StringTokenizer location: class Main 5 errors
s576785499
p00595
Java
import java.io.*; import java.util.StringTokenizer; class Main { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader( System.in));// ??\???????????????????????? String line; int a, b, temp; int x = 0; while ((line = br.readLine()) != null) { StringTokenizer st = new StringTokenizer(line, " "); a = Integer.parseInt(st.nextToken()); b = Integer.parseInt(st.nextToken()); if (a < b) { temp = a; a = b; b = temp; } while (b != 0) { x = a % b; a = b; b = x; } } System.out.println(a); } catch (Exception e) { e.printStackTrace(); } } }
Main.java:28: error: variable a might not have been initialized System.out.println(a); ^ 1 error
s806781490
p00595
Java
import java.util.*; import java.math.*; public class GCD { static Scanner sc = new Scanner(System.in); static BigInteger a,b; public static void main(String[] args) { while(read()){ solve(); } } static boolean read(){ if(!sc.hasNext()) return false; a = sc.nextBigInteger(); b = sc.nextBigInteger(); return true; } static void solve(){ System.out.println(a.gcd(b)); } }
Main.java:3: error: class GCD is public, should be declared in a file named GCD.java public class GCD { ^ 1 error
s514603332
p00595
Java
import java.util.Scanner; public class Main { public static int gcd(int a, int b){ int r; if(b > a){ int t = a; a = b; b = t; } while((r = a % b) != 0){ a = b; b = r; } return b; } public static void main(String[] args) {a Scanner sc = new Scanner(System.in); while(sc.hasNext()){ System.out.println(gcd(sc.nextInt(), sc.nextInt())); } } }
Main.java:23: error: ';' expected Scanner sc = new Scanner(System.in); ^ 1 error
s810315296
p00595
C
#include <cstdio> #include <algorithm> using namespace std; int main() { int m,n; scanf("%d %d", &m, &n); if(m < n) swap(m,n); while(n != 0){ int t=n; n = m%n; m = t; } printf("%d\n", m); return (0); }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s364518306
p00595
C
#include <stdio.h> int gcd(int a, int b) { if (b == 0) return 0; return gcd(b, a % b); } int main(void) { int a, b; while (scanf("%d %d", &a, &b) != EOF){ printf("%d\n", gcd(a, b); } return 0; }
main.c: In function 'main': main.c:14:41: error: expected ')' before ';' token 14 | printf("%d\n", gcd(a, b); | ~ ^ | ) main.c:14:42: error: expected ';' before '}' token 14 | printf("%d\n", gcd(a, b); | ^ | ; 15 | } | ~
s781995885
p00595
C
include<stdio.h> int gcd(int a,int b) { if(b==0) return a; else return gcd(b,a%b); } int main() { int a,b; while(scanf("%d%d",&a,&b)!=EOF){ printf("%d\n",gcd(a,b)); } return 0; }
main.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 1 | include<stdio.h> | ^ main.c: In function 'main': main.c:13:7: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 13 | while(scanf("%d%d",&a,&b)!=EOF){ | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | include<stdio.h> main.c:13:7: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 13 | while(scanf("%d%d",&a,&b)!=EOF){ | ^~~~~ main.c:13:7: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:13:28: error: 'EOF' undeclared (first use in this function) 13 | while(scanf("%d%d",&a,&b)!=EOF){ | ^~~ main.c:13:28: note: 'EOF' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>' main.c:13:28: note: each undeclared identifier is reported only once for each function it appears in main.c:14:1: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 14 | printf("%d\n",gcd(a,b)); | ^~~~~~ main.c:14:1: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:14:1: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:14:1: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:14:15: error: implicit declaration of function 'gcd' [-Wimplicit-function-declaration] 14 | printf("%d\n",gcd(a,b)); | ^~~
s025821488
p00595
C
include<stdio.h> int gcd(int a,int b) { if(b==0) return a; else return gcd(b,a%b); } int main(void) { int a,b; while(scanf("%d%d",&a,&b)!=EOF){ printf("%d\n",gcd(a,b)); } return 0; }
main.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 1 | include<stdio.h> | ^ main.c: In function 'main': main.c:14:7: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 14 | while(scanf("%d%d",&a,&b)!=EOF){ | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | include<stdio.h> main.c:14:7: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 14 | while(scanf("%d%d",&a,&b)!=EOF){ | ^~~~~ main.c:14:7: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:14:28: error: 'EOF' undeclared (first use in this function) 14 | while(scanf("%d%d",&a,&b)!=EOF){ | ^~~ main.c:14:28: note: 'EOF' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>' main.c:14:28: note: each undeclared identifier is reported only once for each function it appears in main.c:15:1: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 15 | printf("%d\n",gcd(a,b)); | ^~~~~~ main.c:15:1: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:15:1: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:15:1: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:15:15: error: implicit declaration of function 'gcd' [-Wimplicit-function-declaration] 15 | printf("%d\n",gcd(a,b)); | ^~~
s319985241
p00595
C
}#include<stdio.h> int main() { int a,b,c; while(scanf("%d %d",&a,&b)!=EOF) { while(c=a%b) { a=b; b=c; } printf("%d\n",b); } return 0; }
main.c:2:1: error: expected identifier or '(' before '}' token 2 | }#include<stdio.h> | ^ main.c:2:2: error: stray '#' in program 2 | }#include<stdio.h> | ^ main.c:2:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 2 | }#include<stdio.h> | ^
s106875788
p00595
C
}#include<stdio.h> int main() { int a,b,c; while(scanf("%d %d",&a,&b)!=EOF) { while(c=a%b) { b=c; } printf("%d\n",b); } return 0; }
main.c:2:1: error: expected identifier or '(' before '}' token 2 | }#include<stdio.h> | ^ main.c:2:2: error: stray '#' in program 2 | }#include<stdio.h> | ^ main.c:2:10: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 2 | }#include<stdio.h> | ^
s889349801
p00595
C
#include<iostream> using namespace std; int gcd(int x, int y) { if (y == 0) return x; else return gcd(y, x % y); } int main(){ int a, b; while( scanf("%d %d", &a, &b) != EOF ){ cout<<gcd(a,b)<<endl; } return 0; }
main.c:1:9: fatal error: iostream: No such file or directory 1 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s802895017
p00595
C
#include <stdio.h> long gcd_euclid(long m, long n) { long tmp; while (n) { temp = m % n; m = n; n = tmp; } return m; } int main(){ long a, b; long tmp; long gcd; while(scanf("%ld %ld", &a, &b)!=EOF){ gcd = gcd_euclid(a, b); temp = a / gcd; printf("%ld %ld\n", gcd, lcm); } return 0; }
main.c: In function 'gcd_euclid': main.c:6:9: error: 'temp' undeclared (first use in this function); did you mean 'tmp'? 6 | temp = m % n; m = n; n = tmp; | ^~~~ | tmp main.c:6:9: note: each undeclared identifier is reported only once for each function it appears in main.c: In function 'main': main.c:15:9: error: 'temp' undeclared (first use in this function); did you mean 'tmp'? 15 | temp = a / gcd; | ^~~~ | tmp main.c:17:34: error: 'lcm' undeclared (first use in this function) 17 | printf("%ld %ld\n", gcd, lcm); | ^~~
s431466380
p00595
C
using namespace std; int main(void){ int a,b,tmp; while(cin>>a>>b){ if(a<b) swap(a,b); while(1){ if(a%b==0) break; tmp = a%b; a = b; b = tmp; } cout<<b<<endl; } return 0; }
main.c:1:1: error: unknown type name 'using' 1 | using namespace std; | ^~~~~ main.c:1:17: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'std' 1 | using namespace std; | ^~~ main.c: In function 'main': main.c:6:9: error: 'cin' undeclared (first use in this function) 6 | while(cin>>a>>b){ | ^~~ main.c:6:9: note: each undeclared identifier is reported only once for each function it appears in main.c:7:13: error: implicit declaration of function 'swap' [-Wimplicit-function-declaration] 7 | if(a<b) swap(a,b); | ^~~~ main.c:16:5: error: 'cout' undeclared (first use in this function) 16 | cout<<b<<endl; | ^~~~ main.c:16:14: error: 'endl' undeclared (first use in this function) 16 | cout<<b<<endl; | ^~~~
s790055238
p00595
C
include<stdio.h> int main(){ int x,y,c,h; while(scanf("%d%d",&x,&y)!=EOF) { while(y!=0) { x=x%y; h=x; x=y; y=h; } printf("%d\n",x); } return 0; }
main.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 1 | include<stdio.h> | ^
s712352273
p00595
C
include<stdio.h> int main(){ int x,y,c,h; while(scanf("%d%d",&x,&y)!=EOF) { while(y!=0) { x=x%y; h=x; x=y; y=h; } printf("%d\n",x); } return 0; }
main.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 1 | include<stdio.h> | ^
s819613063
p00595
C
main(a,b){while(~scanf("%d%d",&a,&b))printf("%d\n",__gcd(a,b));}
main.c:1:1: error: return type defaults to 'int' [-Wimplicit-int] 1 | main(a,b){while(~scanf("%d%d",&a,&b))printf("%d\n",__gcd(a,b));} | ^~~~ main.c: In function 'main': main.c:1:1: error: type of 'a' defaults to 'int' [-Wimplicit-int] main.c:1:1: error: type of 'b' defaults to 'int' [-Wimplicit-int] main.c:1:18: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | main(a,b){while(~scanf("%d%d",&a,&b))printf("%d\n",__gcd(a,b));} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | main(a,b){while(~scanf("%d%d",&a,&b))printf("%d\n",__gcd(a,b));} main.c:1:18: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | main(a,b){while(~scanf("%d%d",&a,&b))printf("%d\n",__gcd(a,b));} | ^~~~~ main.c:1:18: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:38: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 1 | main(a,b){while(~scanf("%d%d",&a,&b))printf("%d\n",__gcd(a,b));} | ^~~~~~ main.c:1:38: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:38: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:1:38: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:1:52: error: implicit declaration of function '__gcd' [-Wimplicit-function-declaration] 1 | main(a,b){while(~scanf("%d%d",&a,&b))printf("%d\n",__gcd(a,b));} | ^~~~~
s342366415
p00595
C
//import java.io.*; import java.util.*; //import java.math.*; public class Main { public static void main(String[] args) throws java.io.IOException{ Scanner scan = new Scanner(System.in); while(scan.hasNext()){ System.out.println(gcd(scan.nextInt(),scan.nextInt())); } } public static int gcd(int a,int b){ if(b==0)return a; return gcd(b,a%b); } }
main.c:2:1: error: unknown type name 'import' 2 | import java.util.*; | ^~~~~~ main.c:2:12: error: expected '=', ',', ';', 'asm' or '__attribute__' before '.' token 2 | import java.util.*; | ^ main.c:4:1: error: unknown type name 'public' 4 | public class Main { | ^~~~~~ main.c:4:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'Main' 4 | public class Main { | ^~~~
s528414142
p00595
C
#include<stdio.h> main(){ int n,m,i,r; while(scanf("%d %d",&n,&m)!=EOF){ if(m<n){ i=n;n=m;m=i; } while(1){ if(n==0){ printf("%d\n",m); break; } r=n; n=m%n; m=r; } } return 0; } } return 0; }
main.c:2:1: error: return type defaults to 'int' [-Wimplicit-int] 2 | main(){ | ^~~~ main.c:21:1: error: expected identifier or '(' before '}' token 21 | } | ^ main.c:22:3: error: expected identifier or '(' before 'return' 22 | return 0; | ^~~~~~ main.c:23:1: error: expected identifier or '(' before '}' token 23 | } | ^
s789087635
p00595
C++
#include <iostream> #include <algorithm> using namespace std; int main(void){ int a,b; whilecin>>a>>b) cout<<__gcd(a,b)<<endl; }
a.cc: In function 'int main()': a.cc:7:9: error: 'whilecin' was not declared in this scope 7 | whilecin>>a>>b) | ^~~~~~~~
s213290628
p00595
C++
#include <iostream> int main(){ int x,y; cin >> x >> y; while(x != y){ if(x > y)x = x - y; if(y > x)y = y - x; } cout << x; }
a.cc: In function 'int main()': a.cc:7:1: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 7 | cin >> x >> y; | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~ a.cc:13:1: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 13 | cout << x; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~
s853372903
p00595
C++
#include <stdio.h> int main(){ int x,y; int byakko(int x, inty){ x > y ? return x % y : return y % x; } while(scanf("%d %d", &x, &y)){ cout << byakko(x, y) << endl; } }
a.cc: In function 'int main()': a.cc:6:19: error: 'inty' has not been declared 6 | int byakko(int x, inty){ | ^~~~ a.cc:6:24: error: a function-definition is not allowed here before '{' token 6 | int byakko(int x, inty){ | ^ a.cc:11:1: error: 'cout' was not declared in this scope 11 | cout << byakko(x, y) << endl; | ^~~~ a.cc:11:9: error: 'byakko' was not declared in this scope 11 | cout << byakko(x, y) << endl; | ^~~~~~ a.cc:11:25: error: 'endl' was not declared in this scope 11 | cout << byakko(x, y) << endl; | ^~~~
s722464521
p00595
C++
#include <stdio.h> int main(){ int x,y; int byakko(int x, inty){ if(x > y) return x % y; else return y % x; return x; } while(scanf("%d %d", &x, &y)){ cout << byakko(x, y) << endl; } }
a.cc: In function 'int main()': a.cc:6:19: error: 'inty' has not been declared 6 | int byakko(int x, inty){ | ^~~~ a.cc:6:24: error: a function-definition is not allowed here before '{' token 6 | int byakko(int x, inty){ | ^ a.cc:16:1: error: 'cout' was not declared in this scope 16 | cout << byakko(x, y) << endl; | ^~~~ a.cc:16:9: error: 'byakko' was not declared in this scope 16 | cout << byakko(x, y) << endl; | ^~~~~~ a.cc:16:25: error: 'endl' was not declared in this scope 16 | cout << byakko(x, y) << endl; | ^~~~
s441001606
p00595
C++
#include <stdio.h> int main(){ int x,y; while(cin >> x >> y){ while(x % y != 0){ if(x > y) x = x % y; } cout << x << endl; } }
a.cc: In function 'int main()': a.cc:6:7: error: 'cin' was not declared in this scope 6 | while(cin >> x >> y){ | ^~~ a.cc:12:1: error: 'cout' was not declared in this scope 12 | cout << x << endl; | ^~~~ a.cc:12:14: error: 'endl' was not declared in this scope 12 | cout << x << endl; | ^~~~
s048591818
p00595
C++
#include<bits/stdc++.h> main(a,b){while(~scanf("%d%d",&a,&b)){printf("%d\n",std::__gcd(a,b));}}
a.cc:2:5: error: expected constructor, destructor, or type conversion before '(' token 2 | main(a,b){while(~scanf("%d%d",&a,&b)){printf("%d\n",std::__gcd(a,b));}} | ^
s485039929
p00595
C++
#include<algorithm> int a,b;main(){while(~scanf("%d%d",&a,&b);printf("%d\n",std::__gcd(a,b)));}}
a.cc:2:9: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 2 | int a,b;main(){while(~scanf("%d%d",&a,&b);printf("%d\n",std::__gcd(a,b)));}} | ^~~~ a.cc: In function 'int main()': a.cc:2:23: error: 'scanf' was not declared in this scope 2 | int a,b;main(){while(~scanf("%d%d",&a,&b);printf("%d\n",std::__gcd(a,b)));}} | ^~~~~ a.cc:2:42: error: expected ')' before ';' token 2 | int a,b;main(){while(~scanf("%d%d",&a,&b);printf("%d\n",std::__gcd(a,b)));}} | ~ ^ | ) a.cc:2:43: error: 'printf' was not declared in this scope 2 | int a,b;main(){while(~scanf("%d%d",&a,&b);printf("%d\n",std::__gcd(a,b)));}} | ^~~~~~ a.cc:2:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' 1 | #include<algorithm> +++ |+#include <cstdio> 2 | int a,b;main(){while(~scanf("%d%d",&a,&b);printf("%d\n",std::__gcd(a,b)));}} a.cc: At global scope: a.cc:2:76: error: expected declaration before '}' token 2 | int a,b;main(){while(~scanf("%d%d",&a,&b);printf("%d\n",std::__gcd(a,b)));}} | ^
s458131636
p00595
C++
#include "bits/stdc++" using namespace std; int main() { int a, b; while (cin >> a >> b){ cout << max(a, b) - min(a, b) < endl; }
a.cc:1:10: fatal error: bits/stdc++: No such file or directory 1 | #include "bits/stdc++" | ^~~~~~~~~~~~~ compilation terminated.
s491313520
p00595
C++
#include "bits/stdc++.h" using namespace std; int main() { int a, b; while (cin >> a >> b){ cout << max(a, b) - min(a, b) < endl; }
a.cc: In function 'int main()': a.cc:8:31: error: no match for 'operator<' (operand types are 'std::basic_ostream<char>' and '<unresolved overloaded function type>') 8 | cout << max(a, b) - min(a, b) < endl; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: a.cc:8:33: note: couldn't deduce template parameter '_Bi_iter' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: a.cc:8:33: note: couldn't deduce template parameter '_Bi_iter' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::pair<_T1, _T2>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: a.cc:8:33: note: couldn't deduce template parameter '_CharT' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _All
s029541723
p00595
C++
#include "bits/stdc++.h" using namespace std; int main() { int a, b; while (cin >> a >> b){ cout << max(a, b) - min(a, b) < endl; } }
a.cc: In function 'int main()': a.cc:8:31: error: no match for 'operator<' (operand types are 'std::basic_ostream<char>' and '<unresolved overloaded function type>') 8 | cout << max(a, b) - min(a, b) < endl; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ In file included from /usr/include/c++/14/regex:68, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181, from a.cc:1: /usr/include/c++/14/bits/regex.h:1143:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const sub_match<_BiIter>&)' 1143 | operator<(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1143:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)' 1224 | operator<(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1224:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator<(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)' 1317 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1317:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)' 1391 | operator<(typename iterator_traits<_Bi_iter>::value_type const* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1391:5: note: template argument deduction/substitution failed: a.cc:8:33: note: couldn't deduce template parameter '_Bi_iter' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)' 1485 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1485:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)' 1560 | operator<(typename iterator_traits<_Bi_iter>::value_type const& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1560:5: note: template argument deduction/substitution failed: a.cc:8:33: note: couldn't deduce template parameter '_Bi_iter' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator<(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)' 1660 | operator<(const sub_match<_Bi_iter>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/regex.h:1660:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::sub_match<_BiIter>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::pair<_T1, _T2>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::reverse_iterator<_Iterator>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::move_iterator<_IteratorL>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ In file included from /usr/include/c++/14/bits/basic_string.h:47, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/string_view:673:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, basic_string_view<_CharT, _Traits>)' 673 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:673:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/string_view:680:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(basic_string_view<_CharT, _Traits>, __type_identity_t<basic_string_view<_CharT, _Traits> >)' 680 | operator< (basic_string_view<_CharT, _Traits> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:680:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'std::basic_string_view<_CharT, _Traits>' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/string_view:688:5: note: candidate: 'template<class _CharT, class _Traits> constexpr bool std::operator<(__type_identity_t<basic_string_view<_CharT, _Traits> >, basic_string_view<_CharT, _Traits>)' 688 | operator< (__type_identity_t<basic_string_view<_CharT, _Traits>> __x, | ^~~~~~~~ /usr/include/c++/14/string_view:688:5: note: template argument deduction/substitution failed: a.cc:8:33: note: couldn't deduce template parameter '_CharT' 8 | cout << max(a, b) - min(a, b) < endl; | ^~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> bool std::operator<(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3874 | operator<(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3874:5: note: template argument deduction/substitution failed: a.cc:8:33: note: 'std::basic_ostream<char>' is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _All
s545027328
p00595
C++
#include <iostream> #include<math.h> #include<iomanip> #include<vector> #include<algorithm> #include<functional> using namespace std; int main() { int a=0;b=0; while(cin >> a >> b){ int c=0; if(a<b){ swap(a,b); } while(b>0){ c = a%b; a=b; b=c; } cout << a; cout << endl; } }
a.cc: In function 'int main()': a.cc:11:13: error: 'b' was not declared in this scope 11 | int a=0;b=0; | ^
s921513251
p00595
C++
#include<iostream> using namespace std; int euclid(int n, int m); int main(){ int n,m; while(cin>>n>>m){ cout <<euclid(n,m<<endl; } } int euclid(int n,int m){ if(n<m){ int temp; temp=m; m=n; n=temp; } if(n%m==0){ return m; }else{ return euclid(m,n%m); } }
a.cc: In function 'int main()': a.cc:9:22: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<' 9 | cout <<euclid(n,m<<endl; | ~^~~~~~
s923889976
p00595
C++
#include <stdio.h> int gcd(int a,int b){ if(b==0)return a; return gcd(b,a%b); } int main(){ int a,b; while(scanf("%d%d",&a,&b)!=EOF){ printf("%d\n",gcd(a,b); }
a.cc: In function 'int main()': a.cc:9:23: error: expected ')' before ';' token 9 | printf("%d\n",gcd(a,b); | ~ ^ | ) a.cc:10:2: error: expected '}' at end of input 10 | } | ^ a.cc:6:11: note: to match this '{' 6 | int main(){ | ^
s661513294
p00595
C++
#include <stdio.h> int gcd(int a,int b){ if(b==0)return a; return gcd(b,a%b); } int main(){ int a,b; while(scanf("%d%d",&a,&b)!=EOF){ printf("%d\n",gcd(a,b); } }
a.cc: In function 'int main()': a.cc:9:23: error: expected ')' before ';' token 9 | printf("%d\n",gcd(a,b); | ~ ^ | )
s195617619
p00595
C++
??????
a.cc:1:1: error: expected unqualified-id before '?' token 1 | ?????? | ^
s536359605
p00595
C++
package com.practice.takuya._1009; import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line = br.readLine(); System.out.println(getGreatestCommonDivisor(line)); } catch (Exception e) { e.printStackTrace(); } } private static int getGreatestCommonDivisor(String line) { String[] splitedArray = line.split(" ", 0); int x = Integer.valueOf(splitedArray[0]).intValue(); int y = Integer.valueOf(splitedArray[1]).intValue(); if(x < y) { swap(x, y); } if(y == 0) { return 0; } while(x % y != 0) { int temp = x % y; x = y; y = temp; } return y; } private static void swap(int x, int y) { int temp = x; y = x; x = temp; } }
a.cc:1:1: error: 'package' does not name a type 1 | package com.practice.takuya._1009; | ^~~~~~~ a.cc:3:1: error: 'import' does not name a type 3 | import java.io.BufferedReader; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.io.InputStreamReader; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:9:1: error: expected unqualified-id before 'public' 9 | public class Main { | ^~~~~~
s494392064
p00595
C++
int gcd(a,b){return b?gcd(b,a%b):a;} main(a,b){while(~scanf("%d%d",&a,&b))printf("%d\n",gcd(a,b));}
a.cc:1:9: error: 'a' was not declared in this scope 1 | int gcd(a,b){return b?gcd(b,a%b):a;} | ^ a.cc:1:11: error: 'b' was not declared in this scope 1 | int gcd(a,b){return b?gcd(b,a%b):a;} | ^ a.cc:1:12: error: expression list treated as compound expression in initializer [-fpermissive] 1 | int gcd(a,b){return b?gcd(b,a%b):a;} | ^ a.cc:2:5: error: expected constructor, destructor, or type conversion before '(' token 2 | main(a,b){while(~scanf("%d%d",&a,&b))printf("%d\n",gcd(a,b));} | ^
s693219705
p00595
C++
#include <iostream> using namespace std; int main(int argc, char **argv) { int *a, *b, s, t, c; int p, q; a = &p; b = &q; while(cin >> p >> q){ s = *a; t = *b; c = 1; for(int tmp = (*a > *b)? *b : *a, i = 2; i <= tmp; i++){ while(s%i == 0 && t%i == 0){ s /= i; t /= i; tmp /= i; c *= i; } } cout << c << " " << endl; return 0; }
a.cc: In function 'int main(int, char**)': a.cc:25:2: error: expected '}' at end of input 25 | } | ^ a.cc:6:1: note: to match this '{' 6 | { | ^
s957247757
p00595
C++
#include <cstdio> int solve(int a, int b) { if (a%b==0) return a; return solve(b,a%b); } int main() { int a,b; while(scanf("%d %d",&a,&b)!=EOF) int res=solve(a,b); printf("%d\n",res); }
a.cc: In function 'int main()': a.cc:8:76: error: 'res' was not declared in this scope 8 | while(scanf("%d %d",&a,&b)!=EOF) int res=solve(a,b); printf("%d\n",res); | ^~~
s204320992
p00595
C++
main(a,b){while(~scanf("%d%d",&a,&b))printf("%d\n",__gcd(a,b));}
a.cc:1:5: error: expected constructor, destructor, or type conversion before '(' token 1 | main(a,b){while(~scanf("%d%d",&a,&b))printf("%d\n",__gcd(a,b));} | ^
s792040613
p00595
C++
#include <iostream> ing main() { long int a, b, i, maks; cin >> a >> b; if (a > b) maks = a; else maks = b; for (i=2;i<=maks;i++) if (maks % a == 0 && maks % b == 0) { cout << i << endl; break; } return 0; }
a.cc:2:1: error: 'ing' does not name a type; did you mean 'int'? 2 | ing main() | ^~~ | int
s063549544
p00595
C++
#include <iostream> using namespace std; ing main() { long int a, b, i, maks; cin >> a >> b; if (a > b) maks = a; else maks = b; for (i=2;i<=maks;i++) if (maks % a == 0 && maks % b == 0) { cout << i << endl; break; } return 0; }
a.cc:3:1: error: 'ing' does not name a type; did you mean 'int'? 3 | ing main() | ^~~ | int
s500396141
p00595
C++
#include<iostream> #include<stdio.h> #include<cmath> #define INF 9999999 using namespace std; int a,b,c; int main(){ while(cin>>a>>b){ while(b!=0){ c=a%b; a=b; b=c; } cout<<a<<endl; } return 0
a.cc: In function 'int main()': a.cc:16:17: error: expected ';' at end of input 16 | return 0 | ^ | ; a.cc:16:17: error: expected '}' at end of input a.cc:7:11: note: to match this '{' 7 | int main(){ | ^
s914884598
p00595
C++
#include <iostream> #include <vector> using namespace std; int get(int, int); int main(int argc, char *argv[]) { int x, y; while (cin >> x >> y) cout << getLCM(x, y) << endl; return 0; } int get(int x, int y) { int tmp; if (x < y) { tmp = y; y = x; x = tmp; } while (x % y != 0) { tmp = x % y; x = y; y = tmp; } return y; }
a.cc: In function 'int main(int, char**)': a.cc:12:13: error: 'getLCM' was not declared in this scope 12 | cout << getLCM(x, y) << endl; | ^~~~~~
s829991592
p00595
C++
int gcd( int m, int n ) { // 引数に0がある場合は0を返す if ( ( 0 == m ) || ( 0 == n ) ) return 0; // ユークリッドの方法 while( m != n ) { if ( m > n ) m = m - n; else n = n - m; } return m; } int main(int argc, const char * argv[]) { //std::cout << "Hello World\n"; while(true){ int n, m; std::cin >> n >> m; //std::cout << n << "," << m << "\n"; std::cout << gcd(n, m) << "\n"; } return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:21:14: error: 'cin' is not a member of 'std' 21 | std::cin >> n >> m; | ^~~ a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' +++ |+#include <iostream> 1 | int gcd( int m, int n ) a.cc:23:14: error: 'cout' is not a member of 'std' 23 | std::cout << gcd(n, m) << "\n"; | ^~~~ a.cc:23:14: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
s546233380
p00595
C++
int gcd( int m, int n ) { // 引数に0がある場合は0を返す if ( ( 0 == m ) || ( 0 == n ) ) return 0; // ユークリッドの方法 while( m != n ) { if ( m > n ) m = m - n; else n = n - m; } return m; }//gcd int main(int argc, const char * argv[]) { int n; while(cin >> n){ //std::cout << n << "," << m << "\n"; } return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:19:11: error: 'cin' was not declared in this scope 19 | while(cin >> n){ | ^~~
s318065204
p00595
C++
int gcd( int m, int n ){ // 引数に0がある場合は0を返す if ( ( 0 == m ) || ( 0 == n ) ) return 0; // ユークリッドの方法 while( m != n ) { if ( m > n ) m = m - n; else n = n - m; } return m; }; int main(int argc, const char * argv[]) { int n, m; while(cin >> n >> m){ //std::cout << n << "," << m << "\n"; cout << gcd(m, n); } return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:18:11: error: 'cin' was not declared in this scope 18 | while(cin >> n >> m){ | ^~~ a.cc:20:9: error: 'cout' was not declared in this scope 20 | cout << gcd(m, n); | ^~~~
s685191640
p00595
C++
#include<iostream> using namespace std; int main(){ int a,b; while(cin>>a>>b){ if(a<b)swap(a,b); while(b){ a=a%b; swap(a,b); } cout<<a<<endl; }
a.cc: In function 'int main()': a.cc:12:2: error: expected '}' at end of input 12 | } | ^ a.cc:3:11: note: to match this '{' 3 | int main(){ | ^
s238266606
p00595
C++
#include <cstdlib> #include <iostream> using namespace std; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); for(int a, b; cin >> a >> b;) { cout << __gcd(a, b) << endl; } return EXIT_SUCCESS; }
a.cc: In function 'int main()': a.cc:10:25: error: '__gcd' was not declared in this scope 10 | cout << __gcd(a, b) << endl; | ^~~~~
s629208132
p00596
C
#include <iostream> #include <fstream> #include <cstdio> #include <cmath> #include <vector> #include <cstring> #include <string> #include <set> #include <map> #include <stack> #include <queue> #include <algorithm> using namespace std; #define REP(i,n) for(int i=0; i<n; ++i) #define FOR(i,a,b) for(int i=a; i<=b; ++i) #define FORR(i,a,b) for (int i=a; i>=b; --i) #define ALL(c) (c).begin(), (c).end() typedef long long ll; typedef vector<int> VI; typedef vector<ll> VL; typedef vector<VI> VVI; typedef vector<VL> VVL; typedef pair<int,int> P; typedef pair<ll,ll> PL; bool check(VI a, VI b){ int n = a.size(); int m = 7; REP(i,n) cout << a[i] << b[i] << endl; VVI dp(1<<n, VI(m)); REP(i,n){ dp[1<<i][b[i]] = 1; dp[1<<i][a[i]] = 1; } FOR(i,1,(1<<n)-1) REP(j,m){ if (dp[i][j] == 0) continue; REP(k,n){ if ((i >> k) & 1) continue; if (a[k] == j) dp[i | (1<<k)][b[k]] = 1; if (b[k] == j) dp[i | (1<<k)][a[k]] = 1; } } REP(j,m){ if (dp[(1<<n)-1][j] == 1) return true; } return false; } int main(){ int n; while (scanf("%d", &n)){ VI a(n), b(n); REP(i,n){ string x; cin >> x; a[i] = x[0] - '0'; b[i] = x[1] - '0'; } cout << (check(a, b) ? "Yes" : "No") << endl; } return 0; }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s587181432
p00596
C
#include <iostream> #include <string> using namespace std; int main() { int n; while (cin >> n) { int a[7] = {0}; string s; for (int i=0; i<n; i++) { cin >> s; a[s[0]-'0']++; a[s[1]-'0']++; } int odd=0; for (int i=0; i<7; i++) if (a[i]%2) odd++; cout << ((odd==0||odd==2) ? "Yes" : "No") << endl; } }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s591369777
p00596
C++
#include <stdio.h> #include <cmath> #include <algorithm> #include <cfloat> #include <stack> #include <queue> #include <vector> #include <string> #include <iostream> typedef long long int ll; typedef unsigned long long int ull; #define BIG_NUM 2000000000 #define MOD 1000000007 #define EPS 0.000000001 using namespace std; int N; int boss[7],height[7]; int get_boss(int id){ if(boss[id] == id)return id; else{ return boss[id] = get_boss(boss[id]); } } int is_same(int x,int y){ return get_boss(x) == get_boss(y); } void unite(int x,int y){ int boss_x = get_boss(x); int boss_y = get_boss(y); if(boss_x == boss_y)return; if(height[x] > height[y]){ boss[boss_y] = boss_x; }else if(height[x] < height[y]){ boss[boss_x] = boss_y; }else{ //height[x] == height[y] boss[boss_y] = boss_x; height[x]++; } } void init(){ for(int i = 0; i < 7; i++){ boss[i] = i; height[i] = 0; } } int main(){ int array[7],num,num_KI,num_boss; char buf[3]; int a,b; while(scanf("%d",&N) != EOF){ init(); for(int i = 0; i < 7; i++)array[i] = 0; for(int i = 0; i < N; i++){ scanf("%s",buf); a = buf[0] - '0'; b = buf[1] - '0'; array[a]++; array[b]++; unite(a,b); } if(N == 1){ printf("Yes\n"); continue; } num_KI = 0; for(int i = 0; i < 7; i++){ if(array[i]%2 == 1)num_KI++; } if(num_KI != 0 && num_KI != 2){ printf("No\n"); continue; } num_boss = 0; for(int i = 0; i < 7; i++){ if(array[i] != 0){ if(boss[i] == get_boss[i])num_boss++; } } if(num_boss > 1){ printf("No\n"); continue; } printf("Yes\n"); } return 0; }
a.cc: In function 'int main()': a.cc:99:57: warning: pointer to a function used in arithmetic [-Wpointer-arith] 99 | if(boss[i] == get_boss[i])num_boss++; | ^ a.cc:99:44: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 99 | if(boss[i] == get_boss[i])num_boss++; | ~~~~~~~~^~~~~~~~~~~~~~
s329411303
p00596
C++
#include <stdio.h> #include <cmath> #include <algorithm> #include <cfloat> #include <stack> #include <queue> #include <vector> #include <string> #include <iostream> typedef long long int ll; typedef unsigned long long int ull; #define BIG_NUM 2000000000 #define MOD 1000000007 #define EPS 0.000000001 using namespace std; int N; int boss[7],height[7]; int get_boss(int id){ if(boss[id] == id)return id; else{ return boss[id] = get_boss(boss[id]); } } void unite(int x,int y){ int boss_x = get_boss(x); int boss_y = get_boss(y); if(boss_x == boss_y)return; if(height[x] > height[y]){ boss[boss_y] = boss_x; }else if(height[x] < height[y]){ boss[boss_x] = boss_y; }else{ //height[x] == height[y] boss[boss_y] = boss_x; height[x]++; } } void init(){ for(int i = 0; i < 7; i++){ boss[i] = i; height[i] = 0; } } int main(){ int array[7],num,num_KI,num_boss; char buf[3]; int a,b; bool FLG; while(scanf("%d",&N) != EOF){ init(); for(int i = 0; i < 7; i++)array[i] = 0; for(int i = 0; i < N; i++){ scanf("%s",buf); a = buf[0] - '0'; b = buf[1] - '0'; array[a]++; array[b]++; unite(a,b); } FLG = true; num_KI = 0; for(int i = 0; i < 7; i++)if(array[i]%2 == 1)num_KI++; if(num_KI > 2){ printf("No\n"); continue; } num_boss = 0; for(int i = 0; i < 7; i++){ if(array[i] > 0 && boss[i] == get_boss[i])num_boss++; } if(num_boss > 1)FLG = false; if(FLG){ printf("Yes\n"); }else{ printf("No\n"); } } return 0; }
a.cc: In function 'int main()': a.cc:90:65: warning: pointer to a function used in arithmetic [-Wpointer-arith] 90 | if(array[i] > 0 && boss[i] == get_boss[i])num_boss++; | ^ a.cc:90:52: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 90 | if(array[i] > 0 && boss[i] == get_boss[i])num_boss++; | ~~~~~~~~^~~~~~~~~~~~~~
s175858064
p00597
C++
include<iostream> using namespace std; int main(void){ while(true){ int n; cin>>n; if(cin.eof()) break; cout << (1 << (n-1)) << endl; } return 0; }
a.cc:1:1: error: 'include' does not name a type 1 | include<iostream> | ^~~~~~~ a.cc: In function 'int main()': a.cc:6:5: error: 'cin' was not declared in this scope 6 | cin>>n; | ^~~ a.cc:9:5: error: 'cout' was not declared in this scope 9 | cout << (1 << (n-1)) << endl; | ^~~~ a.cc:9:29: error: 'endl' was not declared in this scope 9 | cout << (1 << (n-1)) << endl; | ^~~~
s235906203
p00597
C++
/* AizuOnline A1011 Title */ #include <stdio.h> // Select Below //#include <stdlib.h> //#include <string.h> //#include <float.h> //#include <math.h> //#include <limits.h> //Global data section // int N; int expt3(int n) { if(n==0) return(1); else return(3 * expt3(n-1)); } int calc_carbon(int n) { int i,ret; ret=0; for(i=0;i<n;i++) ret += expt3(i); //printf("CC1:%d %d\n",n,ret); return(ret); } calcc(int n) { int i,ret; if(n==1) return(1); if(n==2) return(2); if(n % 2) { ret = 2*calc_carbon((n-1)/2); } else ret=0; for(i=0;i<(n-(n % 2))/2;i++) ret += 4*calc_carbon(i); return(ret+n); } main() { int ret; while(EOF != scanf("%d",&N)) { ret=calcc(N); printf("%d\n",ret); } return(0); }
a.cc:34:1: error: ISO C++ forbids declaration of 'calcc' with no type [-fpermissive] 34 | calcc(int n) | ^~~~~ a.cc:57:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 57 | main() | ^~~~
s477025277
p00598
Java
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); try { String line; while(true){ /* input from here */ if((line = r.readLine())==null){ break; } HashMap<String, Integer[]> sets = new HashMap<String, Integer[]>(); ArrayList<Integer> U = new ArrayList<Integer>(); while(true){ String[] str = line.split(" "); if(str[0].contains("R")){ break; } int n = Integer.parseInt(str[1]); Integer[] e = new Integer[n]; String[] line2 = r.readLine().split(" "); for(int i=0;i<n;i++){ e[i] = Integer.parseInt(line2[i]); if(!U.contains(e[i])) U.add((Integer)e[i]); } Arrays.sort(e); sets.put(str[0], e); line = r.readLine(); } Integer[] setU = U.toArray(new Integer[U.size()]); Arrays.sort(setU); sets.put("U", setU); String exp = r.readLine(); /* input till here */ /* parsing from here */ Expression e = parse(exp); /* parsing till here */ /* semantic analysis from here */ Integer[] res = calc(e,sets); /* semantic analysis till here */ /* output */ Arrays.sort(res); if(res.length>0){ for(int i=0;i<res.length-1;i++){ System.out.print(res[i]+ " "); } System.out.println(res[res.length-1]); } else { System.out.println("NULL"); } } } catch (IOException e) { e.printStackTrace(); } } public static Expression parse(String exp){ //single term if(exp.length()<=2){ Expression e = new Expression(exp); return e; } //2-term-operands String ops = "iuds"; String left = "", right = ""; int index = exp.length()-1; int level = 0; Expression e = null; boolean opfound = false; while(index>=0){ if(exp.charAt(index)==')'){ level++; } else if(exp.charAt(index)=='('){ level--; } if(level==0&&ops.indexOf(exp.substring(index,index+1))>-1){ char op = exp.charAt(index); left = exp.substring(0,index); right = exp.substring(index+1,exp.length()); e = new Expression(op, parse(left), parse(right)); opfound = true; break; } index--; } //single-term operand if(!opfound&&exp.charAt(0)=='c'){ e = null; if(exp.charAt(1)!='('){ e = new Expression('c',new Expression(exp.substring(1,2))); } else { index = 1; while(exp.charAt(index)!=')'){ index++; } String p = exp.substring(2,index); e = new Expression('c',parse(p)); } return e; } if(!opfound){ return parse(exp.substring(1,exp.length()-1)); } return e; } public static Integer[] calc(Expression e, HashMap<String, Integer[]> sets){ Integer[] res = new Integer[500]; ArrayList<Integer> reslist = new ArrayList<Integer>(); ArrayList<Integer> left = null; switch (e.op) { case 'c': Expression u = new Expression("U"); res = calc(new Expression('d',u,e.left),sets); break; case 'i': for(Integer i : calc(e.left, sets)){ for(Integer j :calc(e.right,sets)){ if(i==j){ reslist.add(i); } } } res = reslist.toArray(new Integer[reslist.size()]); break; case 'u' : left = new ArrayList<Integer>(Arrays.asList(calc(e.left,sets))); boolean found = false; reslist = left; for(Integer i : calc(e.right,sets)){ for(Integer j : calc(e.left,sets)){ if(i==j){ found = true; break; } } if(!found){ reslist.add(i); } found = false; } res = reslist.toArray(new Integer[reslist.size()]); break; case 'd' : found = false; for(Integer i : calc(e.left,sets)){ for(Integer j : calc(e.right,sets)){ if(i==j){ found = true; } } if(!found){ reslist.add(i); } found = false; } res = reslist.toArray(new Integer[reslist.size()]); break; case 's' : Expression sleft = new Expression('d',e.left,e.right); Expression sright = new Expression('d',e.right,e.left); res = calc(new Expression('u',sleft,sright),sets); break; default : if(e.end.charAt(0)=='('){ e.end = e.end.substring(1,e.end.length()-1); } else if(e.end.charAt(0)=='c'){ res = calc(new Expression('c',new Expression(e.end.substring(1))),sets); } else { res = sets.get(e.end); } } return res; } class Expression { public char op; public String end; public Expression left,right; //blank node public Expression(){ } //leaf node public Expression(String s){ this.op = '-'; this.left = null; this.right = null; this.end = s; } //complement public Expression(char op, Expression left){ this.op = op; this.left = left; } //other operands public Expression(char op, Expression left, Expression right){ this.op = op; this.left = left; this.right = right; } public void output(){ System.out.print("("); if(left==null&&right==null){ System.out.print(this.end); } else if(op=='c'){ System.out.print(op + " "); left.output(); } else if(right==null){ left.output(); } else { System.out.print(op + " "); left.output(); System.out.print(" "); right.output(); } System.out.print(")"); } } }
Main.java:65: error: non-static variable this cannot be referenced from a static context Expression e = new Expression(exp); ^ Main.java:86: error: non-static variable this cannot be referenced from a static context e = new Expression(op, parse(left), parse(right)); ^ Main.java:96: error: non-static variable this cannot be referenced from a static context e = new Expression('c',new Expression(exp.substring(1,2))); ^ Main.java:96: error: non-static variable this cannot be referenced from a static context e = new Expression('c',new Expression(exp.substring(1,2))); ^ Main.java:103: error: non-static variable this cannot be referenced from a static context e = new Expression('c',parse(p)); ^ Main.java:120: error: non-static variable this cannot be referenced from a static context Expression u = new Expression("U"); ^ Main.java:121: error: non-static variable this cannot be referenced from a static context res = calc(new Expression('d',u,e.left),sets); ^ Main.java:170: error: non-static variable this cannot be referenced from a static context Expression sleft = new Expression('d',e.left,e.right); ^ Main.java:171: error: non-static variable this cannot be referenced from a static context Expression sright = new Expression('d',e.right,e.left); ^ Main.java:173: error: non-static variable this cannot be referenced from a static context res = calc(new Expression('u',sleft,sright),sets); ^ Main.java:179: error: non-static variable this cannot be referenced from a static context res = calc(new Expression('c',new Expression(e.end.substring(1))),sets); ^ Main.java:179: error: non-static variable this cannot be referenced from a static context res = calc(new Expression('c',new Expression(e.end.substring(1))),sets); ^ 12 errors
s770527678
p00598
Java
import java.io.*; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; public class Main { public static void main(String[] args) { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); try { String line; while ((line = r.readLine()) != null) { HashMap<String, Integer[]> sets = new HashMap<String, Integer[]>(); ArrayList<Integer> U = new ArrayList<Integer>(); while (true) { String[] str = line.split(" "); if (str[0].contains("R")) { break; } if(str.length < 2) return; int n = Integer.parseInt(str[1]); Integer[] e = new Integer[n]; String[] line2 = r.readLine().split(" "); for (int i = 0; i < n; i++) { e[i] = Integer.parseInt(line2[i]); if (!U.contains(e[i])) U.add((Integer) e[i]); } Arrays.sort(e); sets.put(str[0], e); line = r.readLine(); } Integer[] setU = U.toArray(new Integer[U.size()]); Arrays.sort(setU); sets.put("U", setU); String exp = r.readLine(); /* input till here */ /* parsing from here */ Expression e = parse(exp); /* parsing till here */ /* semantic analysis from here */ Integer[] res = calc(e, sets); /* semantic analysis till here */ /* output */ if (res.length > 0 && res.length < 501) { Arrays.sort(res); for (int i = 0; i < res.length - 1; i++) { System.out.print(res[i] + " "); } System.out.println(res[res.length - 1]); } else { System.out.println("NULL"); } } } catch (IOException e) { //e.printStackTrace(); } } public static Expression parse(String exp) { if (exp.length() < 1) { return new Expression(); } // 2-term-operands String ops = "iuds"; String left = "", right = ""; int index = exp.length() - 1; int level = 0; Expression e = null; boolean opfound = false; while (index >= 0) { if (exp.charAt(index) == ')') { level++; } else if (exp.charAt(index) == '(') { level--; } if (level == 0 && ops.indexOf(exp.substring(index, index + 1)) > -1) { char op = exp.charAt(index); left = exp.substring(0, index); right = exp.substring(index + 1, exp.length()); e = new Expression(op, parse(left), parse(right)); opfound = true; break; } index--; } // single-term operand if (!opfound && exp.charAt(0) == 'c') { } if (!opfound) { if (exp.charAt(0) == '(') { return parse(exp.substring(1, exp.length() - 1)); } else if (exp.charAt(0) == 'c') { e = null; if (exp.charAt(1) != '(') { e = new Expression('c', new Expression(exp.substring(1, 2))); } else { index = 1; while (exp.charAt(index) != ')') { index++; } String p = exp.substring(2, index); e = new Expression('c', parse(p)); } return e; } else { return new Expression(exp); } } return e; } public static Integer[] calc(Expression e, HashMap<String, Integer[]> sets) { Integer[] res = new Integer[501]; ArrayList<Integer> reslist = new ArrayList<Integer>(); ArrayList<Integer> left = null; switch (e.op) { case 'n': // res[0] = null; break; case 'c': Expression u = new Expression("U"); res = calc(new Expression('d', u, e.left), sets); break; case 'i': for (Integer i : calc(e.left, sets)) { for (Integer j : calc(e.right, sets)) { if (i == j) { reslist.add(i); } } } res = reslist.toArray(new Integer[reslist.size()]); break; case 'u': left = new ArrayList<Integer>(Arrays.asList(calc(e.left, sets))); boolean found = false; reslist = left; for (Integer i : calc(e.right, sets)) { for (Integer j : calc(e.left, sets)) { if (i == j) { found = true; break; } } if (!found) { reslist.add(i); } found = false; } res = reslist.toArray(new Integer[reslist.size()]); break; case 'd': found = false; for (Integer i : calc(e.left, sets)) { for (Integer j : calc(e.right, sets)) { if (i == j) { found = true; } } if (!found) { reslist.add(i); } found = false; } res = reslist.toArray(new Integer[reslist.size()]); break; case 's': Expression sleft = new Expression('d', e.left, e.right); Expression sright = new Expression('d', e.right, e.left); res = calc(new Expression('u', sleft, sright), sets); break; default: if (e.end.charAt(0) == '(') { e.end = e.end.substring(1, e.end.length() - 1); } else if (e.end.charAt(0) == 'c') { res = calc( new Expression('c', new Expression(e.end.substring(1))), sets); } else { res = sets.get(e.end); } } return res; } static class Expression { public char op; public String end; public Expression left, right; // blank node public Expression() { this.op = 'n'; } // leaf node public Expression(String s) { this.op = '-'; this.left = null; this.right = null; this.end = s; } // complement public Expression(char op, Expression left) { this.op = op; this.left = left; } // other operands public Expression(char op, Expression left, Expression right) { this.op = op; this.left = left; this.right = right; } public void output() { System.out.print("("); if (left == null && right == null) { System.out.print(this.end); } else if (op == 'c') { System.out.print(op + " "); left.output(); } else if (right == null) { left.output(); } else { System.out.print(op + " "); left.output(); System.out.print(" "); right.output(); } System.out.print(")"); } } }
Main.java:29: error: cannot find symbol Arrays.sort(e); ^ symbol: variable Arrays location: class Main Main.java:34: error: cannot find symbol Arrays.sort(setU); ^ symbol: variable Arrays location: class Main Main.java:47: error: cannot find symbol Arrays.sort(res); ^ symbol: variable Arrays location: class Main Main.java:139: error: cannot find symbol left = new ArrayList<Integer>(Arrays.asList(calc(e.left, sets))); ^ symbol: variable Arrays location: class Main 4 errors
s583357859
p00598
Java
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); try { String line; return; while ((line = r.readLine()) != null) { HashMap<String, Integer[]> sets = new HashMap<String, Integer[]>(); ArrayList<Integer> U = new ArrayList<Integer>(); while (true) { String[] str = line.split(" "); if (str[0].contains("R")) { break; } if(str.length < 2) return; int n = Integer.parseInt(str[1]); Integer[] e = new Integer[n]; String[] line2 = r.readLine().split(" "); for (int i = 0; i < n; i++) { e[i] = Integer.parseInt(line2[i]); if (!U.contains(e[i])) U.add((Integer) e[i]); } Arrays.sort(e); sets.put(str[0], e); line = r.readLine(); } Integer[] setU = U.toArray(new Integer[U.size()]); Arrays.sort(setU); sets.put("U", setU); String exp = r.readLine(); /* input till here */ /* parsing from here */ Expression e = parse(exp); /* parsing till here */ /* semantic analysis from here */ Integer[] res = calc(e, sets); /* semantic analysis till here */ /* output */ if (res.length > 0 && res.length < 501) { Arrays.sort(res); for (int i = 0; i < res.length - 1; i++) { System.out.print(res[i] + " "); } System.out.println(res[res.length - 1]); } else { System.out.println("NULL"); } } } catch (IOException e) { //e.printStackTrace(); } } public static Expression parse(String exp) { if (exp.length() < 1) { return new Expression(); } // 2-term-operands String ops = "iuds"; String left = "", right = ""; int index = exp.length() - 1; int level = 0; Expression e = null; boolean opfound = false; while (index >= 0) { if (exp.charAt(index) == ')') { level++; } else if (exp.charAt(index) == '(') { level--; } if (level == 0 && ops.indexOf(exp.substring(index, index + 1)) > -1) { char op = exp.charAt(index); left = exp.substring(0, index); right = exp.substring(index + 1, exp.length()); e = new Expression(op, parse(left), parse(right)); opfound = true; break; } index--; } // single-term operand if (!opfound && exp.charAt(0) == 'c') { } if (!opfound) { if (exp.charAt(0) == '(') { return parse(exp.substring(1, exp.length() - 1)); } else if (exp.charAt(0) == 'c') { e = null; if (exp.charAt(1) != '(') { e = new Expression('c', new Expression(exp.substring(1, 2))); } else { index = 1; while (exp.charAt(index) != ')') { index++; } String p = exp.substring(2, index); e = new Expression('c', parse(p)); } return e; } else { return new Expression(exp); } } return e; } public static Integer[] calc(Expression e, HashMap<String, Integer[]> sets) { Integer[] res = new Integer[501]; ArrayList<Integer> reslist = new ArrayList<Integer>(); ArrayList<Integer> left = null; switch (e.op) { case 'n': // res[0] = null; break; case 'c': Expression u = new Expression("U"); res = calc(new Expression('d', u, e.left), sets); break; case 'i': for (Integer i : calc(e.left, sets)) { for (Integer j : calc(e.right, sets)) { if (i == j) { reslist.add(i); } } } res = reslist.toArray(new Integer[reslist.size()]); break; case 'u': left = new ArrayList<Integer>(Arrays.asList(calc(e.left, sets))); boolean found = false; reslist = left; for (Integer i : calc(e.right, sets)) { for (Integer j : calc(e.left, sets)) { if (i == j) { found = true; break; } } if (!found) { reslist.add(i); } found = false; } res = reslist.toArray(new Integer[reslist.size()]); break; case 'd': found = false; for (Integer i : calc(e.left, sets)) { for (Integer j : calc(e.right, sets)) { if (i == j) { found = true; } } if (!found) { reslist.add(i); } found = false; } res = reslist.toArray(new Integer[reslist.size()]); break; case 's': Expression sleft = new Expression('d', e.left, e.right); Expression sright = new Expression('d', e.right, e.left); res = calc(new Expression('u', sleft, sright), sets); break; default: if (e.end.charAt(0) == '(') { e.end = e.end.substring(1, e.end.length() - 1); } else if (e.end.charAt(0) == 'c') { res = calc( new Expression('c', new Expression(e.end.substring(1))), sets); } else { res = sets.get(e.end); } } return res; } static class Expression { public char op; public String end; public Expression left, right; // blank node public Expression() { this.op = 'n'; } // leaf node public Expression(String s) { this.op = '-'; this.left = null; this.right = null; this.end = s; } // complement public Expression(char op, Expression left) { this.op = op; this.left = left; } // other operands public Expression(char op, Expression left, Expression right) { this.op = op; this.left = left; this.right = right; } public void output() { System.out.print("("); if (left == null && right == null) { System.out.print(this.end); } else if (op == 'c') { System.out.print(op + " "); left.output(); } else if (right == null) { left.output(); } else { System.out.print(op + " "); left.output(); System.out.print(" "); right.output(); } System.out.print(")"); } } }
Main.java:10: error: unreachable statement while ((line = r.readLine()) != null) { ^ 1 error
s346786921
p00598
C++
#include <iostream> #include <string> #include <set> #include <cstring> #include <climits> #include <algorithm> #include <map> using namespace std; typedef map<char, set<int> > mapset; set<int> atom(string&, mapset&, int&); set<int> block(string&, mapset&, int&); set<int> unite(set<int>&, set<int>&); set<int> intersection(set<int>&, set<int>&); set<int> difference(set<int>&, set<int>&); set<int> symmetric_difference(set<int>&, set<int>&); set<int> parse(string&, mapset&, int&); set<int> complement(mapset&, set<int>&); set<int> atom(string &expr, mapset &sets, int &k) { return sets[expr[k++]]; } set<int> block(string &expr, mapset &sets, int &k) { if (expr[k] == '(') { k ++; return parse(expr, sets, k++); } else if (expr[k] == 'c') { k ++; return complement(sets, block(expr, sets, k)); } return atom(expr, sets, k); } set<int> unite(set<int> &s1, set<int> &s2) { set<int> ret(s1); for (set<int>::iterator it=s2.begin(); it!=s2.end(); ++it) { ret.insert(*it); } return ret; } set<int> intersection(set<int> &s1, set<int> &s2) { set<int> ret; for (set<int>::iterator it=s2.begin(); it!=s2.end(); ++it) { if (s1.find(*it) != s1.end()) { ret.insert(*it); } } return ret; } set<int> difference(set<int> &s1, set<int> &s2) { set<int> ret(s1); for (set<int>::iterator it=s2.begin(); it!=s2.end(); ++it) { ret.erase(*it); } return ret; } set<int> symmetric_difference(set<int> &s1, set<int> &s2) { return unite(difference(s1, s2), difference(s2, s1)); } set<int> complement(mapset &sets, set<int> &s1) { set<int> U; for (mapset::iterator it=sets.begin(); it!=sets.end(); ++it) { U = unite(U, it->second); } return difference(U, s1); } set<int> parse(string &expr, mapset &sets, int &k) { set<int> v1 = block(expr, sets, k); while (k < (int)expr.size() && expr[k] != ')') { char op = expr[k++]; set<int> v2 = block(expr, sets, k); if (op == 'u') { v1 = unite(v1, v2); } else if (op == 'i') { v1 = intersection(v1, v2); } else if (op == 'd') { v1 = difference(v1, v2); } else if (op == 's') { v1 = symmetric_difference(v1, v2); } } return v1; } void solve(string &expr, mapset &sets) { int k = 0; set<int> st = parse(expr, sets, k); if (st.empty()) { cout << "NULL" << endl; return ; } for (set<int>::iterator it=st.begin(); it!=st.end(); ++it) { cout << (it == st.begin() ? "" : " ") << *it; } cout << endl; } int main() { char c; int k; map<char, set<int> > sets; while (cin >> c >> k) { if (c != 'R') { set<int> st; int t; for (int i=0; i<k; ++i) { cin >> t; st.insert(t); } sets[c] = st; } else { string expr; cin >> expr; solve(expr, sets); sets.clear(); } } return 0; }
a.cc: In function 'std::set<int> block(std::string&, mapset&, int&)': a.cc:29:35: error: cannot bind non-const lvalue reference of type 'int&' to an rvalue of type 'int' 29 | return parse(expr, sets, k++); | ~^~ a.cc:19:34: note: initializing argument 3 of 'std::set<int> parse(std::string&, mapset&, int&)' 19 | set<int> parse(string&, mapset&, int&); | ^~~~ a.cc:32:38: error: cannot bind non-const lvalue reference of type 'std::set<int>&' to an rvalue of type 'std::set<int>' 32 | return complement(sets, block(expr, sets, k)); | ~~~~~^~~~~~~~~~~~~~~ a.cc:20:30: note: initializing argument 2 of 'std::set<int> complement(mapset&, std::set<int>&)' 20 | set<int> complement(mapset&, set<int>&); | ^~~~~~~~~ a.cc: In function 'std::set<int> symmetric_difference(std::set<int>&, std::set<int>&)': a.cc:64:28: error: cannot bind non-const lvalue reference of type 'std::set<int>&' to an rvalue of type 'std::set<int>' 64 | return unite(difference(s1, s2), difference(s2, s1)); | ~~~~~~~~~~^~~~~~~~ a.cc:37:26: note: initializing argument 1 of 'std::set<int> unite(std::set<int>&, std::set<int>&)' 37 | set<int> unite(set<int> &s1, set<int> &s2) { | ~~~~~~~~~~^~
s601899986
p00598
C++
#include <iostream> #include <string> #include <map> #include <vector> #include <set> #include <vector> #include <iterator> using namespace std; typedef map<char, set<int> > M; vector<int> conv_vec(set<int> st) { vector<int> vec; for(set<int>::iterator it = st.begin(); it != st.end(); ++it) { vec.push_back(*it); } return vec; } set<int> conv_set(vector<int> vec) { set<int> st; for(vector<int>::iterator it = vec.begin(); it != vec.end(); ++it) { st.insert(*it); } return st; } void show(vector<int> A, vector<int> B, char order, vector<int> result) { cout << "{ "; for (int i = 0; i < A.size(); i += 1) { cout << A[i] << " "; } cout << "} " << order << " { "; for (int i = 0; i < B.size(); i += 1) { cout << B[i] << " "; } cout << "} = { "; for (int i = 0; i < result.size(); i += 1) { cout << result[i] << " "; } cout << "}" << endl; return; } set<int> calc(set<int> st_A, set<int> st_B, char order) { vector<int> result; vector<int> A = conv_vec(st_A), B = conv_vec(st_B); if (order == 'u') { set_union(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'i') { set_intersection(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'd') { set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 's') { set_symmetric_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'c') { set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } //show(A, B, order, result); return conv_set(result); } int p_skip(string str, int p) { int cnt = 1; while(p < str.size()) { if (str[p] == '(') { ++cnt; } else if (str[p] == ')') { --cnt; } ++p; if (cnt == 0) { break; } } return p; } set<int> parse(string str, M dataset, int start) { int p = start; set<int> A, B; if (str[p] == '(') { p += 1; A = parse(str, dataset, p); p = p_skip(str, p); } else if (str[p] == 'c') { p += 1; if(str[p] == '(') { p += 1; A = parse(str, dataset, p); p = p_skip(str, p); } else { A = dataset[str[p]]; p += 1; } A = calc(dataset['U'], A, 'c'); } else { A = dataset[str[p]]; p += 1; } while(p < str.size()) { if (((string)("uids")).find(str[p]) == string::npos) { break; } char order = str[p]; ++p; if (str[p] == '(') { p += 1; B = parse(str, dataset, p); p = p_skip(str, p); } else if (str[p] == 'c') { p += 1; if(str[p] == '(') { p += 1; B = parse(str, dataset, p); p = p_skip(str, p); } else { B = dataset[str[p]]; p += 1; } B = calc(dataset['U'], B, 'c'); } else { B = dataset[str[p]]; p += 1; } A = calc(A, B, order); } return A; } void solve(string str, M dataset) { set<int> result = parse(str, dataset, 0); if (result.empty()) { cout << "NULL" << endl; return; } int cnt = 0; for (set<int>::iterator it = result.begin(); it != result.end(); ++it) { if (cnt == (int)(result.size())-1) { cout << *it << endl; } else { cout << *it << " "; cnt += 1; } } return; } int main() { char s; int t; set<int> U; string str; M dataset; while(!cin.eof()) { cin >> s >> t; if(s == 'R'){ cin >> str; //cout << "str: " << str << endl; dataset['U'] = U; solve(str, dataset); dataset.clear(); U.clear(); continue; } set<int> st; int u; for (int i = 0; i < t; i += 1) { cin >> u; st.insert(u); U.insert(u); } dataset[s] = st; } return 0; }
a.cc: In function 'std::set<int> calc(std::set<int>, std::set<int>, char)': a.cc:52:9: error: 'set_union' was not declared in this scope 52 | set_union(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~ a.cc:54:9: error: 'set_intersection' was not declared in this scope 54 | set_intersection(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~~~ a.cc:56:9: error: 'set_difference' was not declared in this scope 56 | set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~ a.cc:58:9: error: 'set_symmetric_difference' was not declared in this scope 58 | set_symmetric_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~~~~~~~~~~~ a.cc:60:9: error: 'set_difference' was not declared in this scope 60 | set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~
s638902532
p00598
C++
#include <iostream> #include <string> #include <map> #include <vector> #include <set> #include <vector> #include <iterator> using namespace std; typedef map<char, set<int> > M; vector<int> conv_vec(set<int> st) { vector<int> vec; for(set<int>::iterator it = st.begin(); it != st.end(); ++it) { vec.push_back(*it); } return vec; } set<int> conv_set(vector<int> vec) { set<int> st; for(vector<int>::iterator it = vec.begin(); it != vec.end(); ++it) { st.insert(*it); } return st; } void show(vector<int> A, vector<int> B, char order, vector<int> result) { cout << "{ "; for (int i = 0; i < A.size(); i += 1) { cout << A[i] << " "; } cout << "} " << order << " { "; for (int i = 0; i < B.size(); i += 1) { cout << B[i] << " "; } cout << "} = { "; for (int i = 0; i < result.size(); i += 1) { cout << result[i] << " "; } cout << "}" << endl; return; } set<int> calc(set<int> st_A, set<int> st_B, char order) { vector<int> result; vector<int> A = conv_vec(st_A), B = conv_vec(st_B); if (order == 'u') { set_union(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'i') { set_intersection(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'd') { set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 's') { set_symmetric_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'c') { set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } //show(A, B, order, result); return conv_set(result); } int p_skip(string str, int p) { int cnt = 1; while(p < str.size()) { if (str[p] == '(') { ++cnt; } else if (str[p] == ')') { --cnt; } ++p; if (cnt == 0) { break; } } return p; } set<int> parse(string str, M dataset, int start) { int p = start; set<int> A, B; if (str[p] == '(') { p += 1; A = parse(str, dataset, p); p = p_skip(str, p); } else if (str[p] == 'c') { p += 1; if(str[p] == '(') { p += 1; A = parse(str, dataset, p); p = p_skip(str, p); } else { A = dataset[str[p]]; p += 1; } A = calc(dataset['U'], A, 'c'); } else { A = dataset[str[p]]; p += 1; } while(p < str.size()) { if (((string)("uids")).find(str[p]) == string::npos) { break; } char order = str[p]; ++p; if (str[p] == '(') { p += 1; B = parse(str, dataset, p); p = p_skip(str, p); } else if (str[p] == 'c') { p += 1; if(str[p] == '(') { p += 1; B = parse(str, dataset, p); p = p_skip(str, p); } else { B = dataset[str[p]]; p += 1; } B = calc(dataset['U'], B, 'c'); } else { B = dataset[str[p]]; p += 1; } A = calc(A, B, order); } return A; } void solve(string str, M dataset) { set<int> result = parse(str, dataset, 0); if (result.empty()) { cout << "NULL" << endl; return; } int cnt = 0; for (set<int>::iterator it = result.begin(); it != result.end(); ++it) { if (cnt == (int)(result.size())-1) { cout << *it << endl; } else { cout << *it << " "; cnt += 1; } } return; } int main() { char s; int t; set<int> U; string str; M dataset; while(!cin.eof()) { cin >> s >> t; if(s == 'R'){ cin >> str; //cout << "str: " << str << endl; dataset['U'] = U; solve(str, dataset); dataset.clear(); U.clear(); continue; } set<int> st; int u; for (int i = 0; i < t; i += 1) { cin >> u; st.insert(u); U.insert(u); } dataset[s] = st; } return 0; }
a.cc: In function 'std::set<int> calc(std::set<int>, std::set<int>, char)': a.cc:52:9: error: 'set_union' was not declared in this scope 52 | set_union(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~ a.cc:54:9: error: 'set_intersection' was not declared in this scope 54 | set_intersection(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~~~ a.cc:56:9: error: 'set_difference' was not declared in this scope 56 | set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~ a.cc:58:9: error: 'set_symmetric_difference' was not declared in this scope 58 | set_symmetric_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~~~~~~~~~~~ a.cc:60:9: error: 'set_difference' was not declared in this scope 60 | set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~
s152075023
p00598
C++
#include <iostream> #include <string> #include <map> #include <vector> #include <set> #include <vector> #include <iterator> using namespace std; using std::begin; using std::end; typedef map<char, set<int> > M; vector<int> conv_vec(set<int> st) { vector<int> vec; for(set<int>::iterator it = st.begin(); it != st.end(); ++it) { vec.push_back(*it); } return vec; } set<int> conv_set(vector<int> vec) { set<int> st; for(vector<int>::iterator it = vec.begin(); it != vec.end(); ++it) { st.insert(*it); } return st; } void show(vector<int> A, vector<int> B, char order, vector<int> result) { cout << "{ "; for (int i = 0; i < A.size(); i += 1) { cout << A[i] << " "; } cout << "} " << order << " { "; for (int i = 0; i < B.size(); i += 1) { cout << B[i] << " "; } cout << "} = { "; for (int i = 0; i < result.size(); i += 1) { cout << result[i] << " "; } cout << "}" << endl; return; } set<int> calc(set<int> st_A, set<int> st_B, char order) { vector<int> result; vector<int> A = conv_vec(st_A), B = conv_vec(st_B); if (order == 'u') { std::set_union(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'i') { std::set_intersection(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'd') { std::set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 's') { std::set_symmetric_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'c') { std::set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } //show(A, B, order, result); return conv_set(result); } int p_skip(string str, int p) { int cnt = 1; while(p < str.size()) { if (str[p] == '(') { ++cnt; } else if (str[p] == ')') { --cnt; } ++p; if (cnt == 0) { break; } } return p; } set<int> parse(string str, M dataset, int start) { int p = start; set<int> A, B; if (str[p] == '(') { p += 1; A = parse(str, dataset, p); p = p_skip(str, p); } else if (str[p] == 'c') { p += 1; if(str[p] == '(') { p += 1; A = parse(str, dataset, p); p = p_skip(str, p); } else { A = dataset[str[p]]; p += 1; } A = calc(dataset['U'], A, 'c'); } else { A = dataset[str[p]]; p += 1; } while(p < str.size()) { if (((string)("uids")).find(str[p]) == string::npos) { break; } char order = str[p]; ++p; if (str[p] == '(') { p += 1; B = parse(str, dataset, p); p = p_skip(str, p); } else if (str[p] == 'c') { p += 1; if(str[p] == '(') { p += 1; B = parse(str, dataset, p); p = p_skip(str, p); } else { B = dataset[str[p]]; p += 1; } B = calc(dataset['U'], B, 'c'); } else { B = dataset[str[p]]; p += 1; } A = calc(A, B, order); } return A; } void solve(string str, M dataset) { set<int> result = parse(str, dataset, 0); if (result.empty()) { cout << "NULL" << endl; return; } int cnt = 0; for (set<int>::iterator it = result.begin(); it != result.end(); ++it) { if (cnt == (int)(result.size())-1) { cout << *it << endl; } else { cout << *it << " "; cnt += 1; } } return; } int main() { char s; int t; set<int> U; string str; M dataset; while(!cin.eof()) { cin >> s >> t; if(s == 'R'){ cin >> str; //cout << "str: " << str << endl; dataset['U'] = U; solve(str, dataset); dataset.clear(); U.clear(); continue; } set<int> st; int u; for (int i = 0; i < t; i += 1) { cin >> u; st.insert(u); U.insert(u); } dataset[s] = st; } return 0; }
a.cc: In function 'std::set<int> calc(std::set<int>, std::set<int>, char)': a.cc:54:14: error: 'set_union' is not a member of 'std'; did you mean 'is_union'? 54 | std::set_union(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~ | is_union a.cc:56:14: error: 'set_intersection' is not a member of 'std' 56 | std::set_intersection(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~~~ a.cc:58:14: error: 'set_difference' is not a member of 'std' 58 | std::set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~ a.cc:60:14: error: 'set_symmetric_difference' is not a member of 'std' 60 | std::set_symmetric_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~~~~~~~~~~~ a.cc:62:14: error: 'set_difference' is not a member of 'std' 62 | std::set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~
s460737144
p00598
C++
#include <iostream> #include <string> #include <map> #include <vector> #include <set> #include <vector> #include <iterator> using namespace std; using std::begin; using std::end; typedef map<char, set<int> > M; vector<int> conv_vec(set<int> st) { vector<int> vec; for(set<int>::iterator it = st.begin(); it != st.end(); ++it) { vec.push_back(*it); } return vec; } set<int> conv_set(vector<int> vec) { set<int> st; for(vector<int>::iterator it = vec.begin(); it != vec.end(); ++it) { st.insert(*it); } return st; } void show(vector<int> A, vector<int> B, char order, vector<int> result) { cout << "{ "; for (int i = 0; i < A.size(); i += 1) { cout << A[i] << " "; } cout << "} " << order << " { "; for (int i = 0; i < B.size(); i += 1) { cout << B[i] << " "; } cout << "} = { "; for (int i = 0; i < result.size(); i += 1) { cout << result[i] << " "; } cout << "}" << endl; return; } set<int> calc(set<int> st_A, set<int> st_B, char order) { vector<int> result; vector<int> A = conv_vec(st_A), B = conv_vec(st_B); if (order == 'u') { std::set_union(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'i') { std::set_intersection(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'd') { std::set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 's') { std::set_symmetric_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'c') { std::set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } //show(A, B, order, result); return conv_set(result); } int p_skip(string str, int p) { int cnt = 1; while(p < str.size()) { if (str[p] == '(') { ++cnt; } else if (str[p] == ')') { --cnt; } ++p; if (cnt == 0) { break; } } return p; } set<int> parse(string str, M dataset, int start) { int p = start; set<int> A, B; if (str[p] == '(') { p += 1; A = parse(str, dataset, p); p = p_skip(str, p); } else if (str[p] == 'c') { p += 1; if(str[p] == '(') { p += 1; A = parse(str, dataset, p); p = p_skip(str, p); } else { A = dataset[str[p]]; p += 1; } A = calc(dataset['U'], A, 'c'); } else { A = dataset[str[p]]; p += 1; } while(p < str.size()) { if (((string)("uids")).find(str[p]) == string::npos) { break; } char order = str[p]; ++p; if (str[p] == '(') { p += 1; B = parse(str, dataset, p); p = p_skip(str, p); } else if (str[p] == 'c') { p += 1; if(str[p] == '(') { p += 1; B = parse(str, dataset, p); p = p_skip(str, p); } else { B = dataset[str[p]]; p += 1; } B = calc(dataset['U'], B, 'c'); } else { B = dataset[str[p]]; p += 1; } A = calc(A, B, order); } return A; } void solve(string str, M dataset) { set<int> result = parse(str, dataset, 0); if (result.empty()) { cout << "NULL" << endl; return; } int cnt = 0; for (set<int>::iterator it = result.begin(); it != result.end(); ++it) { if (cnt == (int)(result.size())-1) { cout << *it << endl; } else { cout << *it << " "; cnt += 1; } } return; } int main() { char s; int t; set<int> U; string str; M dataset; while(!cin.eof()) { cin >> s >> t; if(s == 'R'){ cin >> str; //cout << "str: " << str << endl; dataset['U'] = U; solve(str, dataset); dataset.clear(); U.clear(); continue; } set<int> st; int u; for (int i = 0; i < t; i += 1) { cin >> u; st.insert(u); U.insert(u); } dataset[s] = st; } return 0; }
a.cc: In function 'std::set<int> calc(std::set<int>, std::set<int>, char)': a.cc:54:14: error: 'set_union' is not a member of 'std'; did you mean 'is_union'? 54 | std::set_union(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~ | is_union a.cc:56:14: error: 'set_intersection' is not a member of 'std' 56 | std::set_intersection(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~~~ a.cc:58:14: error: 'set_difference' is not a member of 'std' 58 | std::set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~ a.cc:60:14: error: 'set_symmetric_difference' is not a member of 'std' 60 | std::set_symmetric_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~~~~~~~~~~~ a.cc:62:14: error: 'set_difference' is not a member of 'std' 62 | std::set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~
s726872738
p00598
C++
#include <iostream> #include <string> #include <map> #include <vector> #include <set> #include <vector> #include <iterator> using namespace std; typedef map<char, set<int> > M; vector<int> conv_vec(set<int> st) { vector<int> vec; for(set<int>::iterator it = st.begin(); it != st.end(); ++it) { vec.push_back(*it); } return vec; } set<int> conv_set(vector<int> vec) { set<int> st; for(vector<int>::iterator it = vec.begin(); it != vec.end(); ++it) { st.insert(*it); } return st; } void show(vector<int> A, vector<int> B, char order, vector<int> result) { cout << "{ "; for (int i = 0; i < A.size(); i += 1) { cout << A[i] << " "; } cout << "} " << order << " { "; for (int i = 0; i < B.size(); i += 1) { cout << B[i] << " "; } cout << "} = { "; for (int i = 0; i < result.size(); i += 1) { cout << result[i] << " "; } cout << "}" << endl; return; } set<int> calc(set<int> st_A, set<int> st_B, char order) { vector<int> result; vector<int> A = conv_vec(st_A), B = conv_vec(st_B); if (order == 'u') { set_union(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'i') { set_intersection(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'd') { set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 's') { set_symmetric_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'c') { set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } //show(A, B, order, result); return conv_set(result); } int p_skip(string str, int p) { int cnt = 1; while(p < str.size()) { if (str[p] == '(') { ++cnt; } else if (str[p] == ')') { --cnt; } ++p; if (cnt == 0) { break; } } return p; } set<int> parse(string str, M dataset, int start) { int p = start; set<int> A, B; if (str[p] == '(') { p += 1; A = parse(str, dataset, p); p = p_skip(str, p); } else if (str[p] == 'c') { p += 1; if(str[p] == '(') { p += 1; A = parse(str, dataset, p); p = p_skip(str, p); } else { A = dataset[str[p]]; p += 1; } A = calc(dataset['U'], A, 'c'); } else { A = dataset[str[p]]; p += 1; } while(p < str.size()) { if (((string)("uids")).find(str[p]) == string::npos) { break; } char order = str[p]; ++p; if (str[p] == '(') { p += 1; B = parse(str, dataset, p); p = p_skip(str, p); } else if (str[p] == 'c') { p += 1; if(str[p] == '(') { p += 1; B = parse(str, dataset, p); p = p_skip(str, p); } else { B = dataset[str[p]]; p += 1; } B = calc(dataset['U'], B, 'c'); } else { B = dataset[str[p]]; p += 1; } A = calc(A, B, order); } return A; } void solve(string str, M dataset) { set<int> result = parse(str, dataset, 0); if (result.empty()) { cout << "NULL" << endl; return; } int cnt = 0; for (set<int>::iterator it = result.begin(); it != result.end(); ++it) { if (cnt == (int)(result.size())-1) { cout << *it << endl; } else { cout << *it << " "; cnt += 1; } } return; } int main() { char s; int t; set<int> U; string str; M dataset; while(!cin.eof()) { cin >> s >> t; if(s == 'R'){ cin >> str; //cout << "str: " << str << endl; dataset['U'] = U; solve(str, dataset); dataset.clear(); U.clear(); continue; } set<int> st; int u; for (int i = 0; i < t; i += 1) { cin >> u; st.insert(u); U.insert(u); } dataset[s] = st; } return 0; }
a.cc: In function 'std::set<int> calc(std::set<int>, std::set<int>, char)': a.cc:52:9: error: 'set_union' was not declared in this scope 52 | set_union(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~ a.cc:54:9: error: 'set_intersection' was not declared in this scope 54 | set_intersection(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~~~ a.cc:56:9: error: 'set_difference' was not declared in this scope 56 | set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~ a.cc:58:9: error: 'set_symmetric_difference' was not declared in this scope 58 | set_symmetric_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~~~~~~~~~~~ a.cc:60:9: error: 'set_difference' was not declared in this scope 60 | set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); | ^~~~~~~~~~~~~~
s097219785
p00598
C++
#include <iostream> #include <string> #include <map> #include <vector> #include <set> #include <vector> #include <iterator> #include <algorithm> using namespace std; typedef map<char, set<int> > M; vector<int> conv_vec(set<int> st) { vector<int> vec; for(set<int>::iterator it = st.begin(); it != st.end(); ++it) { vec.push_back(*it); } return vec; } set<int> conv_set(vector<int> vec) { set<int> st; for(vector<int>::iterator it = vec.begin(); it != vec.end(); ++it) { st.insert(*it); } return st; } void show(vector<int> A, vector<int> B, char order, vector<int> result) { cout << "{ "; for (int i = 0; i < A.size(); i += 1) { cout << A[i] << " "; } cout << "} " << order << " { "; for (int i = 0; i < B.size(); i += 1) { cout << B[i] << " "; } cout << "} = { "; for (int i = 0; i < result.size(); i += 1) { cout << result[i] << " "; } cout << "}" << endl; return; } set<int> calc(set<int> st_A, set<int> st_B, char order) { vector<int> result; vector<int> A = conv_vec(st_A), B = conv_vec(st_B); if (order == 'u') { set_union(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'i') { set_intersection(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'd') { set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 's') { set_symmetric_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'c') { set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } //show(A, B, order, result); return conv_set(result); } int p_skip(string str, int p) { int cnt = 1; while(p < str.size()) { if (str[p] == '(') { ++cnt; } else if (str[p] == ')') { --cnt; } ++p; if (cnt == 0) { break; } } return p; } set<int> parse(string str, M dataset, int start) { int p = start; set<int> A, B; if (str[p] == '(') { p += 1; A = parse(str, dataset, p); p = p_skip(str, p); } else if (str[p] == 'c') { p += 1; if(str[p] == '(') { p += 1; A = parse(str, dataset, p); p = p_skip(str, p); } else { A = dataset[str[p]]; p += 1; } A = calc(dataset['U'], A, 'c'); } else { A = dataset[str[p]]; p += 1; } while(p < str.size()) { if (((string)("uids")).find(str[p]) == string::npos) { break; } char order = str[p]; ++p; if (str[p] == '(') { p += 1; B = parse(str, dataset, p); p = p_skip(str, p); } else if (str[p] == 'c') { p += 1; if(str[p] == '(') { p += 1; B = parse(str, dataset, p); p = p_skip(str, p); } else { B = dataset[str[p]]; p += 1; } B = calc(dataset['U'], B, 'c'); } else { B = dataset[str[p]]; p += 1; } A = calc(A, B, order); } return A; } void solve(string str, M dataset) { set<int> result = parse(str, dataset, 0); if (result.empty()) { cout << "NULL" << endl; return; } int cnt = 0; sort(result.begin(), result.end()); for (set<int>::iterator it = result.begin(); it != result.end(); ++it) { if (cnt == (int)(result.size())-1) { cout << *it << endl; } else { cout << *it << " "; cnt += 1; } } return; } int main() { char s; int t; set<int> U; string str; M dataset; while(!cin.eof()) { cin >> s >> t; if(s == 'R'){ cin >> str; //cout << "str: " << str << endl; dataset['U'] = U; solve(str, dataset); dataset.clear(); U.clear(); continue; } set<int> st; int u; for (int i = 0; i < t; i += 1) { cin >> u; st.insert(u); U.insert(u); } dataset[s] = st; } return 0; }
In file included from /usr/include/c++/14/algorithm:61, from a.cc:8: /usr/include/c++/14/bits/stl_algo.h: In instantiation of 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = _Rb_tree_const_iterator<int>; _Compare = __gnu_cxx::__ops::_Iter_less_iter]': /usr/include/c++/14/bits/stl_algo.h:4772:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = _Rb_tree_const_iterator<int>]' 4772 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:148:9: required from here 148 | sort(result.begin(), result.end()); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1906:50: error: no match for 'operator-' (operand types are 'std::_Rb_tree_const_iterator<int>' and 'std::_Rb_tree_const_iterator<int>') 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~^~~~~~~~~ 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:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 618 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algo.h:1906:50: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::reverse_iterator<_Iterator>' 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1790 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algo.h:1906:50: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::move_iterator<_IteratorL>' 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~^~~~~~~~~
s054086089
p00598
C++
#include <iostream> #include <string> #include <map> #include <vector> #include <set> #include <vector> #include <iterator> #include <algorithm> using namespace std; typedef map<char, set<int> > M; vector<int> conv_vec(set<int> st) { vector<int> vec; for(set<int>::iterator it = st.begin(); it != st.end(); ++it) { vec.push_back(*it); } return vec; } set<int> conv_set(vector<int> vec) { set<int> st; for(vector<int>::iterator it = vec.begin(); it != vec.end(); ++it) { st.insert(*it); } return st; } void show(vector<int> A, vector<int> B, char order, vector<int> result) { cout << "{ "; for (int i = 0; i < A.size(); i += 1) { cout << A[i] << " "; } cout << "} " << order << " { "; for (int i = 0; i < B.size(); i += 1) { cout << B[i] << " "; } cout << "} = { "; for (int i = 0; i < result.size(); i += 1) { cout << result[i] << " "; } cout << "}" << endl; return; } set<int> calc(set<int> st_A, set<int> st_B, char order) { vector<int> result; vector<int> A = conv_vec(st_A), B = conv_vec(st_B); if (order == 'u') { set_union(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'i') { set_intersection(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'd') { set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 's') { set_symmetric_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'c') { set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } //show(A, B, order, result); return conv_set(result); } int p_skip(string str, int p) { int cnt = 1; while(p < str.size()) { if (str[p] == '(') { ++cnt; } else if (str[p] == ')') { --cnt; } ++p; if (cnt == 0) { break; } } return p; } set<int> parse(string str, M dataset, int start) { int p = start; set<int> A, B; if (str[p] == '(') { p += 1; A = parse(str, dataset, p); p = p_skip(str, p); } else if (str[p] == 'c') { p += 1; if(str[p] == '(') { p += 1; A = parse(str, dataset, p); p = p_skip(str, p); } else { A = dataset[str[p]]; p += 1; } A = calc(dataset['U'], A, 'c'); } else { A = dataset[str[p]]; p += 1; } while(p < str.size()) { if (((string)("uids")).find(str[p]) == string::npos) { break; } char order = str[p]; ++p; if (str[p] == '(') { p += 1; B = parse(str, dataset, p); p = p_skip(str, p); } else if (str[p] == 'c') { p += 1; if(str[p] == '(') { p += 1; B = parse(str, dataset, p); p = p_skip(str, p); } else { B = dataset[str[p]]; p += 1; } B = calc(dataset['U'], B, 'c'); } else { B = dataset[str[p]]; p += 1; } A = calc(A, B, order); } return A; } void solve(string str, M dataset) { set<int> result = parse(str, dataset, 0); if (result.empty()) { cout << "NULL" << endl; return; } int cnt = 0; sort(result.begin(), result.end()); for (set<int>::iterator it = result.begin(); it != result.end(); ++it) { if (cnt == (int)(result.size())-1) { cout << *it << endl; } else { cout << *it << " "; cnt += 1; } } return; } int main() { char s; int t; set<int> U; string str; M dataset; while(!cin.eof()) { cin >> s >> t; if(s == 'R'){ cin >> str; //cout << "str: " << str << endl; dataset['U'] = U; solve(str, dataset); dataset.clear(); U.clear(); continue; } set<int> st; int u; for (int i = 0; i < t; i += 1) { cin >> u; st.insert(u); U.insert(u); } dataset[s] = st; } return 0; }
In file included from /usr/include/c++/14/algorithm:61, from a.cc:8: /usr/include/c++/14/bits/stl_algo.h: In instantiation of 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = _Rb_tree_const_iterator<int>; _Compare = __gnu_cxx::__ops::_Iter_less_iter]': /usr/include/c++/14/bits/stl_algo.h:4772:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = _Rb_tree_const_iterator<int>]' 4772 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:148:9: required from here 148 | sort(result.begin(), result.end()); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1906:50: error: no match for 'operator-' (operand types are 'std::_Rb_tree_const_iterator<int>' and 'std::_Rb_tree_const_iterator<int>') 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~^~~~~~~~~ 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:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 618 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algo.h:1906:50: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::reverse_iterator<_Iterator>' 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1790 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algo.h:1906:50: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::move_iterator<_IteratorL>' 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~^~~~~~~~~
s048990535
p00598
C++
#include <iostream> #include <string> #include <map> #include <vector> #include <set> #include <vector> #include <iterator> #include <algorithm> using namespace std; typedef map<char, set<int> > M; vector<int> conv_vec(set<int> st) { vector<int> vec; for(set<int>::iterator it = st.begin(); it != st.end(); ++it) { vec.push_back(*it); } return vec; } set<int> conv_set(vector<int> vec) { set<int> st; for(vector<int>::iterator it = vec.begin(); it != vec.end(); ++it) { st.insert(*it); } return st; } void show(vector<int> A, vector<int> B, char order, vector<int> result) { cout << "{ "; for (int i = 0; i < A.size(); i += 1) { cout << A[i] << " "; } cout << "} " << order << " { "; for (int i = 0; i < B.size(); i += 1) { cout << B[i] << " "; } cout << "} = { "; for (int i = 0; i < result.size(); i += 1) { cout << result[i] << " "; } cout << "}" << endl; return; } set<int> calc(set<int> st_A, set<int> st_B, char order) { vector<int> result; vector<int> A = conv_vec(st_A), B = conv_vec(st_B); if (order == 'u') { set_union(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'i') { set_intersection(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'd') { set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 's') { set_symmetric_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } else if (order == 'c') { set_difference(begin(A), end(A), begin(B), end(B), inserter(result, end(result))); } //show(A, B, order, result); return conv_set(result); } int p_skip(string str, int p) { int cnt = 1; while(p < str.size()) { if (str[p] == '(') { ++cnt; } else if (str[p] == ')') { --cnt; } ++p; if (cnt == 0) { break; } } return p; } set<int> parse(string str, M dataset, int start) { int p = start; set<int> A, B; if (str[p] == '(') { p += 1; A = parse(str, dataset, p); p = p_skip(str, p); } else if (str[p] == 'c') { p += 1; if(str[p] == '(') { p += 1; A = parse(str, dataset, p); p = p_skip(str, p); } else { A = dataset[str[p]]; p += 1; } A = calc(dataset['U'], A, 'c'); } else { A = dataset[str[p]]; p += 1; } while(p < str.size()) { if (((string)("uids")).find(str[p]) == string::npos) { break; } char order = str[p]; ++p; if (str[p] == '(') { p += 1; B = parse(str, dataset, p); p = p_skip(str, p); } else if (str[p] == 'c') { p += 1; if(str[p] == '(') { p += 1; B = parse(str, dataset, p); p = p_skip(str, p); } else { B = dataset[str[p]]; p += 1; } B = calc(dataset['U'], B, 'c'); } else { B = dataset[str[p]]; p += 1; } A = calc(A, B, order); } return A; } void solve(string str, M dataset) { set<int> result = parse(str, dataset, 0); if (result.empty()) { cout << "NULL" << endl; return; } int cnt = 0; sort(result.begin(), result.end()); for (set<int>::iterator it = result.begin(); it != result.end(); ++it) { if (cnt == (int)(result.size())-1) { cout << *it << endl; } else { cout << *it << " "; cnt += 1; } } return; } int main() { char s; int t; set<int> U; string str; M dataset; while(!cin.eof()) { cin >> s >> t; if(s == 'R'){ cin >> str; //cout << "str: " << str << endl; dataset['U'] = U; solve(str, dataset); dataset.clear(); U.clear(); continue; } set<int> st; int u; for (int i = 0; i < t; i += 1) { cin >> u; st.insert(u); U.insert(u); } dataset[s] = st; } return 0; }
In file included from /usr/include/c++/14/algorithm:61, from a.cc:8: /usr/include/c++/14/bits/stl_algo.h: In instantiation of 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = _Rb_tree_const_iterator<int>; _Compare = __gnu_cxx::__ops::_Iter_less_iter]': /usr/include/c++/14/bits/stl_algo.h:4772:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = _Rb_tree_const_iterator<int>]' 4772 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:148:9: required from here 148 | sort(result.begin(), result.end()); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1906:50: error: no match for 'operator-' (operand types are 'std::_Rb_tree_const_iterator<int>' and 'std::_Rb_tree_const_iterator<int>') 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~^~~~~~~~~ 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:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 618 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algo.h:1906:50: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::reverse_iterator<_Iterator>' 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1790 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_algo.h:1906:50: note: 'std::_Rb_tree_const_iterator<int>' is not derived from 'const std::move_iterator<_IteratorL>' 1906 | std::__lg(__last - __first) * 2, | ~~~~~~~^~~~~~~~~
s830159535
p00598
C++
#include<bits/stdc++.h> using namespace std; #define r(i,n) for(int i=0;i<n;i++) int x,p,n; char c; string S; set<int>st[6],uni; set<int>bnf(); set<int>::iterator it; void Prin(set<int> ans){ if(!ans.size())cout<<"NULL"<<endl; else for(it=ans.begin();it!=ans.end();it++){ if(it!=ans.begin())cout<<' '; cout<<*it; } cout<<endl; } set<int> U(set<int> a,set<int> b){ set<int>s=b; it=a.begin(); while(it!=a.end())s.insert(*it),it++; return s; } set<int> I(set<int> a,set<int> b){ set<int>s; it=a.begin(); while(it!=a.end()){ if(b.count(*it))s.insert(*it); it++; } return s; } set<int> D(set<int> a,set<int> b){ set<int>s; it=a.begin(); while(it!=a.end()){ if(!b.count(*it))s.insert(*it); it++; } return s; } set<int> C(set<int> a,set<int> b){ set<int>s; it=a.begin(); while(it!=a.end()){ if(!b.count(*it))s.insert(*it); it++; } return s; } set<int> ge(){ set<int>s; if(S[p]=='(')p++,s=bnf(),p++; else if(S[p]=='c')p++,s=C(uni,st[S[p++]-'A']); else if('A'<=S[p]&&S[p]<='Z')s=st[S[p++]-'A']; return s; } set<int> bnf(){ set<int>s=ge(); while('a'<=S[p]&&S[p]<='z'){ int t=p++; set<int>g=ge(); if(S[t]=='u')s=U(s,g); if(S[t]=='i')s=I(s,g); if(S[t]=='d')s=D(s,g); if(S[t]=='s')s=U(D(s,g),D(g,s)); } return s; } main(){ while(cin>>c){ p=0; uni.clear(); r(i,6)st[i].clear(); cin>>n; r(i,n)cin>>x,st[c-'A'].insert(x),uni.insert(x); while(1){ cin>>c>>n; if(c=='R')break; r(i,n)cin>>x,st[c-'A'].insert(x),uni.insert(x); } cin>>S; set<int>ans=bnf();if(and.size()==0)exit(0); Prin(ans); } }
a.cc:70:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 70 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:83:29: error: expected identifier before '.' token 83 | set<int>ans=bnf();if(and.size()==0)exit(0); | ^ a.cc:83:29: error: expected ')' before '.' token 83 | set<int>ans=bnf();if(and.size()==0)exit(0); | ~ ^ | )
s395018302
p00598
C++
#include<bits/stdc++.h> using namespace std; #define r(i,n) for(int i=0;i<n;i++) int x,p,n; char c; string S; set<int>st[6],uni; set<int>bnf(); set<int>::iterator it; void Prin(set<int> ans){ //if(!ans.size())cout<<"NULL"<<endl; for(it=ans.begin();it!=ans.end();it++){ if(it!=ans.begin())cout<<' '; cout<<*it; } if(!ans.size())cout<<"NULL"<<endl; cout<<endl; } set<int> U(set<int> a,set<int> b){ set<int>s=b; it=a.begin(); while(it!=a.end())s.insert(*it),it++; return s; } set<int> I(set<int> a,set<int> b){ set<int>s; it=a.begin(); while(it!=a.end()){ if(b.count(*it))s.insert(*it); it++; } return s; } set<int> D(set<int> a,set<int> b){ set<int>s; it=a.begin(); while(it!=a.end()){ if(!b.count(*it))s.insert(*it); it++; } return s; } set<int> C(set<int> a,set<int> b){ set<int>s; it=a.begin(); while(it!=a.end()){ if(!b.count(*it))s.insert(*it); it++; } return s; } set<int> ge(){ set<int>s; if(S[p]=='(')p++,s=bnf(),p++; else if(S[p]=='c'){ while(S[p]=='c')p++; s=C(uni,uni]); } else if('A'<=S[p]&&S[p]<='Z')s=st[S[p++]-'A']; return s; } set<int> bnf(){ set<int>s=ge(); while('a'<=S[p]&&S[p]<='z'){ int t=p++; set<int>g=ge(); if(S[t]=='u')s=U(s,g); if(S[t]=='i')s=I(s,g); if(S[t]=='d')s=D(s,g); if(S[t]=='s')s=U(D(s,g),D(g,s)); } return s; } main(){ while(cin>>c){ p=0; uni.clear(); r(i,6)st[i].clear(); cin>>n; r(i,n)cin>>x,st[c-'A'].insert(x),uni.insert(x); while(1){ cin>>c>>n; if(c=='R')break; r(i,n)cin>>x,st[c-'A'].insert(x),uni.insert(x); } cin>>S; set<int>ans=bnf(); Prin(ans); } }
a.cc: In function 'std::set<int> ge()': a.cc:57:15: error: expected ')' before ']' token 57 | s=C(uni,uni]); | ~ ^ | ) a.cc: At global scope: a.cc:74:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 74 | main(){ | ^~~~
s739893916
p00598
C++
#include <bits/stdc++.h> #include<iostream> #include<cstdio> #include<vector> #include<queue> #include<map> #include<cstring> #include<string> #include <math.h> #include<algorithm> // #include <boost/multiprecision/cpp_int.hpp> #include<functional> #define int long long #define inf 10000000000007 #define pa pair<int,int> #define ll long long #define pal pair<double,pa> #define ppa pair<pa,int> #define ppap pair<int,pa> #define ssa pair<string,int> #define mp make_pair #define pb push_back #define EPS (1e-10) #define equals(a,b) (fabs((a)-(b))<EPS) using namespace std; 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);} Point operator / (double a) {return Point(x/a,y/a);} double absv() {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; struct Segment{ Point p1,p2; }; 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; } bool parareru(Point a,Point b,Point c,Point d){ // if(abs(cross(a-b,d-c))<EPS)cout<<"dd "<<cross(a-b,d-c)<<endl; return abs(cross(a-b,d-c))<EPS; } double distance_ls_p(Point a, Point b, Point c) { if ( dot(b-a, c-a) < EPS ) return (c-a).absv(); if ( dot(a-b, c-b) < EPS ) return (c-b).absv(); return abs(cross(b-a, c-a)) / (b-a).absv(); } bool is_intersected_ls(Segment a,Segment b) { if(a.p1==b.p1||a.p2==b.p1||a.p1==b.p2||a.p2==b.p2) return false; if(parareru((a.p2),(a.p1),(a.p1),(b.p2))&&parareru((a.p2),(a.p1),(a.p1),(b.p1))){ // cout<<"sss"<<endl; if(dot(a.p1-b.p1,a.p1-b.p2)<EPS) return true; if(dot(a.p2-b.p1,a.p2-b.p2)<EPS) return true; if(dot(a.p1-b.p1,a.p2-b.p1)<EPS) return true; if(dot(a.p1-b.p2,a.p2-b.p2)<EPS) return true; return false; } else return ( cross(a.p2-a.p1, b.p1-a.p1) * cross(a.p2-a.p1, b.p2-a.p1) < EPS ) && ( cross(b.p2-b.p1, a.p1-b.p1) * cross(b.p2-b.p1, a.p2-b.p1) < EPS ); } double segment_dis(Segment a,Segment b){ if(is_intersected_ls(a,b))return 0; double r=distance_ls_p(a.p1, a.p2, b.p1); r=min(r,distance_ls_p(a.p1, a.p2, b.p2)); r=min(r,distance_ls_p(b.p1, b.p2, a.p2)); r=min(r,distance_ls_p(b.p1, b.p2, a.p1)); return r; } Point intersection_ls(Segment a, Segment b) { Point ba = b.p2-b.p1; double d1 = abs(cross(ba, a.p1-b.p1)); double d2 = abs(cross(ba, a.p2-b.p1)); double t = d1 / (d1 + d2); return a.p1 + (a.p2-a.p1) * t; } string itos( int i ) { ostringstream s ; s << i ; return s.str() ; } int gcd(int v,int b){ if(v>b) return gcd(b,v); if(v==b) return b; if(b%v==0) return v; return gcd(v,b%v); } double distans(double x1,double y1,double x2,double y2){ double rr=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2); return sqrt(rr); } /* int pr[100010]; //int inv[100010]; */ int beki(int wa,int rr,int warukazu){ if(rr==0) return 1ll; if(rr==1) return wa%warukazu; if(rr%2==1) return (beki(wa,rr-1,warukazu)*wa)%warukazu; int zx=beki(wa,rr/2,warukazu); return (zx*zx)%warukazu; } /* void gya(){ pr[0]=1; for(int i=1;i<100010;i++){ pr[i]=(pr[i-1]*i)%inf; } for(int i=0;i<100010;i++) inv[i]=beki(pr[i],inf-2); } */ //sort(ve.begin(),ve.end(),greater<int>()); //----------------kokomade tenpure------------ //vector<double> ans(100000000),ans2(100000000); /* int par[200100],ranks[200100],kosuu[200100]; void shoki(int n){ for(int i=0;i<n;i++){ par[i]=i; ranks[i]=0; kosuu[i]=1; } } int root(int x){ return par[x]==x ? x : par[x]=root(par[x]); } bool same(int x,int y){ return root(x)==root(y); } void unite(int x,int y){ x=root(x); y=root(y); int xx=kosuu[x],yy=kosuu[y]; if(x==y) return; if(ranks[x]<ranks[y]){ par[x]=y; kosuu[y]=yy+xx; } else { par[y]=x; if(ranks[x]==ranks[y]) ranks[x]=ranks[x]+1; kosuu[x]=yy+xx; } return; } */ string s; int it; vector<int> ve[5]; vector<int> V; vector<int> ch[5]; vector<int> U(vector<int> a1,vector<int> a2){ vector<int> ve; for(int i=0;i<a1.size();i++)ve.pb(a1[i]|a2[i]); return ve; } vector<int> I(vector<int> a1,vector<int> a2){ vector<int> ve; for(int i=0;i<a1.size();i++)ve.pb(a1[i]&a2[i]); return ve; } vector<int> S(vector<int> a1,vector<int> a2){ vector<int> ve; for(int i=0;i<a1.size();i++)ve.pb(a1[i]^a2[i]); return ve; } vector<int> D(vector<int> a1,vector<int> a2){ vector<int> ve; for(int i=0;i<a1.size();i++){ int r; if(a1[i]==1 && a2[i]==0) r=1; else r=0; ve.pb(r); } return ve; } vector<int> C(vector<int> a1){ vector<int> ve; for(int i=0;i<a1.size();i++)ve.pb(1-a1[i]); return ve; } vector<int> shiki(); vector<int> han(){ // cout<<s[it]<<endl; if(s[it]=='c'){ it++; vector<int> e=ka(); return C(e); } else{ it++; return ch[s[it-1]-'A']; } } vector<int> ka(){ if(s[it]=='('){ it++; vector<int> q=shiki(); it++; return q; } else return han(); } vector<int> shiki(){ vector<int> r= ka(); while(s[it]=='u'||s[it]=='s'||s[it]=='d'||s[it]=='i'){ char c=s[it]; it++; vector<int> r2=ka(); if(c=='u') r=U(r,r2); if(c=='s') r=S(r,r2); if(c=='d') r=D(r,r2); if(c=='i') r=I(r,r2); } return r; } int cnt=0; signed main(){ char c; int d; while(1){ cnt++; // if(cnt>20) break; while(1){ cin>>c>>d; if(c=='R') break; for(int i=0;i<d;i++){ int r; cin>>r; ve[c-'A'].pb(r); } } set<int> se; for(int i=0;i<5;i++)for(int j=0;j<ve[i].size();j++)se.insert(ve[i][j]); V.clear(); for(auto its=se.begin();its!=se.end();its++){ V.pb(*its); } for(int i=0;i<5;i++){ for(int j=0;j<V.size();j++){ bool b=false; for(int k=0;k<ve[i].size();k++){ if(ve[i][k]==V[j]) b=true; } if(b) ch[i].pb(1); else ch[i].pb(0); } // for(int j=0;j<V.size();j++)cout<<ch[i][j]; // cout<<endl; } it=0; cin>>s; s+="*"; vector<int> ans=shiki(); bool r=false; for(int i=0;i<ans.size();i++)if(ans[i]) r=true, cout<<V[i]<<" "; if(!r) cout<<"NULL"; cout<<endl; } return 0; }
a.cc: In function 'std::vector<long long int> han()': a.cc:220:23: error: 'ka' was not declared in this scope; did you mean 'pa'? 220 | vector<int> e=ka(); | ^~ | pa
s535377744
p00598
C++
#include <iostream> #include <algorithm> #include <vector> #include <iterator> #include <string> #include <set> #include <map> using namespace std; #define State string::const_iterator class ParseError {}; vector<int> U;//mapを使った方が楽。 map<char, vector<int>> sets; vector<int> expression(State &begin); vector<int> com(State &begin); vector<int> _set(State &begin); vector<int> factor(State &begin); inline void consume(State &begin, char expected); vector<int> dif(vector<int> my_left, vector<int>my_right){ vector<int> ret = {}; std::set_difference(my_left.begin(), my_left.end(), my_right.begin(), my_right.end(), std::inserter(ret, ret.end())); return ret; } // 四則演算の式をパースして、その評価結果を返す。 vector<int> expression(State &begin) { vector<int> my_left = factor(begin); vector<int> ret = {}; while(true){ if(*begin == 'u'){ consume(begin, 'u'); vector<int> my_right = factor(begin); set_union(std::begin(my_left), std::end(my_left), std::begin(my_right), std::end(my_right), std::inserter(ret, std::end(ret))); } else if(*begin == 'i'){ consume(begin, 'i'); vector<int> my_right = factor(begin); set_intersection(std::begin(my_left), std::end(my_left), std::begin(my_right), std::end(my_right), std::inserter(ret, std::end(ret))); } else if(*begin == 'd'){ consume(begin, 'd'); vector<int> my_right = factor(begin); ret = dif(my_left, my_right); } else if(*begin == 's'){ consume(begin, 's'); vector<int> my_right = factor(begin); set_symmetric_difference(std::begin(my_left), std::end(my_left), std::begin(my_right), std::end(my_right), std::inserter(ret, std::end(ret))); } else{ break; } } return ret; } // 乗算除算の式をパースして、その評価結果を返す。 vector<int> com(State &begin) { vector<int> ret = {}; if(*begin == 'c'){ consume(begin, 'c'); vector<int> v = factor(begin); sort(v.begin(), v.end()); ret = dif(U, v); } else { ret = sets[*begin]; sort(ret.begin(), ret.end()); begin++; } return ret; } // 数字の列をパースして、その数を返す。 vector<int> _set(State &begin) { vector<int> ret; if(*begin == 'A'){ consume(begin, 'A'); ret = A; } else if(*begin == 'B'){ consume(begin, 'B'); ret = B; } else if(*begin == 'C'){ consume(begin, 'C'); ret = C; } else if(*begin == 'D'){ consume(begin, 'D'); ret = D; } else if(*begin == 'E'){ consume(begin, 'E'); ret = E; } return ret; } // 括弧か数をパースして、その評価結果を返す。 vector<int> factor(State &begin) { if (*begin == '(') { consume(begin, '('); // '('を飛ばす。 vector<int> ret = expression(begin); consume(begin, ')'); // ')'を飛ばす。 return ret; } else { return com(begin); } } // beginがexpectedを指していたらbeginを一つ進める。 inline void consume(State &begin, char expected) { if (*begin == expected) { begin++; } else { cerr << "Expected '" << expected << "' but got '" << *begin << "'" << endl; cerr << "Rest string is '"; while (*begin) { cerr << *begin++; } cerr << "'" << endl; throw ParseError(); } } int main() { while(true) { set<int> u; while (true) { char se; int n; cin >> se >> n; if (se == 'R') { break; } else{ for(int i=0; i<n; i++){ int input; cin >> input; sets[se].push_back(input); u.insert(input); } } } for(pair<char,vector<int>> v : sets){ sort(v.second.begin(), v.second.end()); cout << v.first << " : "; for(int num : v.second){ cout << num << " "; } cout << endl; } for (int num : u) { U.push_back(num); } string formula; cin >> formula; if(formula == "shutdown"){ break; } State begin = formula.begin(); vector<int> ans = expression(begin); if (ans.size() == 0) { cout << "NULL" << endl; } else { cout << ans[0]; for (int i = 1; i < ans.size(); i++) { cout << " " << ans[i]; } cout << endl; } } return 0; }
a.cc: In function 'std::vector<int> _set(std::__cxx11::basic_string<char>::const_iterator&)': a.cc:91:15: error: 'A' was not declared in this scope 91 | ret = A; | ^ a.cc:95:15: error: 'B' was not declared in this scope 95 | ret = B; | ^ a.cc:99:15: error: 'C' was not declared in this scope 99 | ret = C; | ^ a.cc:103:15: error: 'D' was not declared in this scope 103 | ret = D; | ^ a.cc:107:15: error: 'E' was not declared in this scope 107 | ret = E; | ^
s246349873
p00598
C++
#include <iostream> #include <string> #include <set> #include <map> #define rep(i,n) for(int i=0;i<n;++i) using namespace std; typedef set<int> iset; string src; int p; iset set_u; map<char, iset> sets; iset parse_expr(); // proto bool end() { return p >= (int)src.length(); } char peek() { return src[p]; } void succ() { if (!end()) ++p; } iset set_union(const iset &sa, const iset &sb) { iset us = sa; for (iset::const_iterator it = sb.begin(); it != sb.end(); ++it) { us.insert(*it); } return us; } iset set_intersect(const iset &sa, const iset &sb) { iset is; for (iset::const_iterator it = sb.begin(); it != sb.end(); ++it) { if (sa.find(*it) != sa.end()) is.insert(*it); } return is; } iset set_diff(const iset &sa, const iset &sb) { iset ds = sa; for (iset::const_iterator it = sb.begin(); it != sb.end(); ++it) { ds.erase(*it); } return ds; } iset set_syndiff(const iset &sa, const iset &sb) { return set_union(set_diff(sa, sb), set_diff(sb, sa)); } iset set_compl(const iset &s) { iset cs = set_u; for (iset::const_iterator it = s.begin(); it != s.end(); ++it) { cs.erase(*it); } return cs; } iset parse_primary() { iset s; char c = peek(); switch (c) { case 'c': succ(); s = set_compl(parse_primary()); break; case '(': succ(); s = parse_expr(); if (peek() == ')') succ(); break; default: succ(); s = sets[c]; break; } return s; } bool is_op() { char c = peek(); return c=='u'||c=='i'||c=='d'||c=='s'; } iset parse_expr() { iset a = parse_primary(); while (!end() && is_op()) { char op = peek(); succ(); iset b = parse_primary(); switch (op) { case 'u': a = set_union(a, b); break; case 'i': a = set_intersect(a, b); break; case 'd': a = set_diff(a, b); break; case 's': a = set_syndiff(a, b); break; } } return a; } iset parse() { p = 0; return parse_expr(); } int main() { while(!cin.eof()) { char name; int N, e; sets.clear(); set_u.clear(); while(cin >> name >> N, name != 'R') { rep(i,N) { cin >> e; sets[name].insert(e); set_u.insert(e); } } cin >> src; iset s = parse(); if (s.size() == 0) { cout << "NULL" << endl; continue; } for (iset::const_iterator &it = s.begin(); it != s.end(); ++it) { if (it != s.begin()) cout << " "; cout << *it; } cout << endl; } return 0; }
a.cc: In function 'int main()': a.cc:160:56: error: cannot bind non-const lvalue reference of type 'std::set<int>::const_iterator&' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator&'} to an rvalue of type 'std::set<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} 160 | for (iset::const_iterator &it = s.begin(); it != s.end(); ++it) | ~~~~~~~^~
s302043450
p00599
C++
#include <iostream> #include <list> #include <math.h> #define REP(i, n) for(int (i) = 0; (i) < (n); (i)++) #define EQF(a, b) (fabs((a) - (b)) < EPS) const double EPS = 0.1; class Vector { double x, y; int angle; public: Vector() : x(0.0), y(0.0) {} Vector(double x, double y) : x(x), y(y) {} explicit Vector(std::istream &input) { input >> x >> y; } Vector(const Vector &v) : x(v.x), y(v.y), angle(v.angle) {} Vector operator+(const Vector &v) const { return Vector(x + v.x, y + v.y); } Vector operator-(const Vector &v) const { return Vector(x - v.x, y - v.y); } double operator*(const Vector &v) const { return x * v.x + y * v.y; } Vector operator*(double s) const { return Vector(x * s, y * s); } Vector operator/(double s) const { return Vector(x / s, y / s); } double operator^(const Vector &v) const { return x * v.y - y * v.x; } Vector &operator=(const Vector &v) { x = v.x; y = v.y; angle = v.angle; return *this; } Vector scale(double s) const { return Vector(x * s, y * s); } double size() const { return sqrt(x * x + y * y); } Vector normalize() const { return *this / size(); } void print() const { std::cout << "(" << x << ", " << y << ")" << std::endl; } void set_angle(int new_angle) { angle = new_angle; } int get_angle() { return angle; } }; Vector operator*(double s, const Vector &v) { return v.scale(s); } class NumericException : public std::exception { std::string msg; public: NumericException() : msg("") {} explicit NumericException(const std::string &msg) : msg(msg) {} virtual ~NumericException() throw() {} const char *what() const throw() { return msg.c_str(); } }; std::list<Vector> vertex_list; std::list<std::list<Vector> > save_stack; int large_num, small_num; void dump() { for(std::list<Vector>::iterator i = vertex_list.begin(); i != vertex_list.end(); i++) { std::cout << i->get_angle() << ", "; } std::cout << std::endl; } int solve_recursive() { if(vertex_list.size() < 3) return 0; save_stack.push_back(std::list<Vector>(vertex_list)); while(1) { int flag = false; for(std::list<Vector>::iterator i = vertex_list.begin(); i != vertex_list.end(); i++) { std::list<Vector>::iterator prev = i; std::list<Vector>::iterator next = i; if(prev == vertex_list.begin()) prev = vertex_list.end(); prev--; next++; if(next == vertex_list.end()) next = vertex_list.begin(); if(i->get_angle() % 360 == 0) { prev->set_angle(prev->get_angle() + next->get_angle() - 360); i = vertex_list.erase(i); if(vertex_list.size() < 3) return 0; vertex_list.erase(next); if(vertex_list.size() < 3) return 0; flag = true; simp_count++; break; } } if(!flag) break; } if(vertex_list.size() < 3) return 0; for(std::list<Vector>::iterator i = vertex_list.begin(); i != vertex_list.end(); i++) { std::list<Vector>::iterator prev = i; std::list<Vector>::iterator next = i; if(prev == vertex_list.begin()) prev = vertex_list.end(); prev--; next++; if(next == vertex_list.end()) next = vertex_list.begin(); int i_old = i->get_angle(); int prev_old = prev->get_angle(); int next_old = next->get_angle(); switch(i->get_angle()) { case 36: if(prev->get_angle() >= 144 && next->get_angle() >= 144) { i->set_angle(324); prev->set_angle(prev->get_angle() - 144); next->set_angle(next->get_angle() - 144); small_num++; if(solve_recursive() == 0) return 0; small_num--; } break; case 72: if(prev->get_angle() >= 108 && next->get_angle() >= 108) { i->set_angle(288); prev->set_angle(prev->get_angle() - 108); next->set_angle(next->get_angle() - 108); large_num++; if(solve_recursive() == 0) return 0; large_num--; } break; case 108: if(prev->get_angle() >= 72 && next->get_angle() >= 72) { i->set_angle(252); prev->set_angle(prev->get_angle() - 72); next->set_angle(next->get_angle() - 72); large_num++; if(solve_recursive() == 0) return 0; large_num--; } break; case 144: if(prev->get_angle() >= 36 && next->get_angle() >= 36) { i->set_angle(216); prev->set_angle(prev->get_angle() - 36); next->set_angle(next->get_angle() - 36); small_num++; if(solve_recursive() == 0) return 0; small_num--; } break; default: continue; } i->set_angle(i_old); prev->set_angle(prev_old); next->set_angle(next_old); } vertex_list = save_stack.back(); save_stack.pop_back(); return 1; } int main() { while(1) { try { int vertex_num; std::cin >> vertex_num; if(std::cin.eof()) break; if(vertex_num < 3) throw NumericException("Please specify more than 2 vertices"); large_num = 0; small_num = 0; std::list<Vector> input_list; REP(i, vertex_num) { input_list.push_back(Vector(std::cin)); } Vector prev = input_list.back(); for(std::list<Vector>::iterator i = input_list.begin(); i != input_list.end(); i++) { Vector diff = (*i) - prev; if(!EQF(diff.size(), round(diff.size()))) throw NumericException("Edge length must be integer"); int segment_num = static_cast<int>(round(diff.size()) + EPS); for(int j = 1; j <= segment_num; j++) { vertex_list.push_back(prev + (double)j * diff.normalize()); } prev = (*i); } for(std::list<Vector>::iterator i = vertex_list.begin(); i != vertex_list.end(); i++) { std::list<Vector>::iterator prev = i; std::list<Vector>::iterator next = i; if(prev == vertex_list.begin()) { prev = vertex_list.end(); } prev--; next++; if(next == vertex_list.end()) { next = vertex_list.begin(); } Vector prev_diff = (*i - *prev).normalize(); Vector next_diff = (*next - *i).normalize(); double dot = prev_diff * next_diff; if(dot < -1.0) dot = -1.0; if(dot > 1.0) dot = 1.0; double bend = acos(dot) / M_PI * 180.0; if(!EQF(bend, round(bend))) throw NumericException("Corner angles must be integer"); int bend_i = 180 - round(bend); if((prev_diff ^ next_diff) < -EPS) bend_i = 360 - bend_i; if(bend_i % 36) throw NumericException("Corner angles must be multiple of 36"); i->set_angle(bend_i); } if(solve_recursive()) throw NumericException("The given test case could not be solved"); std::cout << small_num << " " << large_num << std::endl; } catch(NumericException e) { std::cout << "-1 -1" << std::endl; } } return 0; }
a.cc: In function 'int solve_recursive()': a.cc:79:33: error: 'simp_count' was not declared in this scope 79 | simp_count++; | ^~~~~~~~~~
s241831491
p00599
C++
#include<complex> #include<set> #include<vector> #include<iostream> #include<fstream> #include<stack> #include<cmath> #define SHAPE_A 1 #define SHAPE_B 2 #define FRONT 0x01 #define RIGHT 0x02 #define BACK 0x04 #define LEFT 0x08 #define OVER 0x10 #define sc second #define fr first #define REP(i,n) for(int i = 0; i < (int)(n); ++i) #define CUR(i,n) (i%n) #define NEXT(i,n) ((i+1)%n) #define PREV(i,n) ((i-1+n)%n) using namespace std; typedef double elem; typedef complex<elem> point, vec; typedef pair<point, point> line, hline, seg, pp; const elem eps = 1.0e-4; const elem infty = 1e40; const elem pi = acos(-1.0); point base(0,0); // o—Í ostream &operator<<(ostream &os, const pair<point,point> &p){ os << p.fr << "-" << p.sc; return os; } // ”’l‰‰ŽZ inline elem sq(elem a){ return a*a; } inline elem cq(elem a){ return a*a*a; } // Šp“x•ÏŠ· elem rad(elem deg){ return (deg/180)*pi; } elem deg(elem rad){ return (rad*180)/pi; } // •‚“®¬”“_‚ÌŽô‚¢A‚È‚Ç bool eq(elem a, elem b){ return abs(a-b) < eps; } bool lt(elem a, elem b){ return !eq(a,b) && a < b; } bool leq(elem a, elem b){ return eq(a,b) || a < b; } bool gt(elem a, elem b){ return !eq(a,b) && a > b; } bool geq(elem a, elem b){ return eq(a,b) || a > b; } bool ltz(elem a){ return lt( a, 0 ); } bool gtz(elem a){ return gt( a, 0 ); } bool eqv(vec a, vec b){ return eq( abs(b-a),0); } bool is_zv(vec v){ return eq(abs(v),0); } elem emax(elem a, elem b){ return gt(a,b)?a:b; } elem emin(elem a, elem b){ return lt(a,b)?a:b; } bool lesspoint(const point &a, const point &b){ return !eq( a.real(), b.real() ) ? lt( a.real(), b.real() ) : lt( a.imag(), b.imag() ); } // “_ƒIƒyƒŒ[ƒ^ bool far(point a, point b){ return gtz( abs(b-a) ); } bool near(point a, point b){ return leq( abs(b-a), 0 ); } elem dot(vec a, vec b){ return (a.real() * b.real() + a.imag() * b.imag() ); } elem cross(vec a, vec b){ return ( a.real() * b.imag() - a.imag() * b.real() ); } // a‚©‚çb‚܂ŎžŒv‰ñ‚è‚ÌŠp“xA“àŠpA“]‰ñ“] elem varg(vec a, vec b){ elem ret=arg(a)-arg(b); if(lt(ret,0))ret+=2*pi; if(gt(ret,2*pi))ret-=2*pi; if(eq(ret,2*pi))ret=0; return ret; } elem arg(vec a, vec b){ return acos( dot(a,b) / ( abs(a) * abs(b) ) ); } point rot(point p, elem theta){ return p * polar((elem)1.0, theta); } point rotdeg(point p, elem deg){ return p * polar((elem)1.0, rad(deg)); } point proj(line l, point p){ elem t=dot(p-l.first,l.first-l.second)/abs(l.first-l.second); return l.first + t*(l.first-l.second); } point reflect(line l, point p){ return p+(elem)2.0*(proj(l,p)-p); } // “ñ“_ŠÔ‹——£A’¼ü‚Æ“_‚̍ŒZ‹——£Aü•ª‚Æ“_‚̍ŒZ‹——£ elem dist(point a, point b){ return abs(a-b); } elem dist_l(line l, point x){ return abs(cross(l.sc-l.fr,x-l.fr)) / abs(l.sc-l.fr); } elem dist_seg(seg s, point x) { if( ltz( dot(s.sc-s.fr,x-s.fr) ) ) return abs(x-s.fr); if( ltz( dot(s.fr-s.sc,x-s.sc) ) ) return abs(x-s.sc); return dist_l(s,x); } // ’PˆÊƒxƒNƒgƒ‹A–@üƒxƒNƒgƒ‹A’PˆÊ–@üƒxƒNƒgƒ‹ vec uvec(vec a){ return a / abs(a); } vec nmr(vec a){ return a * vec(0,-1); } vec nml(vec a){ return a * vec(0,1); } vec unmr(vec a){ return uvec( nmr(a) ); } vec unml(vec a){ return uvec( nml(a) ); } // ’¼ŒðA•½s”»’è bool orth(point a1, point a2, point b1, point b2){ return eq( dot( a2 - a1, b2 - b1 ), 0 ); } bool orth(vec v1, vec v2){ return eq( dot(v1, v2), 0 ); } bool prll(point a1, point a2, point b1, point b2){ return eq( cross( a2 - a1, b2 - b1 ), 0 ); } bool prll(vec v1, vec v2){ return eq( cross(v1, v2), 0 ); } // CCW ƒƒoƒXƒg‚¾‚ªA¸“x‚É‚æ‚é int ccw(point a, point b, point x){ b -= a; x -= a; // if( is_zv(b) || is_zv( x ) ) return ERROR; if( gtz( cross(b,x) ) ) return LEFT; if( ltz( cross(b,x) ) ) return RIGHT; if( ltz( dot(b,x) ) ) return BACK; if( lt( abs(b), abs(x) ) ) return FRONT; return OVER; } // ü•ª‚ÌŒð·”»’è bool intersectedSS(seg a, seg b) { if( ccw(a.fr,a.sc,b.fr)&OVER || ccw(a.fr,a.sc,b.sc)&OVER ) return true; return ( ccw(a.fr,a.sc,b.fr) | ccw(a.fr,a.sc,b.sc) ) == (LEFT|RIGHT) && ( ccw(b.fr,b.sc,a.fr) | ccw(b.fr,b.sc,a.sc) ) == (LEFT|RIGHT) ; } // ’¼ü‚ÌŒð·”»’è bool intersectedLL(line a, line b){ return !eq( cross(a.sc-a.fr,b.sc-b.fr), 0.0 ); } // Œð“_ŒvŽZ point intersectionSS(seg a, seg b) { elem d1 = dist_l(b,a.fr); elem d2 = dist_l(b,a.sc); return a.fr + ( d1 / (d1 + d2 ) ) * (a.sc-a.fr); } point intersectionLL(line a, line b) { vec va = a.sc - a.fr; vec vb = b.sc - b.fr; return a.fr + va * ( cross(vb, b.fr - a.fr) / cross(vb,va) ); } // ü•ªŒð“_ˆêЇ”Å bool intersectionLL(line a, line b, point &ret){ return intersectedLL( a, b ) ? ret = intersectionLL( a, b ), true : false; } bool intersectionLH(line a, hline b, point &ret){ point tmp; return intersectionLL(a,b,tmp) ? ( ccw(b.fr,b.sc,tmp)&(OVER|FRONT) ? ret=tmp, true : false ) : false; } bool intersectionLS(line l, seg s, point &ret){ point tmp; return intersectionLL(l,s,tmp) ? ( ccw(s.fr,s.sc,tmp)&OVER ? ret=tmp, true : false ) : false; } bool intersectionHH(hline a, hline b, point &ret){ point tmp; return intersectionLL(a,b,tmp) ? ( ccw(a.fr,a.sc,tmp)&(OVER|FRONT)&&ccw(b.fr,b.sc,tmp)&(OVER|FRONT) ? ret = tmp, true : false ) : false; } bool intersectionHS(hline a, seg s, point &ret){ point tmp; return intersectionLS(a,s,tmp) ? ( ccw(a.fr,a.sc,tmp)&(OVER|FRONT) ? ret = tmp, true : false ) : false; } bool intersectionSS(seg a, seg b, point &ret){ return intersectedSS(a,b) ? ret = intersectionSS(a,b), true : false; } // ’Pƒ‘½ŠpŒ`‚Ì“à•ï”»’è(‹«ŠEüŠÜ‚Þ,’¸“_‚Æ“¯‚¶ˆÊ’u‚É—^‚¦‚ç‚ꂽê‡ƒƒoƒXƒg‚È”»’è‚͏o—ˆ‚È‚¢) bool inSimple(point x, const vector<point> &p) { elem rad = 0; int n = p.size(); for(int i = 0; i < n; ++i){ int sign = 1; int cw = ccw(x,p[i],p[(i+1)%n]); int cw2 = ccw( p[i],p[(i+1)%n],x); if( near( x,p[i] ) ) return true; if( cw2 == OVER ) return true; if( cw & OVER ) continue; if( cw & RIGHT ) sign = -1; rad += sign * arg( vec(p[i]-x), vec(p[(i+1)%n]-x) ); } return eq( rad, 2*pi ); } // ’Pƒ‘½ŠpŒ`‚Ì“à•ï”»’è(‹«ŠEüŠÜ‚܂Ȃ¢) bool insideSimple(point x, const vector<point> &p) { elem rad = 0; int n = p.size(); for(int i = 0; i < n; ++i){ int sign = 1; int cw = ccw(x,p[i],p[(i+1)%n]); int cw2 = ccw( p[i],p[(i+1)%n],x); if( near( x,p[i] ) ) return false; if( cw2 == OVER ) return false; if( cw & OVER ) continue; if( cw & RIGHT ) sign = -1; rad += sign * arg( vec(p[i]-x), vec(p[(i+1)%n]-x) ); } return eq( rad, 2*pi ); } static const elem shapeAdiag_l = 2. * cos(rad(18.0)); //*sqrt(1-(2.*(1.-cos(rad(36.0)))/4.)); static const elem shapeBdiag_l = 2. * cos(rad(36.0)); // sqrt(1-(2.*(1.-cos(rad(72.0)))/4.)); static const elem shapeBdiag_s = 2. * sin(rad(36.0)); // sqrt(1-(2.*(1.-cos(rad(144.0)))/4.)); static const elem shapeAdiag_s = 2. * sin(rad(18.0)); //sqrt(1-(2.*(1.-cos(rad(108.0)))/4.)); inline elem polArg(const vector<point> &vp, int i, int n){ vec a(vp[PREV(i,n)]-vp[CUR(i,n)]); vec b(vp[NEXT(i,n)]-vp[CUR(i,n)]); return varg(a,b); } elem minArg(const vector<point> &vp){ elem ret = infty; int n = vp.size(); for(int i = 0; i < n; ++i){ // cout << "VERTEX " << i << " : arg = " << polArg(vp,i,n) << endl; ret = min( ret, polArg( vp, i, n ) ); } return ret; } bool lineWrapping(line a, line b){ // whether a wraps b if( leq( abs(b.sc-b.fr), abs(a.sc-a.fr) ) ){ if( ccw( a.fr, a.sc, b.fr ) == OVER && ccw(a.fr, a.sc, b.sc ) == OVER ) return true; } return false; } class Point{ public: point p; Point():p(0.0,0.0){} Point(point p):p(p){} bool operator<(const Point &t)const{ return !eq( p.real(), t.p.real() ) ? lt( p.real(), t.p.real() ) : lt( p.imag(), t.p.imag() ); } }; bool embed_slave(elem minarg, int i, const vector<point> &vp, int &chooseShape, point &prev, point &diag, point &next){ int n = vp.size(); chooseShape = SHAPE_A; vec va(vp[PREV(i,n)]-vp[CUR(i,n)]); vec vb(vp[NEXT(i,n)]-vp[CUR(i,n)]); vec vc; va = uvec( va ); vb = uvec( vb ); if( eq( minarg, rad(36.0) ) ){ vc = shapeAdiag_l * uvec( (va+vb)/(elem)2. ); }else if( eq( minarg, rad(72.0) ) ){ chooseShape = SHAPE_B, vc = shapeBdiag_l * uvec( (va+vb)/(elem)2. ); }else if( eq( minarg, rad(108.0) ) ){ chooseShape = SHAPE_B, vc = shapeBdiag_s * uvec( (va+vb)/(elem)2. ); }else if( eq( minarg, rad(144.0) ) ){ vc = shapeAdiag_s * uvec( (va+vb)/(elem)2. ); }else{ return false; } prev = vp[CUR(i,n)]+va; diag = vp[CUR(i,n)]+vc; next = vp[CUR(i,n)]+vb; return true; } void incIt(vector<point>::iterator &it, vector<point> &v, int n){ assert(v.size()>1); if(it==v.end())it=v.begin(); while(n>0){ it++;if(it==v.end())it=v.begin();--n; } } void decIt(vector<point>::iterator &it, vector<point> &v, int n){ assert(v.size()>1); while(n>0){ if(it==v.begin())it=v.end();--it;--n; } if(it==v.end())--it; } bool embed(elem minarg, const vector<point> &vp, vector<point> &next, int &nShapeA, int &nShapeB){ int n = vp.size(); bool allskip = false; //cout << "MINARG : " << minarg << endl; /* ’Pƒ‚ɐ}Œ`‚ð‘}“ü‚Å‚«‚éê‡ */ vector<point> tmp; for(int i = 0; i < n; ++i){ if( eq( minarg, polArg( vp, i, n ) ) && !allskip ){ int chooseShape; point pprev, pdiag, pnext; if( !embed_slave( minarg, i, vp, chooseShape, pprev, pdiag, pnext ) ) return false; if( insideSimple( pdiag, vp ) && inSimple( pprev, vp ) && inSimple( pnext, vp ) ){ //cout << " ADD : " << i << endl; tmp.push_back( pprev ); tmp.push_back( pdiag ); tmp.push_back( pnext ); chooseShape == SHAPE_A ? ++nShapeA : ++nShapeB; allskip=true; }else{ tmp.push_back( vp[i] ); } }else{ tmp.push_back( vp[i] ); } } /* ’Pƒ‚ɐ}Œ`‚ð‘}“ü‚Å‚«‚È‚¢ê‡iŠOŒ`‚ª‘å‚«‚­•Ï‚í‚éj */ if( !allskip ){ int insertion_point = -1; int max_linewrap = 0; int chooseShape; point pprev, pdiag, pnext; set<Point> vis; for(int i = 0; i < n; ++i){ vis.insert( Point( vp[i] ) ); if( eq( minarg, polArg( vp, i, n ) ) && !allskip ){ int nWrap = 0; if( !embed_slave( minarg, i, vp, chooseShape, pprev, pdiag, pnext ) ) return false; line L[4]; L[0]=line(vp[CUR(i,n)],pprev); L[1]=line(vp[CUR(i,n)],pnext); L[2]=line(pdiag,pprev); L[3]=line(pdiag,pnext); if( !inSimple(pprev,vp)||!inSimple(pnext,vp)||!inSimple(pdiag,vp) )continue; for(int k = 0; k < 4; ++k){ for(int j = 0; j < n; ++j){ line l(vp[CUR(j,n)],vp[NEXT(j,n)]); if( lineWrapping( l, L[k] ) ){ ++nWrap; break; } } } if( nWrap > max_linewrap ){ insertion_point = i; max_linewrap = nWrap; } } } if( insertion_point < 0 ) return false; embed_slave( minarg, insertion_point, vp, chooseShape, pprev, pdiag, pnext ); // cout << " WRAP : " << max_linewrap << endl; if ( max_linewrap <= 2 ){ tmp.erase( tmp.begin() + insertion_point ); tmp.insert( tmp.begin() + insertion_point, pnext ); tmp.insert( tmp.begin() + insertion_point, pdiag ); tmp.insert( tmp.begin() + insertion_point, pprev ); }else{ bool front=false; int cnt = 0; n=tmp.size(); for(int j = insertion_point; cnt < 2; ++j,++cnt){ //cout << "DEBUG : " << tmp[CUR(j,n)] << ' ' << tmp[NEXT(j,n)] << ' ' << pdiag << endl; if( ccw(tmp[CUR(j,n)], tmp[NEXT(j,n)], pdiag ) == OVER ){ front = true; break; } } //cout << insertion_point << " : " << tmp[insertion_point] << endl; if( front ){ //cout << "FRONT" << endl; vector<point>::iterator its = tmp.begin()+insertion_point; incIt(its,tmp,2); its = tmp.insert( its, pdiag ); decIt(its,tmp,1); its = tmp.erase( its ); decIt(its,tmp,1); its = tmp.erase( its ); tmp.insert( its, pprev ); }else{ //cout << "BACK" << endl; vector<point>::iterator its = tmp.begin()+insertion_point; decIt(its,tmp,1); its = tmp.insert( its, pdiag ); incIt(its,tmp,1); its = tmp.erase( its ); incIt(its,tmp,1); its = tmp.insert( its, pnext ); //cout << *its << endl; ++its; decIt(its,tmp,2); // cout << *its << endl; its = tmp.erase( its ); } } chooseShape == SHAPE_A ? ++nShapeA : ++nShapeB; } /* ®‡«ˆ— */ set<Point> vis; n = tmp.size(); for(int i = 0; i < n; ++i){ if( vis.find( Point(tmp[CUR(i,n)]) ) == vis.end() ){ vis.insert( Point(tmp[CUR(i,n)]) ); next.push_back( tmp[CUR(i,n)] ); } } n = next.size(); for(int i = 0; i < n; ++i){ elem polarg = polArg(next,i,n); if( eq( polarg , 0.0 ) || eq( polarg, 2*pi ) ){ next.erase( next.begin() + i ); --n; --i; if( n < 3 ) break; } } n = next.size(); if( n >= 3 ){ for(int i = 0; i < n; ++i){ int cw = ccw( next[CUR(i,n)], next[NEXT(i,n)], next[NEXT(i+1,n)] ); if( cw == FRONT ){ next.erase( next.begin() + NEXT(i,n) ); --n; --i;if(i<0)i=n-1; }else if( cw == OVER ){ next.erase( next.begin() + NEXT(i+1,n) ); --n; --i;if(i<0)i=n-1; } if(n<3)break; } } return true; } int main(){ // ofstream ofs("visual.txt"); while(true){ int n; bool ans = true; int nShapeA=0; int nShapeB=0; vector<point> vp; vector<point> tmp; cin >> n; if( cin.eof() )break; for(int i=0;i<n;++i){double x,y;cin>>x>>y;vp.push_back(point(x,y));} elem scale = 1.0; elem offset = 0; n = vp.size(); /* for(int i = 0; i < n; ++i){ ofs << "line(" << vp[CUR(i,n)].real() << ',' << vp[CUR(i,n)].imag() << ',' << vp[NEXT(i,n)].real() << ',' << vp[NEXT(i,n)].imag() << ");" << endl; } ofs << "//----------------------------------- " << endl; */ while(true){ if( !embed( minArg(vp), vp, tmp, nShapeA, nShapeB ) ){ ans=false; break; } vp = tmp; tmp.clear(); /* cout << "NUMBER OF SHAPE : " << nShapeA << ' ' << nShapeB << endl; cout << "SIZE : " << vp.size() << endl; for(int i = 0; i < vp.size(); ++i){ cout << vp[i] << ' '; } cout << "\n--------------------------------" << endl; */ /* for visualizer */ elem scale = 1.0; elem offset = 0; int n = vp.size(); /* for(int i = 0; i < n; ++i){ ofs << "line(" << vp[CUR(i,n)].real() << ',' << vp[CUR(i,n)].imag() << ',' << vp[NEXT(i,n)].real() << ',' << vp[NEXT(i,n)].imag() << ");" << endl; } ofs << "//----------------------------------- " << endl; */ if( vp.size() <= 2 ) break; } if( ans ) cout << nShapeA << ' ' << nShapeB << endl; else cout << -1 << ' ' << -1 << endl; //ofs << "// END OF DATASET " << endl; } //ofs.close(); return 0; }
a.cc: In function 'void incIt(std::vector<std::complex<double> >::iterator&, std::vector<std::complex<double> >&, int)': a.cc:276:3: error: 'assert' was not declared in this scope 276 | assert(v.size()>1); | ^~~~~~ a.cc:8:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 7 | #include<cmath> +++ |+#include <cassert> 8 | a.cc: In function 'void decIt(std::vector<std::complex<double> >::iterator&, std::vector<std::complex<double> >&, int)': a.cc:283:3: error: 'assert' was not declared in this scope 283 | assert(v.size()>1); | ^~~~~~ a.cc:283:3: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
s576275933
p00599
C++
int main(){ cout << chinso << endl; }
a.cc: In function 'int main()': a.cc:1:13: error: 'cout' was not declared in this scope 1 | int main(){ cout << chinso << endl; } | ^~~~ a.cc:1:21: error: 'chinso' was not declared in this scope 1 | int main(){ cout << chinso << endl; } | ^~~~~~ a.cc:1:31: error: 'endl' was not declared in this scope 1 | int main(){ cout << chinso << endl; } | ^~~~
s727354024
p00599
C++
int main(){ cout << chinso << endl; }
a.cc: In function 'int main()': a.cc:1:13: error: 'cout' was not declared in this scope 1 | int main(){ cout << chinso << endl; } | ^~~~ a.cc:1:21: error: 'chinso' was not declared in this scope 1 | int main(){ cout << chinso << endl; } | ^~~~~~ a.cc:1:31: error: 'endl' was not declared in this scope 1 | int main(){ cout << chinso << endl; } | ^~~~
s598798350
p00599
C++
chinso
a.cc:1:1: error: 'chinso' does not name a type 1 | chinso | ^~~~~~
s119307045
p00599
C++
chinsososo
a.cc:1:1: error: 'chinsososo' does not name a type 1 | chinsososo | ^~~~~~~~~~
s786090887
p00599
C++
chinsaw
a.cc:1:1: error: 'chinsaw' does not name a type 1 | chinsaw | ^~~~~~~
s342590177
p00601
Java
import java.util.*; import java.lang.*; import java.math.*; import java.io.*; import static java.lang.Math.*; import static java.util.Arrays.*; import static java.util.Collections.*; public class Main{ Scanner sc=new Scanner(System.in); int INF=1<<28; double EPS=1e-12; int n, m; long[] g; int ans; void run(){ for(;;){ n=sc.nextInt(); m=sc.nextInt(); if((n|m)==0){ break; } g=new long[n]; for(int i=0; i<m; i++){ int u=sc.nextInt(); int v=sc.nextInt(); g[u]|=1L<<v; g[v]|=1L<<u; } solve(); } } void solve(){ ans=0; mis(0, 0); ans=n-ans+isolated; println(ans+""); } void mis(long choosed, long removed){ int k=-1; long remained=~removed&((1L<<n)-1); for(; remained!=0;){ int i=Long.numberOfTrailingZeros(remained); if(Long.bitCount(g[i]&~removed)<=1){ k=i; break; } if(k==-1||Long.bitCount(g[i]&~removed)>Long.bitCount(g[k]&~removed)) k=i; remained^=1L<<i; } if(k==-1){ ans=max(ans, Long.bitCount(choosed)); return; } if(Long.bitCount(g[k]&~removed)>=2) mis(choosed, removed|(1L<<k)); mis(choosed|(1L<<k), removed|(1L<<k)|g[k]); } void debug(Object... os){ System.err.println(Arrays.deepToString(os)); } void print(String s){ System.out.print(s); } void println(String s){ System.out.println(s); } public static void main(String[] args){ // System.setOut(new PrintStream(new BufferedOutputStream(System.out))); new Main().run(); } }
Main.java:40: error: cannot find symbol ans=n-ans+isolated; ^ symbol: variable isolated location: class Main 1 error
s115626249
p00601
Java
import java.io.*; import java.util.*; public class Main{ public static void main(String[] arg) throws IOException { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String is; String[] ia; while(true){ ia = in.readLine().split("[ \t]"); int x = Integer.parseInt(ia[0]); int y = Integer.parseInt(ia[1]); if(x == 0 && y == 0){ break; } l = new boolean[x][x]; v = new int[y][2]; ia = in.readLine().split(" "); for(int i = 0;i < y; ++i){ int a,b; v[i][0] = a = Integer.parseInt(ia[2*i]); v[i][1] = b = Integer.parseInt(ia[2*i+1]); l[a][b] = l[b][a] = true; } boolean solved = false; r = new boolean[x]; s = new boolean[y]; int c = 0; while(!solved){ ++c; Arrays.fill(r,true); Arrays.fill(s,true); solved = solve(c); } System.out.println(c); } } static int[][] v; static boolean[][] l; static boolean[] r,s; static boolean solve(int c){ if(c == 0){ return check(s); } for(int i = 0;i < r.length; ++i){ if(r[i]){ boolean[] t = r.clone(); boolean[] u = s.clone(); r[i] = false; for(int j = 0;j < l[i].length; ++j){ if(l[i][j]){ for(int k = 0;k < v.length; ++k){ if((v[k][0] == i && v[k][1] == j) || (v[k][1] == i && v[k][0] == j)){ s[k] = false; } } } } if(solve(c-1)){ return true; } r = t; s = u; } } return false; } static boolean check(boolean[] r){ for(int i = 0;i < r.length; ++i){ if(r[i]){ return false; } } return true; } }
Main.java:77: error: illegal character: '\uff5d' ? ^ Main.java:77: error: reached end of file while parsing ? ^ 2 errors
s954332620
p00601
C++
#include <iostream> #include <limits.h> #include <queue> #include <algorithm> #include <map> #include <cstring> #define dprintf(s,...) printf("%s:%d" s,__func__,__LINE__,__VA_ARGS__) using namespace std; typedef pair<int,int> P; typedef long long int ll; struct Edge{ int to; }; vector<Edge> G[30]; int x,y; bool checked[30]; int solve(){ fill(checked,checked+30,false); int ret=0,next=0,tmp=0; int deg[30]; for(int i=0;i<x;i++) deg[i]=G[i].size(); for(int i=0;i<x;i++){ if(deg[i]==1){ next=G[i][0].to; checked[i]=true; } } while(deg[next]>0){ tmp=next; checked[tmp]=true; if(deg[tmp]==2){//tmp is a part of D ret++; for(int i=0;i<G[tmp].size();i++){ Edge e = G[tmp][i]; deg[tmp]--;//remove the edges connecting tmp deg[e.to]--; if(!checked[e.to]) next=e.to; } } else if(deg[tmp]==1){ for(int i=0;i<G[tmp].size();i++) if(!checked[G[tmp][i].to]) next=G[tmp][i].to; } } return ret; } int main(){ sync_with_stdio(false); while(1){ cin>>x>>y; if(x==0 && y==0) break; int u,v; for(int i=0;i<y;i++){ cin>>u>>v; Edge e1,e2; e1.to=v; e2.to=u; G[u].push_back(e1); G[v].push_back(e2); } cout<<solve()<<endl; for(int i=0;i<x;i++) G[i].erase(G[i].begin(), G[i].end()); } return 0; }
a.cc: In function 'int main()': a.cc:64:3: error: 'sync_with_stdio' was not declared in this scope 64 | sync_with_stdio(false); | ^~~~~~~~~~~~~~~
s704780900
p00601
C++
bool g[100][100]; while(scanf("%d%d",&n,&m) !=EOF , n||m){ if(10<n)assert(1); for(int i=0;i<n;i++) for(int j=0;j<n;j++)g[i][j] = 0; for(int i=0;i<m;i++){ scanf("%d%d",&f,&t); g[f][t] = g[t][f] = 1; } } }
a.cc:3:3: error: expected unqualified-id before 'while' 3 | while(scanf("%d%d",&n,&m) !=EOF , n||m){ | ^~~~~ a.cc:12:1: error: expected declaration before '}' token 12 | } | ^
s178280516
p00601
C++
#include<cstdio> #include<cassert> #include<vector> using namespace std; int main(){ int n,m,f,t; bool g[100][100]; while(scanf("%d%d",&n,&m) !=EOF , n||m){ assert(20=>n); /* for(int i=0;i<n;i++) for(int j=0;j<n;j++)g[i][j] = 0; */ for(int i=0;i<m;i++){ scanf("%d%d",&f,&t); //g[f][t] = g[t][f] = 1; } } }
In file included from /usr/include/c++/14/cassert:44, from a.cc:2: a.cc: In function 'int main()': a.cc:11:15: error: expected primary-expression before '>' token 11 | assert(20=>n); | ^
s417006527
p00601
C++
clude<cstdio> #include<cassert> #include<vector> using namespace std; int main(){ int n,m,f,t; bool g[100][100]; while(scanf("%d%d",&n,&m) !=EOF , n||m){ assert(30>n); for(int i=0;i<n;i++) for(int j=0;j<n;j++)g[i][j] = 0; for(int i=0;i<m;i++){ scanf("%d%d",&f,&t); assert(f<n && t<n); g[f][t] = g[t][f] = 1; } } }
a.cc:1:1: error: 'clude' does not name a type 1 | clude<cstdio> | ^~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/vector:62, 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: /usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared 295 | template <typename _Tp, size_t = sizeof(_Tp)> | ^~~~~~ /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:984:26: error: 'size_t' has not been declared 984 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std' 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /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' 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /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' 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /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' 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /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:1451:32: error: 'size_t' was not declared in this scope 1451 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 63 | #include <bits/version.h> +++ |+#include <cstddef> 64 | /usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid 1451 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared 1453 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope 1454 | struct extent<_Tp[_Size], 0> | ^~~~~ /usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid 1454 | struct extent<_Tp[_Size], 0> | ^ /usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~ /usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid 1455 | : public integral_constant<size_t, _Size> { }; | ^ /usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid /usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared 1457 | template<typename _Tp, unsigned _Uint, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope 1458 | struct extent<_Tp[_Size], _Uint> | ^~~~~ /usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid 1458 | struct extent<_Tp[_Size], _Uint> | ^ /usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope 1463 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid 1463 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type 1857 | { static constexpr size_t __size = sizeof(_Tp); }; | ^~~~~~ /usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~~~~ /usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~ /usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp' 1860 | struct __select; | ^~~~~~~~ /usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared 1862 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^~~ /usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^ /usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared 1866 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> | ^~~ /usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> |
s721620150
p00601
C++
#include <iostream> #include <math.h> #include <algorithm> #include <string> using namespace std; int x, y; int solve(int edges[x][2], int edgenum, bool flag[x]){ if(edgenum >= y) return 0; int node1 = edges[edgenum][0]; int node2 = edges[edgenum][1]; int result; if(flag[node1] || flag[node2]){ // どちらかの角に店がある場合 result = solve(edges, edgenum + 1, flag); }else{ // どちらの角にも店がある場合 // node1 に店を建てる場合 flag[node1] = true; int case1 = solve(edges, edgenum + 1, flag) + 1; flag[node1] = false; // node2 に店を建てる場合 flag[node2] = true; int case2 = solve(edges, edgenum + 1, flag) + 1; flag[node2] = false; result = case1 < case2 ? case1 : case2; } return result; }; int main(int argc, const char * argv[]) { while(cin >> x >> y){ int edges[x][2]; bool flag[x]; for(int i = 0; i < y; i++){ cin >> edges[i][0] >> edges[i][1]; } cout << solve(edges, 0, flag) << "\n"; } return 0; }
a.cc:9:21: error: size of array 'edges' is not an integral constant-expression 9 | int solve(int edges[x][2], int edgenum, bool flag[x]){ | ^ a.cc:9:51: error: size of array 'flag' is not an integral constant-expression 9 | int solve(int edges[x][2], int edgenum, bool flag[x]){ | ^
s984866600
p00601
C++
#include <iostream> #include <math.h> #include <algorithm> #include <string> using namespace std; int x, y; int solve(int edges[x][2], int edgenum, bool flag[x]){ if(edgenum >= y) return 0; int node1 = edges[edgenum][0]; int node2 = edges[edgenum][1]; int result; if(flag[node1] || flag[node2]){ // どちらかの角に店がある場合 result = solve(edges, edgenum + 1, flag); }else{ // どちらの角にも店がある場合 // node1 に店を建てる場合 flag[node1] = true; int case1 = solve(edges, edgenum + 1, flag) + 1; flag[node1] = false; // node2 に店を建てる場合 flag[node2] = true; int case2 = solve(edges, edgenum + 1, flag) + 1; flag[node2] = false; result = case1 < case2 ? case1 : case2; } return result; }; int main(int argc, const char * argv[]) { while(cin >> x >> y){ int edges[x][2]; bool flag[x]; for(int i = 0; i < y; i++){ cin >> edges[i][0] >> edges[i][1]; } cout << solve(edges, 0, flag) << "\n"; } return 0; }
a.cc:9:21: error: size of array 'edges' is not an integral constant-expression 9 | int solve(int edges[x][2], int edgenum, bool flag[x]){ | ^ a.cc:9:51: error: size of array 'flag' is not an integral constant-expression 9 | int solve(int edges[x][2], int edgenum, bool flag[x]){ | ^
s750223940
p00601
C++
#include <iostream> #include <math.h> #include <algorithm> #include <string> using namespace std; int x, y; int solve(int edges[x][2], int edgenum, bool flag[x]){ if(edgenum >= y) return 0; int node1 = edges[edgenum][0]; int node2 = edges[edgenum][1]; int result; if(flag[node1] || flag[node2]){ // どちらかの角に店がある場合 result = solve(edges, edgenum + 1, flag); }else{ // どちらの角にも店がある場合 // node1 に店を建てる場合 flag[node1] = true; int case1 = solve(edges, edgenum + 1, flag) + 1; flag[node1] = false; // node2 に店を建てる場合 flag[node2] = true; int case2 = solve(edges, edgenum + 1, flag) + 1; flag[node2] = false; result = case1 < case2 ? case1 : case2; } return result; }; int main(int argc, const char * argv[]) { while(cin >> x >> y){ int edges[x][2]; bool flag[x]; for(int i = 0; i < y; i++){ cin >> edges[i][0] >> edges[i][1]; } cout << solve(edges, 0, flag) << "\n"; } return 0; }
a.cc:9:21: error: size of array 'edges' is not an integral constant-expression 9 | int solve(int edges[x][2], int edgenum, bool flag[x]){ | ^ a.cc:9:51: error: size of array 'flag' is not an integral constant-expression 9 | int solve(int edges[x][2], int edgenum, bool flag[x]){ | ^
s703820448
p00602
C
#include<stdio.h> #include<string.h> #include<math.h> #define MOD 1001 #define MAX 10001 int getfibo(int); int root(int); int find(int,int); void merge(int,int); int fibo[MAX]; int p[MAX]; int main(void) { fibo[0]=1; fibo[1]=2; int a,b,i,j; while(scanf("%d %d",&a,&d)==2) { memset(p,-1,sizeof(p)); for(i=1;i<=a;i++) { for(j=1;j<=a;j++) { if(abs(getfibo(i)-getfibo(j))<d) { if(!find(i,j))memset(i,j); } } } int b[MAX]={0},res,c=0; for(i=1;i<=a;i++) { res=root(i); if(!b[res]) { b[res]=1; c++; } } printf("%d\n",c); } return 0; } int getfibo(int n) { if(n<1)return 1; if(fibo[n])return[n]; return fibo[n]=(getfibo(n-1)+getfibo(n-2))%MOD } int root(int a) { return p[a]<0?a:(p[a]=root(p[a])); } int find(int a,int b) { return root(a)==root(b); } void merge(int a,int b) { p[root(a)]=root(b); }
main.c: In function 'main': main.c:21:27: error: 'd' undeclared (first use in this function) 21 | while(scanf("%d %d",&a,&d)==2) | ^ main.c:21:27: note: each undeclared identifier is reported only once for each function it appears in main.c:29:18: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration] 29 | if(abs(getfibo(i)-getfibo(j))<d) | ^~~ main.c:4:1: note: include '<stdlib.h>' or provide a declaration of 'abs' 3 | #include<math.h> +++ |+#include <stdlib.h> 4 | main.c:31:40: error: passing argument 1 of 'memset' makes pointer from integer without a cast [-Wint-conversion] 31 | if(!find(i,j))memset(i,j); | ^ | | | int In file included from main.c:2: /usr/include/string.h:61:28: note: expected 'void *' but argument is of type 'int' 61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1)); | ~~~~~~^~~ main.c:31:33: error: too few arguments to function 'memset' 31 | if(!find(i,j))memset(i,j); | ^~~~~~ /usr/include/string.h:61:14: note: declared here 61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1)); | ^~~~~~ main.c: In function 'getfibo': main.c:53:20: error: expected expression before '[' token 53 | if(fibo[n])return[n]; | ^ main.c:55:1: error: expected ';' before '}' token 55 | } | ^
s196201110
p00602
C
#include<stdio.h> #include<string.h> #include<math.h> #define MOD 1001 #define MAX 10001 int getfibo(int); int root(int); int find(int,int); void merge(int,int); int fibo[MAX]; int p[MAX]; int main(void) { fibo[0]=1; fibo[1]=2; int a,d,i,j; while(scanf("%d %d",&a,&d)==2) { memset(p,-1,sizeof(p)); for(i=1;i<=a;i++) { for(j=1;j<=a;j++) { if(abs(getfibo(i)-getfibo(j))<d) { if(!find(i,j))memset(i,j); } } } int b[MAX]={0},res,c=0; for(i=1;i<=a;i++) { res=root(i); if(!b[res]) { b[res]=1; c++; } } printf("%d\n",c); } return 0; } int getfibo(int n) { if(n<1)return 1; if(fibo[n])return[n]; return fibo[n]=(getfibo(n-1)+getfibo(n-2))%MOD; } int root(int a) { return p[a]<0?a:(p[a]=root(p[a])); } int find(int a,int b) { return root(a)==root(b); } void merge(int a,int b) { p[root(a)]=root(b); }
main.c: In function 'main': main.c:29:18: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration] 29 | if(abs(getfibo(i)-getfibo(j))<d) | ^~~ main.c:4:1: note: include '<stdlib.h>' or provide a declaration of 'abs' 3 | #include<math.h> +++ |+#include <stdlib.h> 4 | main.c:31:40: error: passing argument 1 of 'memset' makes pointer from integer without a cast [-Wint-conversion] 31 | if(!find(i,j))memset(i,j); | ^ | | | int In file included from main.c:2: /usr/include/string.h:61:28: note: expected 'void *' but argument is of type 'int' 61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1)); | ~~~~~~^~~ main.c:31:33: error: too few arguments to function 'memset' 31 | if(!find(i,j))memset(i,j); | ^~~~~~ /usr/include/string.h:61:14: note: declared here 61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1)); | ^~~~~~ main.c: In function 'getfibo': main.c:53:20: error: expected expression before '[' token 53 | if(fibo[n])return[n]; | ^
s692825052
p00602
C
#include<stdio.h> #include<string.h> #include<math.h> #define MOD 1001 #define MAX 10001 int getfibo(int); int root(int); int find(int,int); void merge(int,int); int fibo[MAX]; int p[MAX]; int main(void) { fibo[0]=1; fibo[1]=2; int a,d,i,j; while(scanf("%d %d",&a,&d)==2) { memset(p,-1,sizeof(p)); for(i=1;i<=a;i++) { for(j=1;j<=a;j++) { if(abs(getfibo(i)-getfibo(j))<d) { if(!find(i,j))merge(i,j); } } } int b[MAX]={0},res,c=0; for(i=1;i<=a;i++) { res=root(i); if(!b[res]) { b[res]=1; c++; } } printf("%d\n",c); } return 0; } int getfibo(int n) { if(n<1)return 1; if(fibo[n])return [n]; return fibo[n]=(getfibo(n-1)+getfibo(n-2))%MOD; } int root(int a) { return p[a]<0?a:(p[a]=root(p[a])); } int find(int a,int b) { return root(a)==root(b); } void merge(int a,int b) { p[root(a)]=root(b); }
main.c: In function 'main': main.c:29:18: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration] 29 | if(abs(getfibo(i)-getfibo(j))<d) | ^~~ main.c:4:1: note: include '<stdlib.h>' or provide a declaration of 'abs' 3 | #include<math.h> +++ |+#include <stdlib.h> 4 | main.c: In function 'getfibo': main.c:53:21: error: expected expression before '[' token 53 | if(fibo[n])return [n]; | ^
s500768188
p00602
C
#include <stdio.h> #define SIZE (150) #define N (1001) void swap(int *a, int *b) { int tmp; tmp = *a; *a = *b; *b = tmp; } void makeHeap(int *dat, int size, int oya) { int i; /// ”½•œ§Œä int oidx; /// e‚Ì“Y‚¦Žš•Û‘¶ int oval; /// e‚Ì’l•Û‘¶ int ko; /// Žq‚Ì“Y‚¦Žš oidx = oya; // e‚Ì“Y‚¦Žš‚ð•Û‘¶ oval = dat[oidx]; // e‚Ì’l‚ð•Û‘¶ ko = oidx + oidx + 1; // ¶‚ÌŽq‚Ì“Y‚¦Žš‚ð•Û‘¶ while(ko < size) // ‚±‚Ì“Y‚¦Žš‚ªƒf[ƒ^”–¢–ž‚̏ꍇŒJ‚è•Ô‚· { if((ko+1 < size) && (dat[ko] < dat[ko+1])) ko++; // ‰E‚ÌŽq‚ª‘å‚«‚¢ if(oval >= dat[ko]) break; // e‚ª‘å‚«‚¢, ‚»‚±‚ŏI—¹ dat[oidx] = dat[ko]; // e‚Ɉê”Ô‘å‚«‚¢Žq‚Ì’l‚ð‘ã“ü oidx = ko; // ‚»‚ÌŽq‚Ì“Y‚¦Žš‚ðe‚Æ‚·‚é ko = oidx + oidx + 1; // e‚Æ‚µ‚½Žq‚ÌŽq‚ð‹‚ß‚é } dat[oidx] = oval; // •Û‘¶‚µ‚Ä‚¢‚½e‚Ì’l‚ð‘ã“ü } int hsort(int *dat, int size) { int oya; int sz = size; for(oya=(int)((size-2)/2); oya >= 0; oya--) { makeHeap(dat, sz, oya); } while(sz > 0) { sz--; swap(&dat[0], &dat[sz]); makeHeap(dat, sz, 0); } return 0; } int main(void) { int fib, fib1, fib2; char input[8]; int node[SIZE]; short cnt; short v, d; /// “ü—Í v, d short i, j; /// ”½•œ§Œä{i, j} short scnt; /// ƒTƒCƒY‚̃JƒEƒ“ƒg ///double st, pt; while(gets(input)) { if(input[0] == '\0') break; sscanf(input, "%d%d", &v, &d); ///st = gettime(); scnt = 1; fib1 = 1; fib2 = 2; node[0] = fib2; for(i=2; i <= v; i++) { fib = (fib2 + fib1) % N; node[scnt++] = fib; fib1 = fib2; fib2 = fib; } hsort(node, scnt); cnt = 1; i = 0; for(j=i+1; j < scnt; j++) { if(0 > (node[j]-node[i]) || (node[j]-node[i]) >= d){ cnt++; } i = j; } printf("%d\n", cnt); } return 0; }
main.c: In function 'main': main.c:65:15: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration] 65 | while(gets(input)) { | ^~~~ | fgets
s272606165
p00602
C
#include <stdio.h> ///#define Windows ///#include "gettime.h" #define SIZE (1001) #define N (1001) ///#define SIZE_OF(x, type) (sizeof(x) / sizeof(type)) ///#define PRINT_ARRAY(i, ary, size) for(i = 0; i < size; i++){ printf("%d-", *(ary+i)); } printf("\n") void swap(int *a, int *b) { int tmp; tmp = *a; *a = *b; *b = tmp; } void makeHeap(int *dat, int size, int oya) { int i; /// ”½•œ§Œä int oidx; /// e‚Ì“Y‚¦Žš•Û‘¶ int oval; /// e‚Ì’l•Û‘¶ int ko; /// Žq‚Ì“Y‚¦Žš oidx = oya; // e‚Ì“Y‚¦Žš‚ð•Û‘¶ oval = dat[oidx]; // e‚Ì’l‚ð•Û‘¶ ko = oidx + oidx + 1; // ¶‚ÌŽq‚Ì“Y‚¦Žš‚ð•Û‘¶ while(ko < size) // ‚±‚Ì“Y‚¦Žš‚ªƒf[ƒ^”–¢–ž‚̏ꍇŒJ‚è•Ô‚· { if((ko+1 < size) && (dat[ko] < dat[ko+1])) ko++; // ‰E‚ÌŽq‚ª‘å‚«‚¢ if(oval >= dat[ko]) break; // e‚ª‘å‚«‚¢, ‚»‚±‚ŏI—¹ dat[oidx] = dat[ko]; // e‚Ɉê”Ô‘å‚«‚¢Žq‚Ì’l‚ð‘ã“ü oidx = ko; // ‚»‚ÌŽq‚Ì“Y‚¦Žš‚ðe‚Æ‚·‚é ko = oidx + oidx + 1; // e‚Æ‚µ‚½Žq‚ÌŽq‚ð‹‚ß‚é } dat[oidx] = oval; // •Û‘¶‚µ‚Ä‚¢‚½e‚Ì’l‚ð‘ã“ü } int hsort(int *dat, int size) { int oya; int sz = size; ///int i; ///printf("size=%d\n", sz); ///PRINT_ARRAY(i, dat, size); for(oya=(int)((size-2)/2); oya >= 0; oya--) { makeHeap(dat, sz, oya); } ///PRINT_ARRAY(i, dat, size); while(sz > 0) { sz--; swap(&dat[0], &dat[sz]); makeHeap(dat, sz, 0); } ///PRINT_ARRAY(i, dat, size); return 0; } int main(void) { int fib, fib1, fib2; char input[8]; int node[SIZE]; short cnt; short v, d; /// “ü—Í v, d short i, j; /// ”½•œ§Œä{i, j} short scnt; /// ƒTƒCƒY‚̃JƒEƒ“ƒg ///double st, pt; while(gets(input)) { if(input[0] == '\0') break; sscanf(input, "%d%d", &v, &d); ///st = gettime(); scnt = 1; fib1 = 1; fib2 = 2; node[0] = fib2; for(i=2; i <= v; i++) { fib = (fib2 + fib1) % N; //printf("[%d]fib=%lld, fib_mod_N=%lld\n", scnt, fib, fib%N); node[scnt++] = fib; fib1 = fib2; fib2 = fib; } hsort(node, scnt); cnt = 1; i = 0; for(j=i+1; j < scnt; j++) { if(0 > (node[j]-node[i]) || (node[j]-node[i]) >= d){ cnt++; ///printf("if : i=%d, j=%d\n", i, j); } i = j; } printf("%d\n", cnt); ///pt = (gettime() - st) * 1000; ///printf("ŽžŠÔ: %10.4f ƒ~ƒŠ•b\n", pt); } return 0; }
main.c: In function 'main': main.c:76:15: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration] 76 | while(gets(input)) { | ^~~~ | fgets
s388592259
p00602
C
#include <iostream> #include <vector> #include <algorithm> using namespace std; int fib[1002]; int main(){ fib[0] = 1; fib[1] = 2; for(int i=2;i<1002;i++){ fib[i] = (fib[i-1] + fib[i-2]) % 1001; } int v,d; while(cin >> v >> d){ if((v|d) == 0) break; vector<int> vec; int res = 1; for(int i=1;i<=v;i++){ vec.push_back(fib[i]); } sort(vec.begin(), vec.end()); for(int i=1;i<vec.size();i++){ if(vec[i] - vec[i-1] >= d){ res++; } } cout << res << endl; } }
main.c:1:10: fatal error: iostream: No such file or directory 1 | #include <iostream> | ^~~~~~~~~~ compilation terminated.
s727319675
p00602
C
include<stdlib.h> p(int*a,int*b){return *a - *b;} c,V,i,f[1001];main(d){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){ for(f[1]=3,f[0]=i=2;i<V;i++)f[i]=(f[i-1]+f[i-2])%1001; for(qsort(f,V,4,p),c=1;i;f[i]-f[--i]<d?:c++);} return 0;}
main.c:1:8: error: expected '=', ',', ';', 'asm' or '__attribute__' before '<' token 1 | include<stdlib.h> | ^ main.c:3:1: warning: data definition has no type or storage class 3 | c,V,i,f[1001];main(d){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){ | ^ main.c:3:1: error: type defaults to 'int' in declaration of 'c' [-Wimplicit-int] main.c:3:3: error: type defaults to 'int' in declaration of 'V' [-Wimplicit-int] 3 | c,V,i,f[1001];main(d){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){ | ^ main.c:3:5: error: type defaults to 'int' in declaration of 'i' [-Wimplicit-int] 3 | c,V,i,f[1001];main(d){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){ | ^ main.c:3:7: error: type defaults to 'int' in declaration of 'f' [-Wimplicit-int] 3 | c,V,i,f[1001];main(d){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){ | ^ main.c:3:15: error: return type defaults to 'int' [-Wimplicit-int] 3 | c,V,i,f[1001];main(d){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){ | ^~~~ main.c: In function 'main': main.c:3:15: error: type of 'd' defaults to 'int' [-Wimplicit-int] main.c:3:29: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 3 | c,V,i,f[1001];main(d){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){ | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | include<stdlib.h> main.c:3:29: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 3 | c,V,i,f[1001];main(d){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){ | ^~~~~ main.c:3:29: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:3:49: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 3 | c,V,i,f[1001];main(d){for(;~scanf("%d%d",&V,&d);printf("%d\n",c)){ | ^~~~~~ main.c:3:49: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:3:49: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:3:49: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:5:5: error: implicit declaration of function 'qsort' [-Wimplicit-function-declaration] 5 | for(qsort(f,V,4,p),c=1;i;f[i]-f[--i]<d?:c++);} | ^~~~~ main.c:5:17: error: 'p' undeclared (first use in this function) 5 | for(qsort(f,V,4,p),c=1;i;f[i]-f[--i]<d?:c++);} | ^ main.c:5:17: note: each undeclared identifier is reported only once for each function it appears in
s587228553
p00602
C
#include<stdlib.h> p(int*a,int*b){return*a-*b;} int main () { int f[1001]; int F[1001]; int N,i,V,d,count; N=1001; f[0]=2; f[1]=3; for(;~scanf("%d%d",&V,&d);){ count = 1; for(i=2;i<V;i++)F[i]=(F[i-1]+F[i-2])%N;} for(i=0;i<V;i++)f[i]=F[i]; qsort(F,V,4,p); for(i=1;i<V;i++) if(F[i]-F[i-1]>d-1) count++; printf( "%d\n" , count); } return 0; }
main.c:2:1: error: return type defaults to 'int' [-Wimplicit-int] 2 | p(int*a,int*b){return*a-*b;} | ^ main.c: In function 'main': main.c:10:7: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 10 | for(;~scanf("%d%d",&V,&d);){ | ^~~~~ main.c:2:1: note: include '<stdio.h>' or provide a declaration of 'scanf' 1 | #include<stdlib.h> +++ |+#include <stdio.h> 2 | p(int*a,int*b){return*a-*b;} main.c:10:7: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 10 | for(;~scanf("%d%d",&V,&d);){ | ^~~~~ main.c:10:7: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:14:15: error: passing argument 4 of 'qsort' from incompatible pointer type [-Wincompatible-pointer-types] 14 | qsort(F,V,4,p); | ^ | | | int (*)(int *, int *) In file included from main.c:1: /usr/include/stdlib.h:971:34: note: expected '__compar_fn_t' {aka 'int (*)(const void *, const void *)'} but argument is of type 'int (*)(int *, int *)' 971 | __compar_fn_t __compar) __nonnull ((1, 4)); | ~~~~~~~~~~~~~~^~~~~~~~ main.c:18:3: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 18 | printf( "%d\n" , count); | ^~~~~~ main.c:18:3: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:18:3: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:18:3: note: include '<stdio.h>' or provide a declaration of 'printf' main.c: At top level: main.c:20:2: error: expected identifier or '(' before 'return' 20 | return 0; | ^~~~~~ main.c:21:1: error: expected identifier or '(' before '}' token 21 | } | ^