submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s711517170
p00629
C++
#include<iostream> #include<vector> #include<string.h> using namespace std; struct log{ int id,belong,correct,penalty; }; int main(void){ struct log team[1001]; int n,idcount[1001]; while(cin>>n,n){ memset(team,0,sizeof(team)); memset(idcount,0,sizeof(idcount)); for(int i=1;i<=n;i++){ cin>>team[i].id>>team[i].belong>>team[i].correct>>team[i].penalty; } for(int i=1;i<=n;i++){ for(int j=n;j>=i+1;j--){ if(team[j-1].correct<team[j].correct){ struct log temp; temp=team[j]; team[j]=team[j-1]; team[j-1]=temp; } } } for(int i=1;i<=n;i++){ for(int j=n;j>=i+1;j--){ if(team[j-1].correct==team[j].correct && team[j-1].penalty>team[j].penalty){ struct log temp; temp=team[j]; team[j]=team[j-1]; team[j-1]=temp; } } } for(int i=1;i<=n;i++){ for(int j=n;j>=i+1;j--){ if(team[j-1].correct==team[j].correct && team[j-1].penalty==team[j].penalty && team[j-1].id>team[j].id){ struct log temp; temp=team[j]; team[j]=team[j-1]; team[j-1]=temp; } } } idcount[team[i].belong]=0; for(int i=1;i<=n;i++){ if(i<10 && idcount[team[i].belong]<3){ cout<<team[i].id<<endl; idcount[team[i].belong]++; } else if(i<=10 && i<20 && idcount[team[i].belong]<2){ cout<<team[i].id<<endl; idcount[team[i].belong]++; } else if(i<=20 && i<26 && idcount[team[i].belong]==0){ cout<<team[i].id<<endl; idcount[team[i].belong]++; } } } }
a.cc: In function 'int main()': a.cc:58:30: error: 'i' was not declared in this scope 58 | idcount[team[i].belong]=0; | ^
s465715102
p00629
C++
#include<iostream> #include<vector> #include<string.h> using namespace std; struct log{ int id,belong,correct,penalty; }; int main(void){ struct log team[1001]; int n,idcount[1001]; while(cin>>n,n){ memset(team,0,sizeof(team)); memset(idcount,0,sizeof(idcount)); for(int i=1;i<=n;i++){ cin>>team[i].id>>team[i].belong>>team[i].correct>>team[i].penalty; } for(int i=1;i<=n;i++){ for(int j=n;j>=i+1;j--){ if(team[j-1].correct<team[j].correct){ struct log temp; temp=team[j]; team[j]=team[j-1]; team[j-1]=temp; } } } for(int i=1;i<=n;i++){ for(int j=n;j>=i+1;j--){ if(team[j-1].correct==team[j].correct && team[j-1].penalty>team[j].penalty){ struct log temp; temp=team[j]; team[j]=team[j-1]; team[j-1]=temp; } } } for(int i=1;i<=n;i++){ for(int j=n;j>=i+1;j--){ if(team[j-1].correct==team[j].correct && team[j-1].penalty==team[j].penalty && team[j-1].id>team[j].id){ struct log temp; temp=team[j]; team[j]=team[j-1]; team[j-1]=temp; } } } for(int i=1,sum=0;i<=n;i++){ if(sum<10 && idcount[team[i].belong]<3){ cout<<team[i].id<<endl; idcount[team[i].belong]++; sum++; } else if(sum<=10 && sum<20 && idcount[team[i].belong]<2){ cout<<team[i].id<<endl; idcount[team[i].belong]++; sum++; } else if(sum<=20 && sum<26 && idcount[team[i].belong]==0){ cout<<team[i].id<<endl; idcount[team[i].belong]++; sum++; } } } }iostream> #include<vector> #include<string.h> using namespace std; struct log{ int id,belong,correct,penalty; }; int main(void){ struct log team[1001]; int n,idcount[1001]; while(cin>>n,n){ memset(team,0,sizeof(team)); memset(idcount,0,sizeof(idcount)); for(int i=1;i<=n;i++){ cin>>team[i].id>>team[i].belong>>team[i].correct>>team[i].penalty; } for(int i=1;i<=n;i++){ for(int j=n;j>=i+1;j--){ if(team[j-1].correct<team[j].correct){ struct log temp; temp=team[j]; team[j]=team[j-1]; team[j-1]=temp; } } } for(int i=1;i<=n;i++){ for(int j=n;j>=i+1;j--){ if(team[j-1].correct==team[j].correct && team[j-1].penalty>team[j].penalty){ struct log temp; temp=team[j]; team[j]=team[j-1]; team[j-1]=temp; } } } for(int i=1;i<=n;i++){ for(int j=n;j>=i+1;j--){ if(team[j-1].correct==team[j].correct && team[j-1].penalty==team[j].penalty && team[j-1].id>team[j].id){ struct log temp; temp=team[j]; team[j]=team[j-1]; team[j-1]=temp; } } } for(int i=1,sum=0;i<=n;i++){ if(sum<10 && idcount[team[i].belong]<3){ cout<<team[i].id<<endl; idcount[team[i].belong]++; } else if(sum<=10 && sum<20 && idcount[team[i].belong]<2){ cout<<team[i].id<<endl; idcount[team[i].belong]++; } else if(sum<=20 && sum<26 && idcount[team[i].belong]==0){ cout<<team[i].id<<endl; idcount[team[i].belong]++; sum++; } } } }
a.cc:77:10: error: expected unqualified-id before '>' token 77 | }iostream> | ^ a.cc:83:8: error: redefinition of 'struct log' 83 | struct log{ | ^~~ a.cc:7:8: note: previous definition of 'struct log' 7 | struct log{ | ^~~ a.cc:87:5: error: redefinition of 'int main()' 87 | int main(void){ | ^~~~ a.cc:11:5: note: 'int main()' previously defined here 11 | int main(void){ | ^~~~
s083744979
p00630
Java
package aoj10xx; import java.util.Scanner; public class AOJ1044 { public static void main ( String[] args ){ Scanner sc = new Scanner( System.in ); while( true ){ String src = sc.next(); char[] strc = src.toCharArray(); String type = sc.next(); char diff = 'a' - 'A'; switch (type.toCharArray()[ 0 ] ){ case 'X': return; case 'U': if( 'a' <= strc[ 0 ] && strc[ 0 ] <= 'z' ){ strc[ 0 ] -= diff; // to upper case } for( int i = 1; i < strc.length; i++ ){ if( strc[ i ] == '_' ){ String s1 = ""; String s2 = ""; for( int j = 0; j < i; j++ ){ s1 += strc[ j ]; } if( 'a' <= strc[ i + 1 ] && strc[ i + 1 ] <= 'z' ){ strc[ i + 1 ] -= diff; } for( int j = i + 1; j < strc.length; j++ ){ s2 += strc[ j ]; } strc = ( s1 + s2 ).toCharArray(); } } System.out.println( strc ); break; case 'L': if( 'A' <= strc[ 0 ] && strc[ 0 ] <= 'Z' ){ strc[ 0 ] += diff; // to upper case } for( int i = 1; i < strc.length; i++ ){ if( strc[ i ] == '_' ){ String s1 = ""; String s2 = ""; for( int j = 0; j < i; j++ ){ s1 += strc[ j ]; } if( 'a' <= strc[ i + 1 ] && strc[ i + 1 ] <= 'z' ){ strc[ i + 1 ] -= diff; } for( int j = i + 1; j < strc.length; j++ ){ s2 += strc[ j ]; } strc = ( s1 + s2 ).toCharArray(); } } System.out.println( strc ); break; case 'D': if( 'A' <= strc[ 0 ] && strc[ 0 ] <= 'Z' ){ strc[ 0 ] += diff; // to upper case } for( int i = 1; i < strc.length; i++ ){ if( 'A' <= strc[ i ] && strc[ i ] <= 'Z' ){ String s = ""; for( int j = 0; j < i; j++ ){ s += strc[ j ]; } s += "_"; strc[ i ] += diff; for( int j = i; j < strc.length; j++ ){ s += strc[ j ]; } strc = s.toCharArray(); } } System.out.println( strc ); break; } } } }
Main.java:5: error: class AOJ1044 is public, should be declared in a file named AOJ1044.java public class AOJ1044 { ^ 1 error
s275010800
p00630
C++
#include<iostream> #include<string> #include<cctype> #include<algorithm> using namespace std; int main() { string s; string::iterator i; char c; int x; while(cin>>s>>c,c-'X') { s[0]=toupper(s[0]); while(x=s.find('_'),x!=string::npos) s.erase(x,1),s[x]=toupper(s[x]); if(c-'U')s[0]=tolower(s[0]); if(c=='D') for(i=s.begin();(i=find_if(i,s.end(),isupper))!=s.end();++i) *i=tolower(*i),s.insert(i,'_'); cout<<s<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:19:51: error: no matching function for call to 'find_if(std::__cxx11::basic_string<char>::iterator&, std::__cxx11::basic_string<char>::iterator, <unresolved overloaded function type>)' 19 | for(i=s.begin();(i=find_if(i,s.end(),isupper))!=s.end();++i) | ~~~~~~~^~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:61, from a.cc:4: /usr/include/c++/14/bits/stl_algo.h:3867:5: note: candidate: 'template<class _IIter, class _Predicate> _IIter std::find_if(_IIter, _IIter, _Predicate)' 3867 | find_if(_InputIterator __first, _InputIterator __last, | ^~~~~~~ /usr/include/c++/14/bits/stl_algo.h:3867:5: note: template argument deduction/substitution failed: a.cc:19:51: note: couldn't deduce template parameter '_Predicate' 19 | for(i=s.begin();(i=find_if(i,s.end(),isupper))!=s.end();++i) | ~~~~~~~^~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/algorithm:86: /usr/include/c++/14/pstl/glue_algorithm_defs.h:52:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Predicate> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _ForwardIterator> std::find_if(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Predicate)' 52 | find_if(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Predicate __pred); | ^~~~~~~ /usr/include/c++/14/pstl/glue_algorithm_defs.h:52:1: note: candidate expects 4 arguments, 3 provided
s733105184
p00630
C++
#include<iostream> #include<string> #include<cctype> #include<algorithm> #include<functional> using namespace std; int main() { string s; string::iterator i; char c; int x; while(cin>>s>>c,c-'X') { s[0]=toupper(s[0]); while(x=s.find('_'),x!=string::npos) s.erase(x,1),s[x]=toupper(s[x]); if(c-'U')s[0]=tolower(s[0]); if(c=='D') for(i=s.begin();(i=find_if(i,s.end(),ptr_fun(isupper)))!=s.end();++i) *i=tolower(*i),s.insert(i,'_'); cout<<s<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:20:69: error: no matching function for call to 'ptr_fun(<unresolved overloaded function type>)' 20 | for(i=s.begin();(i=find_if(i,s.end(),ptr_fun(isupper)))!=s.end();++i) | ~~~~~~~^~~~~~~~~ In file included from /usr/include/c++/14/string:49, 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_function.h:1123:5: note: candidate: 'template<class _Arg, class _Result> std::pointer_to_unary_function<_Arg, _Result> std::ptr_fun(_Result (*)(_Arg))' 1123 | ptr_fun(_Result (*__x)(_Arg)) | ^~~~~~~ /usr/include/c++/14/bits/stl_function.h:1123:5: note: template argument deduction/substitution failed: a.cc:20:69: note: couldn't deduce template parameter '_Arg' 20 | for(i=s.begin();(i=find_if(i,s.end(),ptr_fun(isupper)))!=s.end();++i) | ~~~~~~~^~~~~~~~~ /usr/include/c++/14/bits/stl_function.h:1150:5: note: candidate: 'template<class _Arg1, class _Arg2, class _Result> std::pointer_to_binary_function<_Arg1, _Arg2, _Result> std::ptr_fun(_Result (*)(_Arg1, _Arg2))' 1150 | ptr_fun(_Result (*__x)(_Arg1, _Arg2)) | ^~~~~~~ /usr/include/c++/14/bits/stl_function.h:1150:5: note: template argument deduction/substitution failed: a.cc:20:69: note: candidate expects 2 arguments, 1 provided 20 | for(i=s.begin();(i=find_if(i,s.end(),ptr_fun(isupper)))!=s.end();++i) | ~~~~~~~^~~~~~~~~ a.cc:20:69: note: couldn't deduce template parameter '_Arg1'
s727082420
p00630
C++
while true do identifier, role = gets.chomp.split(' ') break if role == 'X' words = Array.new if identifier[0] =~ /[A-Z]/ then words = identifier.scan(/[A-Z][a-z]*/).map {|x| x.downcase } elsif identifier.include? '_' then words = identifier.split '_' else words = identifier.scan(/(?:^[a-z]*)|(?:[A-Z][a-z]*)/).map {|x| x.downcase } end if role == 'U' puts words.map {|x| x.capitalize }.join elsif role == 'L' print words.shift puts words.map {|x| x.capitalize }.join elsif role == 'D' puts words.join '_' end end
a.cc:1:1: error: expected unqualified-id before 'while' 1 | while true do | ^~~~~ a.cc:8:3: error: 'elsif' does not name a type 8 | elsif identifier.include? '_' then | ^~~~~ a.cc:12:3: error: 'end' does not name a type 12 | end | ^~~ a.cc:15:39: error: expected unqualified-id before '.' token 15 | puts words.map {|x| x.capitalize }.join | ^ a.cc:18:39: error: expected unqualified-id before '.' token 18 | puts words.map {|x| x.capitalize }.join | ^
s628383275
p00631
Java
import java.util.*; public class Main { static int n; static int[] a = new int[21]; static int dfs(int A, int B, int i) { int x; int y; if(i == n) return Math.abs(A-B); x = dfs(A+a[i], B, i+1); y = dfs(A, B+a[i], i+1); return Math.min(x, y); } public static void main(String[] args) { try(Scanner sc = new Scanner(System.in)) { while(sc.hasNext()){ n = sc.nextInt(); if(n == 0) break; for(int i=0; i<n; i++) { a[i] = sc.nextInt(); } System.out.println(dfs(0, 0, 0)); } } } }
Main.java:19: error: illegal character: '\uff5b' while(sc.hasNext())? ^ Main.java:26: error: illegal character: '\uff5d' ? ^ 2 errors
s788257688
p00631
C
#include <cstdio> #include <cmath> #include <algorithm> using namespace std; int main(void) { int i, n, array[20], A, B; while (scanf("%d", &n), n != 0){ A = B = 0; for (i = 0; i < n; i++){ scanf("%d", &array[i]); } sort(array, array + n); reverse(array, array + n); for (i = 0; i < n; i++){ if (A < B){ A += array[i]; } else { B += array[i]; } } printf("%d\n", abs(A - B)); } return (0); }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s529628152
p00631
C
#include <cstdio> #include <cstdlib> #include <algorithm> using namespace std; int main() { int i, n, array[20], A, B; while (scanf("%d", &n), n != 0){ A = B = 0; for (i = 0; i < n; i++){ scanf("%d", &array[i]); } sort(array, array + n); reverse(array, array + n); for (i = 0; i < n; i++){ if (A < B){ A += array[i]; } else { B += array[i]; } } printf("%d\n", abs(A - B)); } return (0); }
main.c:1:10: fatal error: cstdio: No such file or directory 1 | #include <cstdio> | ^~~~~~~~ compilation terminated.
s699955887
p00631
C
#include<stdio.h> #include<math.h> int result; int main(){ int i,n,data[20],; while(1){ scanf("%d",&n); if(n==0)break; for(i=0;i<n;i++)scanf("%d",&data[i]); result=1000000; printf("%d\n",search(n,data,0,0,0)); } return 0; } int search(int n,int data[],int i,int a,int b){ if(i<n){ search(n,data,i+1,a+data[i],b); search(n,data,i+1,a,b+data[i]); } else if(abs(a-b)<result)result=abs(a-b); return result; }
main.c: In function 'main': main.c:7:20: error: expected identifier or '(' before ';' token 7 | int i,n,data[20],; | ^ main.c:13:19: error: implicit declaration of function 'search' [-Wimplicit-function-declaration] 13 | printf("%d\n",search(n,data,0,0,0)); | ^~~~~~ main.c: In function 'search': main.c:24:11: error: implicit declaration of function 'abs' [-Wimplicit-function-declaration] 24 | else if(abs(a-b)<result)result=abs(a-b); | ^~~ main.c:3:1: note: include '<stdlib.h>' or provide a declaration of 'abs' 2 | #include<math.h> +++ |+#include <stdlib.h> 3 |
s017729717
p00631
C++
#include<iostream> #include<vector> #include<math.h> #include<stdlib.h> #include<algorithm> using namespace std; static const int MAX_MEMBERS = 20; int Members; int FightingPower[MAX_MEMBERS]; vector<int> power; int seek = 0; int FightingPower[MAX_MEMBERS], n, res; const int INF = 1000001; void dfs(int i, int a_sum, int b_sum) { if (i == n) { res = min(abs(a_sum - b_sum), res); } else { dfs(i + 1, a_sum + FightingPower[i], b_sum); dfs(i + 1, a_sum, b_sum + FightingPower[i]); } } int main() { while (cin >> n && n!=0) { for (int i = 0; i<n; i++) { cin >> FightingPower[i]; } res = INF; dfs(0, 0, 0); cout << res << endl; } }
a.cc:16:5: error: redefinition of 'int FightingPower [20]' 16 | int FightingPower[MAX_MEMBERS], n, res; | ^~~~~~~~~~~~~ a.cc:11:5: note: 'int FightingPower [20]' previously declared here 11 | int FightingPower[MAX_MEMBERS]; | ^~~~~~~~~~~~~
s930050721
p00631
C++
#include <functional> #include <vector> #include <cstdio> #include <string> #include <cmath> #include <cfloat> #include <map> using namespace std; int main(){ int n; while(cin>>n,n!=0){ int a=0,b=0; vector<int> s(n); for(int i=0;i<n;i++) cin>>s[i]; sort(s.begin(),s.end(),greater<int>()); for(int i=0;i<n;i++){ if(s[i]>0){ if(a>b) b+=s[i]; else a+=s[i]; } else{ if(a>b) a+=s[i]; else b+=s[i]; } cout<<abs(a-b)<<endl; } }
a.cc: In function 'int main()': a.cc:14:15: error: 'cin' was not declared in this scope 14 | while(cin>>n,n!=0){ | ^~~ a.cc:8:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 7 | #include <map> +++ |+#include <iostream> 8 | using namespace std; a.cc:21:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 21 | sort(s.begin(),s.end(),greater<int>()); | ^~~~ | sqrt a.cc:37:17: error: 'cout' was not declared in this scope 37 | cout<<abs(a-b)<<endl; | ^~~~ a.cc:37:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:37:33: error: 'endl' was not declared in this scope 37 | cout<<abs(a-b)<<endl; | ^~~~ a.cc:8:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 7 | #include <map> +++ |+#include <ostream> 8 | using namespace std; a.cc:39:2: error: expected '}' at end of input 39 | } | ^ a.cc:10:11: note: to match this '{' 10 | int main(){ | ^
s989105575
p00631
C++
#include <cmath> #include <vector> #include <iostream> #include <algorithm> using namespace std; int main() { int n, sum; vector<int> a; while(true) { cin >> n; if(n == 0) { break; } a = vector<int>(n); for(int i = 0; i < n; i++) { cin >> a[i]; sum += a[i]; } int min_ = (1 << 29); for(int i = 0; i <(1 << n); i++) { int sum2 = 0; for(int j = 0; j < n; j++) { if(i & (1 << j)) { sum2 += a[j]; } } min_ = min(abs(2 * sum2 - sum), min_); } cout << min << endl; } return 0; }
a.cc: In function 'int main()': a.cc:42:14: error: no match for 'operator<<' (operand types are 'std::ostream' {aka 'std::basic_ostream<char>'} and '<unresolved overloaded function type>') 42 | cout << min << endl; | ~~~~~^~~~~~ In file included from /usr/include/c++/14/iostream:41, from a.cc:3: /usr/include/c++/14/ostream:116:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ostream_type& (*)(__ostream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:116:36: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ostream_type& (*)(std::basic_ostream<char>::__ostream_type&)' {aka 'std::basic_ostream<char>& (*)(std::basic_ostream<char>&)'} 116 | operator<<(__ostream_type& (*__pf)(__ostream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:125:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; __ios_type = std::basic_ios<char>]' 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/ostream:125:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::basic_ostream<char>::__ios_type& (*)(std::basic_ostream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 125 | operator<<(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:135:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ^~~~~~~~ /usr/include/c++/14/ostream:135:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)' 135 | operator<<(ios_base& (*__pf) (ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ostream:174:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 174 | operator<<(long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:174:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int' 174 | operator<<(long __n) | ~~~~~^~~ /usr/include/c++/14/ostream:178:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 178 | operator<<(unsigned long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:178:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int' 178 | operator<<(unsigned long __n) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:182:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(bool) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 182 | operator<<(bool __n) | ^~~~~~~~ /usr/include/c++/14/ostream:182:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool' 182 | operator<<(bool __n) | ~~~~~^~~ In file included from /usr/include/c++/14/ostream:1022: /usr/include/c++/14/bits/ostream.tcc:96:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(short int) [with _CharT = char; _Traits = std::char_traits<char>]' 96 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:97:22: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int' 97 | operator<<(short __n) | ~~~~~~^~~ /usr/include/c++/14/ostream:189:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(short unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 189 | operator<<(unsigned short __n) | ^~~~~~~~ /usr/include/c++/14/ostream:189:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int' 189 | operator<<(unsigned short __n) | ~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/bits/ostream.tcc:110:5: note: candidate: 'std::basic_ostream<_CharT, _Traits>& std::basic_ostream<_CharT, _Traits>::operator<<(int) [with _CharT = char; _Traits = std::char_traits<char>]' 110 | basic_ostream<_CharT, _Traits>:: | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/ostream.tcc:111:20: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int' 111 | operator<<(int __n) | ~~~~^~~ /usr/include/c++/14/ostream:200:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 200 | operator<<(unsigned int __n) | ^~~~~~~~ /usr/include/c++/14/ostream:200:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int' 200 | operator<<(unsigned int __n) | ~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:211:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 211 | operator<<(long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:211:28: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int' 211 | operator<<(long long __n) | ~~~~~~~~~~^~~ /usr/include/c++/14/ostream:215:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long long unsigned int) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 215 | operator<<(unsigned long long __n) | ^~~~~~~~ /usr/include/c++/14/ostream:215:37: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int' 215 | operator<<(unsigned long long __n) | ~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:231:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 231 | operator<<(double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:231:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double' 231 | operator<<(double __f) | ~~~~~~~^~~ /usr/include/c++/14/ostream:235:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(float) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 235 | operator<<(float __f) | ^~~~~~~~ /usr/include/c++/14/ostream:235:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float' 235 | operator<<(float __f) | ~~~~~~^~~ /usr/include/c++/14/ostream:243:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long double) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 243 | operator<<(long double __f) | ^~~~~~~~ /usr/include/c++/14/ostream:243:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double' 243 | operator<<(long double __f) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:301:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(const void*) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>]' 301 | operator<<(const void* __p) | ^~~~~~~~ /usr/include/c++/14/ostream:301:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'const void*' 301 | operator<<(const void* __p) | ~~~~~~~~~~~~^~~ /usr/include/c++/14/ostream:306:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(std::nullptr_t) [with _CharT = char; _Traits = std::char_traits<char>; __ostream_type = std::basic_ostream<char>; std::nullptr_t = std::nullptr_t]' 306 | operator<<(nullptr_t) | ^~~~~~~~ /usr/include/c++/14/ostream:306:18: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::nullptr_t' 306 | operator<<(n
s067409109
p00631
C++
#include<iostream> using namespace std; int abs(int a){return a < 0 ? -a : a;} int main(){ int n; int a[22]; while(cin>>n,n){ for(int i=0;i<n;i++) cin>>a[i]; int mi=INT_MAX; for(int l=0;l<(2<<n);l++){ int p=0,q=0; for(int i=0;i<n;i++){ if((l>>i)&1) p+=a[i]; else q+=a[i]; } mi=min(abs(q-p),mi); } cout<<mi<<endl; } }
a.cc: In function 'int main()': a.cc:10:16: error: 'INT_MAX' was not declared in this scope 10 | int mi=INT_MAX; | ^~~~~~~ a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 1 | #include<iostream> +++ |+#include <climits> 2 | using namespace std;
s636695459
p00631
C++
#include<iostream> using namespace std; int abs(int a){return a < 0 ? -a : a;} int main(){ int n; int a[22]; while(cin>>n,n){ for(int i=0;i<n;i++) cin>>a[i]; int mi=INT_MAX; for(int l=0;l<(2<<n);l++){ int p=0,q=0; for(int i=0;i<n;i++){ if((l>>i)&1) p+=a[i]; else q+=a[i]; } mi=min(abs(q-p),mi); } cout<<mi<<endl; } }
a.cc: In function 'int main()': a.cc:10:16: error: 'INT_MAX' was not declared in this scope 10 | int mi=INT_MAX; | ^~~~~~~ a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 1 | #include<iostream> +++ |+#include <climits> 2 | using namespace std;
s428406031
p00631
C++
#include<bits/stdc++.h> #define mk make_pair using namespace std; int a[20],n; unordered_map<pair<pair<int,int>,int>,int >m; int dfs(int d,int x,int y){ if(d==n){if(y<x)swap(x,y);return y-x;} return min(dfs(d+1,x+a[d],y),dfs(d+1,x,y+a[d])); } int main(){ while(cin>>n,n){ for(int i=0;i<n;i++)cin>>a[i]; cout<<dfs(0,0,0)<<endl;m.clear(); } }
a.cc:5:44: error: use of deleted function 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<std::pair<int, int>, int>; _Tp = int; _Hash = std::hash<std::pair<std::pair<int, int>, int> >; _Pred = std::equal_to<std::pair<std::pair<int, int>, int> >; _Alloc = std::allocator<std::pair<const std::pair<std::pair<int, int>, int>, int> >]' 5 | unordered_map<pair<pair<int,int>,int>,int >m; | ^ In file included from /usr/include/c++/14/unordered_map:41, from /usr/include/c++/14/functional:63, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53, from a.cc:1: /usr/include/c++/14/bits/unordered_map.h:148:7: note: 'std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::pair<std::pair<int, int>, int>; _Tp = int; _Hash = std::hash<std::pair<std::pair<int, int>, int> >; _Pred = std::equal_to<std::pair<std::pair<int, int>, int> >; _Alloc = std::allocator<std::pair<const std::pair<std::pair<int, int>, int>, int> >]' is implicitly deleted because the default definition would be ill-formed: 148 | unordered_map() = default; | ^~~~~~~~~~~~~ /usr/include/c++/14/bits/unordered_map.h:148:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<std::pair<int, int>, int>; _Value = std::pair<const std::pair<std::pair<int, int>, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<std::pair<int, int>, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<std::pair<int, int>, int> >; _Hash = std::hash<std::pair<std::pair<int, int>, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/unordered_map.h:33: /usr/include/c++/14/bits/hashtable.h:539:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::pair<std::pair<int, int>, int>; _Value = std::pair<const std::pair<std::pair<int, int>, int>, int>; _Alloc = std::allocator<std::pair<const std::pair<std::pair<int, int>, int>, int> >; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<std::pair<int, int>, int> >; _Hash = std::hash<std::pair<std::pair<int, int>, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 539 | _Hashtable() = default; | ^~~~~~~~~~ /usr/include/c++/14/bits/hashtable.h:539:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<std::pair<int, int>, int>; _Value = std::pair<const std::pair<std::pair<int, int>, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<std::pair<int, int>, int> >; _Hash = std::hash<std::pair<std::pair<int, int>, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' In file included from /usr/include/c++/14/bits/hashtable.h:35: /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::pair<std::pair<int, int>, int>; _Value = std::pair<const std::pair<std::pair<int, int>, int>, int>; _ExtractKey = std::__detail::_Select1st; _Equal = std::equal_to<std::pair<std::pair<int, int>, int> >; _Hash = std::hash<std::pair<std::pair<int, int>, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, false, true>]' is implicitly deleted because the default definition would be ill-formed: 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<std::pair<int, int>, int>; _Value = std::pair<const std::pair<std::pair<int, int>, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<std::pair<int, int>, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' /usr/include/c++/14/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::pair<std::pair<int, int>, int> >]': /usr/include/c++/14/bits/hashtable_policy.h:1328:7: required from here 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: error: use of deleted function 'std::hash<std::pair<std::pair<int, int>, int> >::hash()' 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ In file included from /usr/include/c++/14/string_view:50, 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/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<std::pair<int, int>, int> >::hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::pair<std::pair<int, int>, int>, false>::__hash_enum()' /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::pair<std::pair<int, int>, int>; bool <anonymous> = false]' 83 | __hash_enum(__hash_enum&&); | ^~~~~~~~~~~ /usr/include/c++/14/bits/functional_hash.h:83:7: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<std::pair<int, int>, int>; bool <anonymous> = false]' is private within this context 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1245:49: note: use '-fdiagnostics-all-candidates' to display considered candidates 1245 | _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { } | ^~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::pair<std::pair<int, int>, int>; _Value = std::pair<const std::pair<std::pair<int, int>, int>, int>; _ExtractKey = std::__detail::_Select1st; _Hash = std::hash<std::pair<std::pair<int, int>, int> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed: 1328 | _Hash_code_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1328:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<std::pair<int, int>, int> >, true>::~_Hashtable_ebo_helper()' /usr/include/c++/14/bits/hashtable_policy.h:1242:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::pair<std::pair<int, int>, int> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed: 1242 | struct _Hashtable_ebo_helper<_Nm, _Tp, true> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1242:12: error: use of deleted function 'std::hash<std::pair<std::pair<int, int>, int> >::~hash()' /usr/include/c++/14/bits/functional_hash.h:102:12: note: 'std::hash<std::pair<std::pair<int, int>, int> >::~hash()' is implicitly deleted because the default definition would be ill-formed: 102 | struct hash : __hash_enum<_Tp> | ^~~~ /usr/include/c++/14/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::pair<std::pair<int, int>, int>; bool <anonymous> = false]' is private within this context /usr/include/c++/14/bits/functional_hash.h:84:7: note: declared private here 84 | ~__hash_enum(); | ^ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: note: use '-fdiagnostics-all-candidates' to display considered candidates 1731 | _Hashtable_base() = default; | ^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/hashtable_policy.h:1731:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::pair<std::pair<int, int>, int>, std::pair<const std::pair<std::pair<int, int>, int>, int>, std::__detail::_Select1st, std::hash<std::pair<std::pair<int, int>, int> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' /usr/include/c++/14/bits/hashtable_policy.h:1306:12: note: 'std::__detail::_Hash_code_base<std::pair<std::pair<int, int>, int>, std::pair<const std::pair<std::pair<int, int>, int>, int>, std::__detail::_Select1st, std::hash<std::
s230845478
p00631
C++
void dfs(int now, int i); int a[100]; int minimum = 1000000000, n, sum; void dfs(int now,int i){ if(i == n){ if(minimum > abs(sum-now*2)){ minimum = abs(sum-now*2); return; } } dfs(now, i+1); dfs(now-a[i], i+1); } int main(){ while(1){ sum = 0; cin >> n; if(n == 0) break; for(int i = 0;i < n;i++){ cin >> a[i]; sum += a[i]; } sort(a, a+n); dfs(sum, 0); cout << minimum << endl; } return 0; }
a.cc: In function 'void dfs(int, int)': a.cc:7:18: error: 'abs' was not declared in this scope 7 | if(minimum > abs(sum-now*2)){ | ^~~ a.cc: In function 'int main()': a.cc:18:5: error: 'cin' was not declared in this scope 18 | cin >> n; | ^~~ a.cc:26:5: error: 'sort' was not declared in this scope; did you mean 'short'? 26 | sort(a, a+n); | ^~~~ | short a.cc:30:5: error: 'cout' was not declared in this scope 30 | cout << minimum << endl; | ^~~~ a.cc:30:24: error: 'endl' was not declared in this scope 30 | cout << minimum << endl; | ^~~~
s486401514
p00631
C++
#include<iostream> #include<algorithm> #include<math> using namespace std; int main(){ double sum,mostnear; bool a[20]; int n,kyas[20],shiftmax,sssum,ansint,i,j; while(1){ scanf("%d",&n); if(n==0) break; for(i=0;i<n;i++){ scanf("%d",&kyas[i]); } sort(kyas,kyas+n); sum=0; for(i=0;i<n;i++){ sum+=kyas[i]; } sum/=2; mostnear = 2100000000; shiftmax = 1<<n; for(i=0;i<shiftmax;i++){ for(j=0;j<n;j++){ a[j] = i&1<<j; } sssum=0; for(j=0;j<n;j++){ sssum += a[j]*kyas[j]; } mostnear = mostnear>fabs(sssum-sum) ? fabs(sssum-sum) : mostnear; } printf("%d\n",(int)(mostnear*2)); } }
a.cc:3:9: fatal error: math: No such file or directory 3 | #include<math> | ^~~~~~ compilation terminated.
s887879960
p00631
C++
#include<iostream> #include<algorithm> #include<math> using namespace std; int main(void){ double sum,mostnear; bool a[20]; int n,kyas[20],shiftmax,sssum,ansint,i,j; while(1){ scanf("%d",&n); if(n==0) break; for(i=0;i<n;i++){ scanf("%d",&kyas[i]); } sort(kyas,kyas+n); sum=0; for(i=0;i<n;i++){ sum+=kyas[i]; } sum/=2; mostnear = 2100000000; shiftmax = 1<<n; for(i=0;i<shiftmax;i++){ for(j=0;j<n;j++){ a[j] = i&1<<j; } sssum=0; for(j=0;j<n;j++){ sssum += a[j]*kyas[j]; } mostnear = mostnear>fabs(sssum-sum) ? fabs(sssum-sum) : mostnear; } printf("%d\n",(int)(mostnear*2)); } return 0; }
a.cc:3:9: fatal error: math: No such file or directory 3 | #include<math> | ^~~~~~ compilation terminated.
s068713145
p00631
C++
#include<iostream> #include<vector> #include<algorithm> using namespace std; int main() { int n; for(;;) { vector<int> num; cin >> n; if(n==0) break; for(int i=0;i<n;i++) { int a; cin >> a; num.push_back(a); } sort(num.begin(),num.end()); int a=0,b=0; int a_f=1; if(num.size()==2) { cout << sqrt((num[0]-num[1])*(num[0]-num[1])) << endl; } else { if(num.size()%2==0) { for(int i=0,j=num.size()-1;i<j;i++,j--) { if(a_f==1) { a+=num[i]+num[j]; a_f=0; } else { b+=num[i]+num[j]; a_f=1; } } } else { for(int i=1,j=num.size()-1;i<=j || i<num.size();i++,j--) { if(a_f==1) { a+=num[i]+num[j]; a_f=0; } else { b+=num[i]+num[j]; a_f=1; } } if(a<=b) a+=num[0]; else b+=num[0]; } cout << "a:" << a << " b:" << b << endl; cout << sqrt((a-b)*(a-b)) << endl; } } }
a.cc: In function 'int main()': a.cc:31:33: error: 'sqrt' was not declared in this scope 31 | cout << sqrt((num[0]-num[1])*(num[0]-num[1])) << endl; | ^~~~ a.cc:72:33: error: 'sqrt' was not declared in this scope 72 | cout << sqrt((a-b)*(a-b)) << endl; | ^~~~
s134402515
p00631
C++
#include <iostream> using namespace std; int n; int data[20]; int rec(int p, int A, int B) { static int min; if(p == 0) min = 999999; if(p == n) { int temp = abs(A-B); if(temp < min) min = temp; return 0; } rec(p+1, A+data[p], B); rec(p+1, A, B+data[p]); return min; } int main() { while(1) { cin >> n; if(n == 0) break; for(int i = 0; i < n; i++) { cin >> data[i]; } cout << rec(0, 0, 0) << endl; } return 0; }
a.cc: In function 'int rec(int, int, int)': a.cc:15:14: error: reference to 'data' is ambiguous 15 | rec(p+1, A+data[p], B); | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:5:5: note: 'int data [20]' 5 | int data[20]; | ^~~~ a.cc:16:17: error: reference to 'data' is ambiguous 16 | rec(p+1, A, B+data[p]); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:5:5: note: 'int data [20]' 5 | int data[20]; | ^~~~ a.cc: In function 'int main()': a.cc:25:14: error: reference to 'data' is ambiguous 25 | cin >> data[i]; | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:5:5: note: 'int data [20]' 5 | int data[20]; | ^~~~
s243872118
p00631
C++
#include<iostream> #include<algorithm> using namespace std; int main () { int ab[20]; bool used[20]; int sum; int aSum; int bSum; bool aUsed[20]; bool bUsod[20]; while (true) { int n; cin >> n; if ( n == 0) break; sum = 0; aSum = 0; bSum = 0; for (int i=0; i<n; i++ ) { cin >> ab[i]; used[i] = false; aUsed[i] = false; bUsed[i] = false; sum += ab[i]; } sort ( ab, &ab[n]); for ( int i=n; i>=0; i-- ) { if ( aSum <= bSum ) { aSum += ab[i]; aUsed[i] = true; } else { bSum += ab[i]; bUsed[i] = true; } } /* bool stop = true; while (true) { if (abs (aSum - bSum) / 2 == 0 ) { break; } for ( int i=0; i<n; i++ ) { if ( abs(aSum - bSum)/2 >= ab[i] ) { if ( aUsed > bUsed ) { } } */ cout << abs(aSum - bSum); } }
a.cc: In function 'int main()': a.cc:30:25: error: 'bUsed' was not declared in this scope; did you mean 'bUsod'? 30 | bUsed[i] = false; | ^~~~~ | bUsod a.cc:42:33: error: 'bUsed' was not declared in this scope; did you mean 'bUsod'? 42 | bUsed[i] = true; | ^~~~~ | bUsod
s903734694
p00631
C++
#include<cstdio> #include<cstdlib> #include<numeric> using namespace std; int main(){ for(int n;scanf("%d",&n),n;){ int a[20]; for(int i=0;i<n;i++) scanf("%d",a+i); int ans=1<<30; int sum=accumulate(a,a+n,0); for(int i=0;i<(1<<n);i++){ int psum=0; for(int j=0;j<n;j++){ if(i&(1<<j)) psum+=a[j]; } ans=min(ans,abs(sum-2*psum)); } printf("%d\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:19:29: error: 'min' was not declared in this scope; did you mean 'main'? 19 | ans=min(ans,abs(sum-2*psum)); | ^~~ | main
s184334028
p00631
C++
#include <iostream> #include <algorithm> #include <cassert> #include <cctype> #include <complex> #include <cstdio> #include <map> #include <math.h> #include <queue> #include <set> #include <stack> #include <string> #include <vector> using namespace std; int n,p[20],s[1<<20],s1[1<<10]; int main(){ while(cin>>n){ if(!n)return 0; int n2=n/2; fill(s1,s1+(1<<n2),0); int sum=0; for(int i=0;i<n;i++){cin>>p[i];sum+=p[i];} if(n<2){ fill(s,s+(1<<n),0); for(int i=0;i<1<<n;i++){ int sss=0; for(int j=0;j<n;j++)if((i/(1<<j))%2)sss+=p[j]; dif=min(dif,abs(sss*2-sum)); } cout<<dif<<endl; } else{ for(int i=0;i<1<<n2;i++){ for(int j=0;j<n2;j++)if(i>>j&1)s1[i]+=p[j]; } sort(s1,s1+(1<<n2)); int ans=1e+9; for(int i=0;i<1<<(n-n2);i++){ int ss=0; for(int j=0;j<n-n2;j++)if(i>>j&1)ss+=p[j+n2]; ans=min(ans,min(abs((*lower_bound(s1,s1+(1<<n2),(sum+1)/2-ss)+ss)*2-sum),abs((*(lower_bound(s1,s1+(1<<n2),(sum+1)/2-ss)-1)+ss)*2-sum))); } cout<<ans<<endl; } } }
a.cc: In function 'int main()': a.cc:30:33: error: 'dif' was not declared in this scope; did you mean 'div'? 30 | dif=min(dif,abs(sss*2-sum)); | ^~~ | div a.cc:32:31: error: 'dif' was not declared in this scope; did you mean 'div'? 32 | cout<<dif<<endl; | ^~~ | div
s573080993
p00631
C++
int n; while(cin>>n&&n!=0){ int a[20]; int sum=0; for(int i=0; i < n; i++){ cin >> a[i]; sum+=a[i]; } sort(a,a+n); int Asum=0; vector<int>A,B; for(int i = 0; i < n; i++){ if(Asum < sum){ A.push_back(a[i]); Asum+=a[i]; sum-=a[i]; } else{ for(int j = i; j < n; j++){ B.push_back(a[j]); } break; } } int minSum = abs(Asum-sum); for(int i = 0; i < A.size(); i++){ if(Asum <= sum) break; Asum-=a[i]; sum+=a[i]; minSum = min(minSum,abs(Asum-sum)); } cout << minSum << endl; } return 0; }
a.cc:3:9: error: expected unqualified-id before 'while' 3 | while(cin>>n&&n!=0){ | ^~~~~ a.cc:39:9: error: expected unqualified-id before 'return' 39 | return 0; | ^~~~~~ a.cc:40:1: error: expected declaration before '}' token 40 | } | ^
s093413325
p00631
C++
#include <cstdio> #include <algorithm> using namespace std; #define INF (1<<25) int main(){ int n , v[20] , X[41] , Y[41] , top; while(scanf("%d\n",&n)&& n){ int dp2[21] = {0}; for(int i = 0 ; i < n ; i++) scanf("%d",&v[i]) , memo[i].clear(); sort(v,v+n,greater<int>()); for(int i = n-1 ; i >= 0 ; i--) dp2[i] = dp2[i+1] + v[i]; int ans = INF; top = 0; X[top] = Y[top] = 0; while(~top){ int pos = X[top] , sum = Y[top]; top--; if(pos==n) ans = min(ans,sum); else{ if( sum >= dp2[pos] && ans <= sum-dp2[pos] ) continue; // ツ枝ツ偲ォ X[++top] = pos+1 , Y[top] = sum+v[pos]; X[++top] = pos+1 , Y[top] = abs(sum-v[pos]); } } printf("%d\n",ans); } }
a.cc: In function 'int main()': a.cc:10:66: error: 'memo' was not declared in this scope 10 | for(int i = 0 ; i < n ; i++) scanf("%d",&v[i]) , memo[i].clear(); | ^~~~ a.cc:11:28: error: 'greater' was not declared in this scope 11 | sort(v,v+n,greater<int>()); | ^~~~~~~ a.cc:11:36: error: expected primary-expression before 'int' 11 | sort(v,v+n,greater<int>()); | ^~~
s789176073
p00631
C++
#include<cstdio> #include<sstream> #include<string> #define reps(i,f,n) for(int i = f; i < int(n); i++) #define rep(i,n) reps(i,0,n) using namespace std; int main(void){ int n; while(cin >> n){ int ans = 100000000; int a[32]={0}; if(!n)break; rep(i,n)cin >> a[i]; rep(i,1<<n){ int ga = 0,gb = 0; for(int j = 1,index = 0; j < 1<<n; j = j<<1,index++){ if(i&j){ ga+=a[index]; }else{ gb+=a[index]; } } ans = min(abs(ga-gb), ans); } printf("%d\n", ans); } }
a.cc: In function 'int main()': a.cc:13:15: error: 'cin' was not declared in this scope 13 | while(cin >> n){ | ^~~ a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 2 | #include<sstream> +++ |+#include <iostream> 3 | #include<string>
s187123655
p00631
C++
#include<cstdio> #include<algorithm> #define reps(i,f,n) for(int i = f; i < int(n); i++) #define rep(i,n) reps(i,0,n) using namespace std; int main(void){ int n; while(cin >> n){ int ans = 100000000; int a[32]={0}; if(!n)break; rep(i,n)cin >> a[i]; rep(i,1<<n){ int ga = 0,gb = 0; for(int j = 1,index = 0; j < 1<<n; j = j<<1,index++){ if(i&j){ ga+=a[index]; }else{ gb+=a[index]; } } ans = min(abs(ga-gb), ans); } printf("%d\n", ans); } }
a.cc: In function 'int main()': a.cc:12:15: error: 'cin' was not declared in this scope 12 | while(cin >> n){ | ^~~ a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 2 | #include<algorithm> +++ |+#include <iostream> 3 |
s908337488
p00631
C++
#include<iostream> #include<cmath> using namespace std; #define INF = (1 << 30) #define rep(i,n) for(int i = 0 ; i < (n) ; ++i) int n,ANS,vc[20]; void dfs(int rec,int now){ if(now == n){ ANS = min(ANS,abs(rec)); return; } dfs(rec+vc[now],now+1); dfs(rec-vc[now],now+1); } int main(){ while(cin >> n , n){ ANS = INF; rep(i,n) cin >> vc[i]; dfs(0,0); cout << ANS << endl; } }
a.cc: In function 'int main()': a.cc:4:13: error: expected primary-expression before '=' token 4 | #define INF = (1 << 30) | ^ a.cc:19:11: note: in expansion of macro 'INF' 19 | ANS = INF; | ^~~
s300210490
p00631
C++
#include<iostream> #include<cmath> #include<algorithm> using namespace std; #define INF = (1 << 30) #define rep(i,n) for(int i = 0 ; i < (n) ; ++i) int n,ANS,vc[20]; void dfs(int rec,int now){ if(now == n){ ANS = min(ANS,abs(rec)); return; } dfs(rec+vc[now],now+1); dfs(rec-vc[now],now+1); } int main(){ while(cin >> n , n){ ANS = INF; rep(i,n) cin >> vc[i]; dfs(0,0); cout << ANS << endl; } }
a.cc: In function 'int main()': a.cc:5:13: error: expected primary-expression before '=' token 5 | #define INF = (1 << 30) | ^ a.cc:20:11: note: in expansion of macro 'INF' 20 | ANS = INF; | ^~~
s467697889
p00632
Java
import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Queue; import java.util.Scanner; public class Main { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); int mod = 1000000007; int[] dx = { 1, 0, -1, 0, 0 }; int[] dy = { 0, 1, 0, -1, 0 }; void run() { for (;;) { int H = sc.nextInt(); int W = sc.nextInt(); if ((H | W) == 0) { return; } char[][] field = new char[H][W]; // HashSet<String> hs = new HashSet<String>(); int allcnt = 0; int gH = 0, gW = 0, goH = 0, goW = 0; for (int i = 0; i < H; i++) { String input = sc.next(); for (int j = 0; j < W; j++) { field[i][j] = input.charAt(j); if (input.charAt(j) == 'A') { gH = i; gW = j; } if (input.charAt(j) == 'B') { goH = i; goW = j; } } } String direction = sc.next(); boolean visit[][][][][] = new boolean[H][W][H][W][9]; Queue<Info> queue = new LinkedList<Info>(); queue.add(new Info(gH, gW)); int nowGohostH = goH; int nowGohostW = goW; int cnt = 0; int ansH = 0; int ansW = 0; int index = 0; boolean able = false; int roop = 0; label: while (!queue.isEmpty()) { int size = queue.size(); char exe = direction.charAt(index % direction.length()); for (int I = 0; I < size; I++) { Info now = queue.poll(); if (now.girlH == nowGohostH && now.girlW == nowGohostW) { ansH = now.girlH; ansW = now.girlW; able = true; break label; } // hs.add(now.girlH + "-" + now.girlW + "-" + now.gohostH // + "-" + now.gohostW); int girl_nextH = 0; int girl_nextW = 0; for (int i = 0; i < 5; i++) { girl_nextH = now.girlH + dy[i]; girl_nextW = now.girlW + dx[i]; if (girl_nextH < 0) { girl_nextH = 0; } if (girl_nextH == H) { girl_nextH = H - 1; } if (girl_nextW < 0) { girl_nextW = 0; } if (girl_nextW == W) { girl_nextW = W - 1; } if (0 <= girl_nextH && girl_nextH < H && 0 <= girl_nextW && girl_nextW < W && 0 <= nowGohostH && nowGohostH < H && 0 <= nowGohostW && nowGohostW < W && field[girl_nextH][girl_nextW] != '#') { Info next = new Info(girl_nextH, girl_nextW); if (!visit[next.girlH][next.girlW][nowGohostH][nowGohostW][Integer.valueOf(exe-'0')]) { visit[next.girlH][next.girlW][nowGohostH][nowGohostW][Integer.valueOf(exe-'0')] = true; roop = 0; queue.add(next); allcnt++; } } } if (queue.isEmpty()) { roop++; if (roop <= 10) { queue.add(now); } } } cnt++; index++; if (exe == '5') { nowGohostW = nowGohostW + dx[4]; nowGohostH = nowGohostH + dy[4]; } if (exe == '8') { nowGohostW = nowGohostW + dx[3]; nowGohostH = nowGohostH + dy[3]; } if (exe == '6') { nowGohostW = nowGohostW + dx[0]; nowGohostH = nowGohostH + dy[0]; } if (exe == '4') { nowGohostW = nowGohostW + dx[2]; nowGohostH = nowGohostH + dy[2]; } if (exe == '2') { nowGohostW = nowGohostW + dx[1]; nowGohostH = nowGohostH + dy[1]; } if (nowGohostH < 0) { nowGohostH = 0; } if (nowGohostH == H) { nowGohostH = H - 1; } if (nowGohostW < 0) { nowGohostW = 0; } if (nowGohostW == W) { nowGohostW = W - 1; } } System.out.println(able ? cnt + " " + ansH + " " + ansW : "impossible"); } } class Info { int girlH; int girlW; public Info(int girlH, int girlW) { this.girlH = girlH; this.girlW = girlW; } } public static void main(String[] args) { new AOJ_1046().run(); } void debug(Object... o) { System.out.println(Arrays.deepToString(o)); } void debug2(char[][] array) { for (int i = 0; i < array.length; i++) { for (int j = 0; j < array[i].length; j++) { System.out.print(array[i][j]); } System.out.println(); } } class MyScanner { int nextInt() { try { int c = System.in.read(); while (c != '-' && (c < '0' || '9' < c)) c = System.in.read(); if (c == '-') return -nextInt(); int res = 0; do { res *= 10; res += c - '0'; c = System.in.read(); } while ('0' <= c && c <= '9'); return res; } catch (Exception e) { return -1; } } double nextDouble() { return Double.parseDouble(next()); } String next() { try { StringBuilder res = new StringBuilder(""); int c = System.in.read(); while (Character.isWhitespace(c)) c = System.in.read(); do { res.append((char) c); } while (!Character.isWhitespace(c = System.in.read())); return res.toString(); } catch (Exception e) { return null; } } } }
Main.java:154: error: cannot find symbol new AOJ_1046().run(); ^ symbol: class AOJ_1046 location: class Main 1 error
s519465690
p00632
C
#include <stdio.h> #include <string.h> typedef struct tag_Pair{ int R; int C; }Pair; int main(){ int H,W; char Map[21][21]; char Pat[11]; int i,j; while(1){ scanf("%d %d",&H,&W); if(!H&&!W)break; for(i=0;i<H;i++){ scanf("%s\n",Map[i]); } scanf("%s\n",Pat); int turn =0; int M[H][W]; Pair P;P.R=-1;P.C=-1; for(i=0;i<H;i++){ for(j=0;j<W;j++){ M[i][j]=-1; if(Map[i][j]=='A')M[i][j]=0; if(Map[i][j]=='B'){ P.R=i; P.C=j; } } } int chk=1; int FS[H*W+1];//ハッシュの代わり int FScnt=0;//ハッシュの要素の個数。H*Wが小さいのでO(N)で管理。。。 int move; int k; int PatLength=strlen(Pat); while(1){ turn++; //まずAを進める for(i=0;i<H;i++){ for(j=0;j<W;j++){ if(M[i][j]==turn-1){ if(i-1>=0 && Map[i-1][j]!='#' && M[i-1][j]==-1)M[i-1][j]=turn; if(i+1<H && Map[i+1][j]!='#' && M[i+1][j]==-1)M[i+1][j]=turn; if(j-1>=0 && Map[i][j-1]!='#' && M[i][j-1]==-1)M[i][j-1]=turn; if(j+1<W && Map[i][j+1]!='#' && M[i][j+1]==-1)M[i][j+1]=turn; } } } move=(turn -1)%(PatLength); if(Pat[move]=='8'){if(P.R-1>=0)P.R-=1;} if(Pat[move]=='4'){if(P.C-1>=0)P.C-=1;} if(Pat[move]=='5'){;} if(Pat[move]=='6'){if(P.C+1<W)P.C+=1;} if(Pat[move]=='2'){if(P.R+1<H)P.R+=1;} if(M[P.R][P.C]!=-1)break; if(turn>H*W){ //ループ停止条件: //turn>H*Wであれば、Aが行けるところにはすべてフラグが立っている //Bの動きの周期点をturn>H*W以降で観察すれば、Bがループに入ったかどうかが分かる。 if(move==0){ */ for(k=0;k<FScnt;k++){ if(FS[k]==P.R*W+P.C){ chk=0; } } if(chk==0)break; FScnt++; FS[P.R*W+P.C]; } } } if(chk==0){ printf("impossible\n"); continue; } printf("%d %d %d\n",turn,P.R,P.C); } return 0; }
main.c: In function 'main': main.c:72:2: error: expected expression before '/' token 72 | */ for(k=0;k<FScnt;k++){ | ^
s884867584
p00632
C++
4 7 A#...#B .#.#.#. .#.#.#. ...#... 5 4 7 A#...#B .#.#.#. .#.#.#. ...#... 2 4 7 A#...#B .#.#.#. .#.#.#. ...#... 4 4 7 A#...#B .#.#.#. .#.#.#. ...#... 442668 1 10 A#.......B 55555554 1 10 A#.......B 55555555 0 0
a.cc:2:2: error: stray '#' in program 2 | A#...#B | ^ a.cc:2:6: error: stray '#' in program 2 | A#...#B | ^ a.cc:3:2: error: stray '#' in program 3 | .#.#.#. | ^ a.cc:3:4: error: stray '#' in program 3 | .#.#.#. | ^ a.cc:3:6: error: stray '#' in program 3 | .#.#.#. | ^ a.cc:4:2: error: stray '#' in program 4 | .#.#.#. | ^ a.cc:4:4: error: stray '#' in program 4 | .#.#.#. | ^ a.cc:4:6: error: stray '#' in program 4 | .#.#.#. | ^ a.cc:5:4: error: stray '#' in program 5 | ...#... | ^ a.cc:8:2: error: stray '#' in program 8 | A#...#B | ^ a.cc:8:6: error: stray '#' in program 8 | A#...#B | ^ a.cc:9:2: error: stray '#' in program 9 | .#.#.#. | ^ a.cc:9:4: error: stray '#' in program 9 | .#.#.#. | ^ a.cc:9:6: error: stray '#' in program 9 | .#.#.#. | ^ a.cc:10:2: error: stray '#' in program 10 | .#.#.#. | ^ a.cc:10:4: error: stray '#' in program 10 | .#.#.#. | ^ a.cc:10:6: error: stray '#' in program 10 | .#.#.#. | ^ a.cc:11:4: error: stray '#' in program 11 | ...#... | ^ a.cc:14:2: error: stray '#' in program 14 | A#...#B | ^ a.cc:14:6: error: stray '#' in program 14 | A#...#B | ^ a.cc:15:2: error: stray '#' in program 15 | .#.#.#. | ^ a.cc:15:4: error: stray '#' in program 15 | .#.#.#. | ^ a.cc:15:6: error: stray '#' in program 15 | .#.#.#. | ^ a.cc:16:2: error: stray '#' in program 16 | .#.#.#. | ^ a.cc:16:4: error: stray '#' in program 16 | .#.#.#. | ^ a.cc:16:6: error: stray '#' in program 16 | .#.#.#. | ^ a.cc:17:4: error: stray '#' in program 17 | ...#... | ^ a.cc:20:2: error: stray '#' in program 20 | A#...#B | ^ a.cc:20:6: error: stray '#' in program 20 | A#...#B | ^ a.cc:21:2: error: stray '#' in program 21 | .#.#.#. | ^ a.cc:21:4: error: stray '#' in program 21 | .#.#.#. | ^ a.cc:21:6: error: stray '#' in program 21 | .#.#.#. | ^ a.cc:22:2: error: stray '#' in program 22 | .#.#.#. | ^ a.cc:22:4: error: stray '#' in program 22 | .#.#.#. | ^ a.cc:22:6: error: stray '#' in program 22 | .#.#.#. | ^ a.cc:23:4: error: stray '#' in program 23 | ...#... | ^ a.cc:26:2: error: stray '#' in program 26 | A#.......B | ^ a.cc:29:2: error: stray '#' in program 29 | A#.......B | ^ a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 4 7 | ^
s244893966
p00632
C++
#include<iostream> #include<queue> using namespace std; typedef pair<pair<int,int>,int> pa; #define ff first.first #define fs first.second int h,w,sx,sy,gx,gy; int dx[4]={1,0,-1,0}; int dy[4]={0,-1,0,1}; int co[21][21]; char ma[21][21]; bool visited[21][21]; string pat; int main(){ while(cin>>h>>w,h){ for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ co[i][j]=INT_MAX; cin>>ma[i][j]; if(ma[i][j]=='A') sx=j,sy=i; else if(ma[i][j]=='B') gx=j,gy=i; } } queue<pa>q; q.push(make_pair(make_pair(sx, sy), 0)); while(q.size()){ pa p = q.front(); q.pop(); if(co[p.fs][p.ff]!=INT_MAX) continue; co[p.fs][p.ff]=p.second; for(int i=0;i<4;i++){ int nx=p.ff+dx[i]; int ny=p.fs+dy[i]; if(nx>=0&&nx<w&&ny>=0&ny<h&&ma[ny][nx]!='#'&&co[ny][nx]==INT_MAX) q.push(make_pair(make_pair(nx, ny), p.second+1)); } } cin>>pat; for(int j=0,go=0;;j++,go++){ int i=j%pat.length(); if(co[gy][gx]<=go){ cout<<go<<" "<<gy<<" "<<gx<<endl; break; } if(go>100000){ cout<<"impossible"<<endl; break; } if(pat[i]=='8') gy--; else if(pat[i]=='6') gx++; else if(pat[i]=='4') gx--; else if(pat[i]=='2') gy++; gy=max(0,min(h-1,gy)); gx=max(0,min(w-1,gx)); } } }
a.cc: In function 'int main()': a.cc:20:26: error: 'INT_MAX' was not declared in this scope 20 | co[i][j]=INT_MAX; | ^~~~~~~ a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 2 | #include<queue> +++ |+#include <climits> 3 | using namespace std; a.cc:33:32: error: 'INT_MAX' was not declared in this scope 33 | if(co[p.fs][p.ff]!=INT_MAX) | ^~~~~~~ a.cc:33:32: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' a.cc:39:74: error: 'INT_MAX' was not declared in this scope 39 | if(nx>=0&&nx<w&&ny>=0&ny<h&&ma[ny][nx]!='#'&&co[ny][nx]==INT_MAX) | ^~~~~~~ a.cc:39:74: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
s531808502
p00632
C++
#include <iostream> using namespace std; typedef struct { int x, y; } Vector; char map[16 + 2][16 + 2]; unsigned int data[16][16][16][16][10]; int ans; int ans_x, ans_y; int change(char move[], Vector mv[]) { int i = 0; while (move[i] != '\0'){ mv[i].x = mv[i].y = 0; switch (move[i]){ case '5': break; case '8': mv[i].y = -1; break; case '6': mv[i].x = 1; break; case '4': mv[i].x = -1; break; case '2': mv[i].y = 1; break; } i++; } return (i); } int calc(int sx, int sy, int gx, int gy, Vector mv[], int move_count, int depth) { int mx, my; if (map[sx][sy] == -1 || map[sx][sy] == '#' || ans <= depth){ return (0); } if (sx == gx && sy == gy){ if (ans > depth){ ans = depth; ans_x = sx - 1; ans_y = sy - 1; } return (0); } if (data[sx - 1][sy - 1][gx - 1][gy - 1][depth % move_count] == 1){ return (0); } data[sx - 1][sy - 1][gx - 1][gy - 1][depth % move_count] = 1; mx = mv[depth % move_count].x; my = mv[depth % move_count].y; if (map[gx + mx][gy + my] != -1){ gx += mx; gy += my; } calc(sx + 1, sy, gx, gy, mv, move_count, depth + 1); calc(sx - 1, sy, gx, gy, mv, move_count, depth + 1); calc(sx, sy + 1, gx, gy, mv, move_count, depth + 1); calc(sx, sy - 1, gx, gy, mv, move_count, depth + 1); calc(sx, sy, gx, gy, mv, move_count, depth + 1); data[sx - 1][sy - 1][gx - 1][gy - 1][depth % move_count] = 0; return (0); } int main(void) { int hight, width; int sx, sy, gx, gy; char move[11]; Vector mv[10]; int move_count; while (1){ ans = 16 * 16 * 16 * 16 * 10; cin >> hight >> width; if (hight == 0 && width == 0)break; for (int y = 0; y < hight + 2; y++){ char str[16 + 1]; if (y == 0 || y == hight + 1){ for (int x = 0; x < width + 2; x++){ map[x][y] = -1; } } else { cin >> str; map[0][y] = map[width + 1][y] = -1; for (int x = 0; x < width; x++){ if (str[x] == 'A'){ sx = x + 1; sy = y; } if (str[x] == 'B'){ gx = x + 1; gy = y; } map[x + 1][y] = str[x]; } } } cin >> move; memset(data, 0, 16 * 16 * 16 * 16 * 10); move_count = change(move, mv); calc(sx, sy, gx, gy, mv, move_count, 0); if (ans == 16 * 16 * 16 * 16 * 10){ cout << "impossible" << endl; } else { cout << ans << ' ' << ans_y << ' ' << ans_x << endl; } } return (0); }
a.cc: In function 'int calc(int, int, int, int, Vector*, int, int)': a.cc:56:13: error: reference to 'data' is ambiguous 56 | if (data[sx - 1][sy - 1][gx - 1][gy - 1][depth % move_count] == 1){ | ^~~~ In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:10:14: note: 'unsigned int data [16][16][16][16][10]' 10 | unsigned int data[16][16][16][16][10]; | ^~~~ a.cc:59:9: error: reference to 'data' is ambiguous 59 | data[sx - 1][sy - 1][gx - 1][gy - 1][depth % move_count] = 1; | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:10:14: note: 'unsigned int data [16][16][16][16][10]' 10 | unsigned int data[16][16][16][16][10]; | ^~~~ a.cc:74:9: error: reference to 'data' is ambiguous 74 | data[sx - 1][sy - 1][gx - 1][gy - 1][depth % move_count] = 0; | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:10:14: note: 'unsigned int data [16][16][16][16][10]' 10 | unsigned int data[16][16][16][16][10]; | ^~~~ a.cc: In function 'int main()': a.cc:115:24: error: reference to 'data' is ambiguous 115 | memset(data, 0, 16 * 16 * 16 * 16 * 10); | ^~~~ /usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)' 344 | data(initializer_list<_Tp> __il) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:334:5: note: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])' 334 | data(_Tp (&__array)[_Nm]) noexcept | ^~~~ /usr/include/c++/14/bits/range_access.h:323:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)' 323 | data(const _Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ /usr/include/c++/14/bits/range_access.h:312:5: note: 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)' 312 | data(_Container& __cont) noexcept(noexcept(__cont.data())) | ^~~~ a.cc:10:14: note: 'unsigned int data [16][16][16][16][10]' 10 | unsigned int data[16][16][16][16][10]; | ^~~~ a.cc:115:17: error: 'memset' was not declared in this scope 115 | memset(data, 0, 16 * 16 * 16 * 16 * 10); | ^~~~~~ a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 1 | #include <iostream> +++ |+#include <cstring> 2 |
s395960362
p00632
C++
#include <stdio.h> #include <list> using namespace std; //#define DEBUG typedef struct { int px, py; int gx, gy; int move_index; int depth; } DATA; char map[20 + 2][20 + 2]; char move_inst[11]; list<unsigned> lstHash; list<DATA> lstSarch; unsigned calc_hash(const DATA& data) { unsigned hash; hash = data.px | (data.py << 5) | (data.gx << 10) | (data.gy << 15) | (data.move_index << 20); return (hash); } bool is_add(const DATA& data) { unsigned hash; hash = calc_hash(data); if (map[data.px][data.py] == -1 || map[data.px][data.py] == '#' || find(lstHash.begin(), lstHash.end(), hash) != lstHash.end()){ return (false); } return (true); } int width_priority_sarch(const DATA& data) { DATA add; add.depth = data.depth + 1; add.move_index = (data.move_index + 1) % strlen(move_inst); add.gx = data.gx; add.gy = data.gy; switch (move_inst[data.move_index]){ case '8': add.gy--; break; case '4': add.gx--; break; case '6': add.gx++; break; case '2': add.gy++; break; default : break; } if (map[add.gx][add.gy] == -1){ add.gx = data.gx; add.gy = data.gy; } add.px = data.px; add.py = data.py; if (is_add(add) == true){ lstSarch.push_back(add); lstHash.push_back(calc_hash(add)); } #ifdef DEBUG printf("%d %d\n", add.move_index, data.move_index); printf("%u %u\n", calc_hash(add), calc_hash(data)); #endif add.px++; if (is_add(add) == true){ lstSarch.push_back(add); lstHash.push_back(calc_hash(add)); } add.px = data.px; add.px--; if (is_add(add) == true){ lstSarch.push_back(add); lstHash.push_back(calc_hash(add)); } add.px = data.px; add.py++; if (is_add(add) == true){ lstSarch.push_back(add); lstHash.push_back(calc_hash(add)); } add.py = data.py; add.py--; if (is_add(add) == true){ lstSarch.push_back(add); lstHash.push_back(calc_hash(add)); } return (0); } bool is_end(DATA& data) { if (data.px == data.gx && data.py == data.gy){ return (true); } return (false); } int main(void) { DATA start; int hight, with; while (1){ lstHash.clear(); lstSarch.clear(); scanf("%d%d", &hight, &with); if (hight == 0 || with == 0){ break; } for (int i = 0; i < 22; i++){ for (int j = 0; j < 22; j++){ map[i][j] = -1; } } for (int y = 0; y < hight; y++){ char str[21]; scanf("%s", str); for (int x = 0; x < with; x++){ map[x + 1][y + 1] = str[x]; if (map[x + 1][y + 1] == 'A'){ start.px = x + 1; start.py = y + 1; map[x + 1][y + 1] = '.'; } if (map[x + 1][y + 1] == 'B'){ start.gx = x + 1; start.gy = y + 1; map[x + 1][y + 1] = '.'; } } } scanf("%s", move_inst); start.move_index = 0; start.depth = 0; lstHash.push_back(calc_hash(start)); lstSarch.push_back(start); while (lstSarch.empty() == false && is_end(lstSarch.front()) == false){ #ifdef DEBUG printf("%d %d %d %d %d %d\n", lstSarch.front().px, lstSarch.front().py, lstSarch.front().gx, lstSarch.front().gy, lstSarch.front().depth, lstSarch.front().move_index); #endif width_priority_sarch(lstSarch.front()); lstSarch.pop_front(); } if (lstSarch.empty() == true){ puts("impossible"); } else { printf("%d %d %d\n", lstSarch.front().depth, lstSarch.front().py - 1, lstSarch.front().px - 1); } } return (0); }
a.cc: In function 'bool is_add(const DATA&)': a.cc:35:76: error: 'find' was not declared in this scope 35 | if (map[data.px][data.py] == -1 || map[data.px][data.py] == '#' || find(lstHash.begin(), lstHash.end(), hash) != lstHash.end()){ | ^~~~ a.cc: In function 'int width_priority_sarch(const DATA&)': a.cc:47:50: error: 'strlen' was not declared in this scope 47 | add.move_index = (data.move_index + 1) % strlen(move_inst); | ^~~~~~ a.cc:3:1: note: 'strlen' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include <list> +++ |+#include <cstring> 3 |
s876992948
p00632
C++
#include<stdio.h> #include<queue.h> int main(){ queue<int> q; int w,h,f[484],i,j,d[]={22,0,-1,0,1,0,-22},a,b,t,x,z; char p[15]; for(;scanf("%d%d ",&h,&w),h;){ for(j=0;j<w+2;j++)f[j]=f[j-~h*22]=-9; for(i=1;i<=h;i++){ for(j=1;j<=w;j++){ f[x=i*22+j]=-1; switch(getchar()){ case'#':--f[x];break; case'A':a=x;break; case'B':b=x;break; } } f[i*22]=f[i*22-~w]=-9; getchar(); } f[a]=t=0; q.push(0); for(q.push(a);q.size()>1;){ a=q.front(); q.pop(); if(a){ for(i=0;i<7;i+=2) if(f[x=a+d[i]]==-1) f[x]=t, q.push(x); else ++t,q.push(0); } q.pop(); scanf("%s",p); for(a=t=0;!a;){ x=b; z=0; for(i=0;!a&&p[i];i++){ t++; f[j=b+d[p[i]-'2']]>-3?b=j:0; f[b]>=0&&t>=f[b]?a=b:0; f[b]>=0&&++z; } !z&!a&!p[i]&b==x&f[b]<0&&--a; } printf(a<0?"impossible\n":"%d %d %d\n",t,a/22-1,a%22-1); } }
a.cc:2:9: fatal error: queue.h: No such file or directory 2 | #include<queue.h> | ^~~~~~~~~ compilation terminated.
s246807182
p00632
C++
#include<stdio.h> #include<queue> int main(){ std::queue<int> q; int w,h,f[484],i,j,d[]={22,0,-1,0,1,0,-22},a,b,t,x,z; char p[15]; for(;scanf("%d%d ",&h,&w),h;){ for(j=0;j<w+2;j++)f[j]=f[j-~h*22]=-9; for(i=1;i<=h;i++){ for(j=1;j<=w;j++){ f[x=i*22+j]=-1; switch(getchar()){ case'#':--f[x];break; case'A':a=x;break; case'B':b=x;break; } } f[i*22]=f[i*22-~w]=-9; getchar(); } f[a]=t=0; q.push(0); for(q.push(a);q.size()>1;){ a=q.front(); q.pop(); if(a){ for(i=0;i<7;i+=2) if(f[x=a+d[i]]==-1) f[x]=t, q.push(x); else ++t,q.push(0); } q.pop(); scanf("%s",p); for(a=t=0;!a;){ x=b; z=0; for(i=0;!a&&p[i];i++){ t++; f[j=b+d[p[i]-'2']]>-3?b=j:0; f[b]>=0&&t>=f[b]?a=b:0; f[b]>=0&&++z; } !z&!a&!p[i]&b==x&f[b]<0&&--a; } printf(a<0?"impossible\n":"%d %d %d\n",t,a/22-1,a%22-1); } }
a.cc: In function 'int main()': a.cc:50:2: error: expected '}' at end of input 50 | } | ^ a.cc:3:11: note: to match this '{' 3 | int main(){ | ^
s027475701
p00632
C++
#import<stdio.h> #import<queue.h> int main(){ queue<int> q; int w,h,f[484],i,j,d[]={22,0,-1,0,1,0,-22},a,b,t,x,z; char p[15]; for(;scanf("%d%d ",&h,&w),h;){ for(j=0;j<w+2;j++)f[j]=f[j-~h*22]=-9; for(i=1;i<=h;i++){ for(j=1;j<=w;j++){ f[x=i*22+j]=-1; switch(getchar()){ case'#':--f[x];break; case'A':a=x;break; case'B':b=x;break; } } f[i*22]=f[i*22-~w]=-9; getchar(); } f[a]=t=0; q.push(0); for(q.push(a);q.size()>1;){ a=q.front(); q.pop(); if(a){ for(i=0;i<7;i+=2) if(f[x=a+d[i]]==-1) f[x]=t, q.push(x); else ++t,q.push(0); } } q.pop(); scanf("%s",p); for(a=t=0;!a;){ x=b; z=0; for(i=0;!a&&p[i];i++){ t++; f[j=b+d[p[i]-'2']]>-3?b=j:0; f[b]>=0&&t>=f[b]?a=b:0; f[b]>=0&&++z; } !z&!a&!p[i]&b==x&f[b]<0&&--a; } printf(a<0?"impossible\n":"%d %d %d\n",t,a/22-1,a%22-1); } }
a.cc:1:2: warning: #import is a deprecated GCC extension [-Wdeprecated] 1 | #import<stdio.h> | ^~~~~~ a.cc:2:2: warning: #import is a deprecated GCC extension [-Wdeprecated] 2 | #import<queue.h> | ^~~~~~ a.cc:2:8: fatal error: queue.h: No such file or directory 2 | #import<queue.h> | ^~~~~~~~~ compilation terminated.
s622826785
p00632
C++
#import<stdio.h> #import<queue> int main(){std::queue<int>q;int w,h,f[484],i,j,a,b,t,x,z;char p[15];for(;scanf("%d%d ",&h,&w),h;){for(j=0;j<w+2;j++)f[j]=f[j-~h*22]=-9;for(i=1;i<=h;i++){for(j=1;j<=w;j++)f[x=i*22+j]=-1,z=getchar(),z-35?z>65?b=x:z>64?a=x:1:--f[x];f[i*22]=f[i*22-~w]=-9;getchar();}f[a]=t=0;q.push(0);for(q.push(a);a=q.front(),q.size()>1;q.pop())if(!a)++t,q.push(0);else for(i=4;i--;)if(f[x=a+" 57L"[i]-54]==-1)f[x]=t,q.push(x);q.pop();scanf("%s",p);for(a=t=0;!a;){x=b;z=0;for(i=0;!a&&p[i];f[b]>=0&&++z){++t,f[j=b-54+"L65676 "[p[i++]-50]]>-3?b=j:0,f[b]>=0&t>=f[b]?a=b:0;!z&!a&!p[i]&b==x&f[b]<0&&--a;}printf(a<0?"impossible\n":"%d %d %d\n",t,a/22-1,a%22-1);}}
a.cc:1:2: warning: #import is a deprecated GCC extension [-Wdeprecated] 1 | #import<stdio.h> | ^~~~~~ a.cc:2:2: warning: #import is a deprecated GCC extension [-Wdeprecated] 2 | #import<queue> | ^~~~~~ a.cc: In function 'int main()': a.cc:3:639: error: expected '}' at end of input 3 | int main(){std::queue<int>q;int w,h,f[484],i,j,a,b,t,x,z;char p[15];for(;scanf("%d%d ",&h,&w),h;){for(j=0;j<w+2;j++)f[j]=f[j-~h*22]=-9;for(i=1;i<=h;i++){for(j=1;j<=w;j++)f[x=i*22+j]=-1,z=getchar(),z-35?z>65?b=x:z>64?a=x:1:--f[x];f[i*22]=f[i*22-~w]=-9;getchar();}f[a]=t=0;q.push(0);for(q.push(a);a=q.front(),q.size()>1;q.pop())if(!a)++t,q.push(0);else for(i=4;i--;)if(f[x=a+" 57L"[i]-54]==-1)f[x]=t,q.push(x);q.pop();scanf("%s",p);for(a=t=0;!a;){x=b;z=0;for(i=0;!a&&p[i];f[b]>=0&&++z){++t,f[j=b-54+"L65676 "[p[i++]-50]]>-3?b=j:0,f[b]>=0&t>=f[b]?a=b:0;!z&!a&!p[i]&b==x&f[b]<0&&--a;}printf(a<0?"impossible\n":"%d %d %d\n",t,a/22-1,a%22-1);}} | ~ ^
s685249859
p00632
C++
int main(){std::queue<int>q;int w,h,f[484],i,j,a,b,t,x,z;char p[15];for(;scanf("%d%d ",&h,&w),h;){for(j=0;j<w+2;j++)f[j]=f[j-~h*22]=-9;for(i=1;i<=h;i++){for(j=1;j<=w;j++)f[x=i*22+j]=-1,z=getchar(),z-35?z>65?b=x:z>64?a=x:1:--f[x];f[i*22]=f[i*22-~w]=-9;getchar();}f[a]=t=0;q.push(0);for(q.push(a);a=q.front(),q.size()>1;q.pop())if(!a)++t,q.push(0);else for(i=4;i--;)if(f[x=a+" 57L"[i]-54]==-1)f[x]=t,q.push(x);q.pop();scanf("%s",p);for(a=t=0;!a;){x=b;z=0;for(i=0;!a&&p[i];f[b]>=0&&++z)++t,f[j=b-54+"L65676 "[p[i++]-50]]>-3?b=j:0,f[b]>=0&t>=f[b]?a=b:0;!z&!a&!p[i]&b==x&f[b]<0&&--a;}printf(a<0?"impossible\n":"%d %d %d\n",t,a/22-1,a%22-1);}}
a.cc: In function 'int main()': a.cc:1:17: error: 'queue' is not a member of 'std' 1 | int main(){std::queue<int>q;int w,h,f[484],i,j,a,b,t,x,z;char p[15];for(;scanf("%d%d ",&h,&w),h;){for(j=0;j<w+2;j++)f[j]=f[j-~h*22]=-9;for(i=1;i<=h;i++){for(j=1;j<=w;j++)f[x=i*22+j]=-1,z=getchar(),z-35?z>65?b=x:z>64?a=x:1:--f[x];f[i*22]=f[i*22-~w]=-9;getchar();}f[a]=t=0;q.push(0);for(q.push(a);a=q.front(),q.size()>1;q.pop())if(!a)++t,q.push(0);else for(i=4;i--;)if(f[x=a+" 57L"[i]-54]==-1)f[x]=t,q.push(x);q.pop();scanf("%s",p);for(a=t=0;!a;){x=b;z=0;for(i=0;!a&&p[i];f[b]>=0&&++z)++t,f[j=b-54+"L65676 "[p[i++]-50]]>-3?b=j:0,f[b]>=0&t>=f[b]?a=b:0;!z&!a&!p[i]&b==x&f[b]<0&&--a;}printf(a<0?"impossible\n":"%d %d %d\n",t,a/22-1,a%22-1);}} | ^~~~~ a.cc:1:1: note: 'std::queue' is defined in header '<queue>'; this is probably fixable by adding '#include <queue>' +++ |+#include <queue> 1 | int main(){std::queue<int>q;int w,h,f[484],i,j,a,b,t,x,z;char p[15];for(;scanf("%d%d ",&h,&w),h;){for(j=0;j<w+2;j++)f[j]=f[j-~h*22]=-9;for(i=1;i<=h;i++){for(j=1;j<=w;j++)f[x=i*22+j]=-1,z=getchar(),z-35?z>65?b=x:z>64?a=x:1:--f[x];f[i*22]=f[i*22-~w]=-9;getchar();}f[a]=t=0;q.push(0);for(q.push(a);a=q.front(),q.size()>1;q.pop())if(!a)++t,q.push(0);else for(i=4;i--;)if(f[x=a+" 57L"[i]-54]==-1)f[x]=t,q.push(x);q.pop();scanf("%s",p);for(a=t=0;!a;){x=b;z=0;for(i=0;!a&&p[i];f[b]>=0&&++z)++t,f[j=b-54+"L65676 "[p[i++]-50]]>-3?b=j:0,f[b]>=0&t>=f[b]?a=b:0;!z&!a&!p[i]&b==x&f[b]<0&&--a;}printf(a<0?"impossible\n":"%d %d %d\n",t,a/22-1,a%22-1);}} a.cc:1:23: error: expected primary-expression before 'int' 1 | int main(){std::queue<int>q;int w,h,f[484],i,j,a,b,t,x,z;char p[15];for(;scanf("%d%d ",&h,&w),h;){for(j=0;j<w+2;j++)f[j]=f[j-~h*22]=-9;for(i=1;i<=h;i++){for(j=1;j<=w;j++)f[x=i*22+j]=-1,z=getchar(),z-35?z>65?b=x:z>64?a=x:1:--f[x];f[i*22]=f[i*22-~w]=-9;getchar();}f[a]=t=0;q.push(0);for(q.push(a);a=q.front(),q.size()>1;q.pop())if(!a)++t,q.push(0);else for(i=4;i--;)if(f[x=a+" 57L"[i]-54]==-1)f[x]=t,q.push(x);q.pop();scanf("%s",p);for(a=t=0;!a;){x=b;z=0;for(i=0;!a&&p[i];f[b]>=0&&++z)++t,f[j=b-54+"L65676 "[p[i++]-50]]>-3?b=j:0,f[b]>=0&t>=f[b]?a=b:0;!z&!a&!p[i]&b==x&f[b]<0&&--a;}printf(a<0?"impossible\n":"%d %d %d\n",t,a/22-1,a%22-1);}} | ^~~ a.cc:1:74: error: 'scanf' was not declared in this scope 1 | int main(){std::queue<int>q;int w,h,f[484],i,j,a,b,t,x,z;char p[15];for(;scanf("%d%d ",&h,&w),h;){for(j=0;j<w+2;j++)f[j]=f[j-~h*22]=-9;for(i=1;i<=h;i++){for(j=1;j<=w;j++)f[x=i*22+j]=-1,z=getchar(),z-35?z>65?b=x:z>64?a=x:1:--f[x];f[i*22]=f[i*22-~w]=-9;getchar();}f[a]=t=0;q.push(0);for(q.push(a);a=q.front(),q.size()>1;q.pop())if(!a)++t,q.push(0);else for(i=4;i--;)if(f[x=a+" 57L"[i]-54]==-1)f[x]=t,q.push(x);q.pop();scanf("%s",p);for(a=t=0;!a;){x=b;z=0;for(i=0;!a&&p[i];f[b]>=0&&++z)++t,f[j=b-54+"L65676 "[p[i++]-50]]>-3?b=j:0,f[b]>=0&t>=f[b]?a=b:0;!z&!a&!p[i]&b==x&f[b]<0&&--a;}printf(a<0?"impossible\n":"%d %d %d\n",t,a/22-1,a%22-1);}} | ^~~~~ a.cc:1:188: error: 'getchar' was not declared in this scope 1 | int main(){std::queue<int>q;int w,h,f[484],i,j,a,b,t,x,z;char p[15];for(;scanf("%d%d ",&h,&w),h;){for(j=0;j<w+2;j++)f[j]=f[j-~h*22]=-9;for(i=1;i<=h;i++){for(j=1;j<=w;j++)f[x=i*22+j]=-1,z=getchar(),z-35?z>65?b=x:z>64?a=x:1:--f[x];f[i*22]=f[i*22-~w]=-9;getchar();}f[a]=t=0;q.push(0);for(q.push(a);a=q.front(),q.size()>1;q.pop())if(!a)++t,q.push(0);else for(i=4;i--;)if(f[x=a+" 57L"[i]-54]==-1)f[x]=t,q.push(x);q.pop();scanf("%s",p);for(a=t=0;!a;){x=b;z=0;for(i=0;!a&&p[i];f[b]>=0&&++z)++t,f[j=b-54+"L65676 "[p[i++]-50]]>-3?b=j:0,f[b]>=0&t>=f[b]?a=b:0;!z&!a&!p[i]&b==x&f[b]<0&&--a;}printf(a<0?"impossible\n":"%d %d %d\n",t,a/22-1,a%22-1);}} | ^~~~~~~ a.cc:1:1: note: 'getchar' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | int main(){std::queue<int>q;int w,h,f[484],i,j,a,b,t,x,z;char p[15];for(;scanf("%d%d ",&h,&w),h;){for(j=0;j<w+2;j++)f[j]=f[j-~h*22]=-9;for(i=1;i<=h;i++){for(j=1;j<=w;j++)f[x=i*22+j]=-1,z=getchar(),z-35?z>65?b=x:z>64?a=x:1:--f[x];f[i*22]=f[i*22-~w]=-9;getchar();}f[a]=t=0;q.push(0);for(q.push(a);a=q.front(),q.size()>1;q.pop())if(!a)++t,q.push(0);else for(i=4;i--;)if(f[x=a+" 57L"[i]-54]==-1)f[x]=t,q.push(x);q.pop();scanf("%s",p);for(a=t=0;!a;){x=b;z=0;for(i=0;!a&&p[i];f[b]>=0&&++z)++t,f[j=b-54+"L65676 "[p[i++]-50]]>-3?b=j:0,f[b]>=0&t>=f[b]?a=b:0;!z&!a&!p[i]&b==x&f[b]<0&&--a;}printf(a<0?"impossible\n":"%d %d %d\n",t,a/22-1,a%22-1);}} a.cc:1:252: error: 'getchar' was not declared in this scope 1 | int main(){std::queue<int>q;int w,h,f[484],i,j,a,b,t,x,z;char p[15];for(;scanf("%d%d ",&h,&w),h;){for(j=0;j<w+2;j++)f[j]=f[j-~h*22]=-9;for(i=1;i<=h;i++){for(j=1;j<=w;j++)f[x=i*22+j]=-1,z=getchar(),z-35?z>65?b=x:z>64?a=x:1:--f[x];f[i*22]=f[i*22-~w]=-9;getchar();}f[a]=t=0;q.push(0);for(q.push(a);a=q.front(),q.size()>1;q.pop())if(!a)++t,q.push(0);else for(i=4;i--;)if(f[x=a+" 57L"[i]-54]==-1)f[x]=t,q.push(x);q.pop();scanf("%s",p);for(a=t=0;!a;){x=b;z=0;for(i=0;!a&&p[i];f[b]>=0&&++z)++t,f[j=b-54+"L65676 "[p[i++]-50]]>-3?b=j:0,f[b]>=0&t>=f[b]?a=b:0;!z&!a&!p[i]&b==x&f[b]<0&&--a;}printf(a<0?"impossible\n":"%d %d %d\n",t,a/22-1,a%22-1);}} | ^~~~~~~ a.cc:1:252: note: 'getchar' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' a.cc:1:272: error: 'q' was not declared in this scope 1 | int main(){std::queue<int>q;int w,h,f[484],i,j,a,b,t,x,z;char p[15];for(;scanf("%d%d ",&h,&w),h;){for(j=0;j<w+2;j++)f[j]=f[j-~h*22]=-9;for(i=1;i<=h;i++){for(j=1;j<=w;j++)f[x=i*22+j]=-1,z=getchar(),z-35?z>65?b=x:z>64?a=x:1:--f[x];f[i*22]=f[i*22-~w]=-9;getchar();}f[a]=t=0;q.push(0);for(q.push(a);a=q.front(),q.size()>1;q.pop())if(!a)++t,q.push(0);else for(i=4;i--;)if(f[x=a+" 57L"[i]-54]==-1)f[x]=t,q.push(x);q.pop();scanf("%s",p);for(a=t=0;!a;){x=b;z=0;for(i=0;!a&&p[i];f[b]>=0&&++z)++t,f[j=b-54+"L65676 "[p[i++]-50]]>-3?b=j:0,f[b]>=0&t>=f[b]?a=b:0;!z&!a&!p[i]&b==x&f[b]<0&&--a;}printf(a<0?"impossible\n":"%d %d %d\n",t,a/22-1,a%22-1);}} | ^ a.cc:1:580: error: 'printf' was not declared in this scope 1 | int main(){std::queue<int>q;int w,h,f[484],i,j,a,b,t,x,z;char p[15];for(;scanf("%d%d ",&h,&w),h;){for(j=0;j<w+2;j++)f[j]=f[j-~h*22]=-9;for(i=1;i<=h;i++){for(j=1;j<=w;j++)f[x=i*22+j]=-1,z=getchar(),z-35?z>65?b=x:z>64?a=x:1:--f[x];f[i*22]=f[i*22-~w]=-9;getchar();}f[a]=t=0;q.push(0);for(q.push(a);a=q.front(),q.size()>1;q.pop())if(!a)++t,q.push(0);else for(i=4;i--;)if(f[x=a+" 57L"[i]-54]==-1)f[x]=t,q.push(x);q.pop();scanf("%s",p);for(a=t=0;!a;){x=b;z=0;for(i=0;!a&&p[i];f[b]>=0&&++z)++t,f[j=b-54+"L65676 "[p[i++]-50]]>-3?b=j:0,f[b]>=0&t>=f[b]?a=b:0;!z&!a&!p[i]&b==x&f[b]<0&&--a;}printf(a<0?"impossible\n":"%d %d %d\n",t,a/22-1,a%22-1);}} | ^~~~~~ a.cc:1:580: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
s700237058
p00632
C++
#include<iostream> #include<map> #include<string> #include<vector> #include<algorithm> #define all(c) c.begin(),c.end() #define pb push_back #define INF 10000000 using namespace std; typedef pair<int,int> P; int w,h; vector<string> s; P d[10]; int antime; P q; map<int,int> mp; string op; int dp[20][20][20][20][100]; bool in(P n){ if(n.second>=0&&n.second<w&&n.first>=0&&n.first<h) return true; return false; } void f(int cnt){ cout<<cnt<<endl; f(cnt+1); } int ans; int ret(P a,P b,int time){ //cout<<time<<endl; if(a==b){ if(antime>time){ antime=time; q.first=a.first; q.second=a.second; } //cout<<a.first<<" "<<a.second<<endl; //cout<<time<<endl; return time; } if(100<time) return INF; if(dp[a.first][a.second][b.first][b.second][time]!=-1) return dp[a.first][a.second][b.first][b.second][time]; int ans=INF; P na,nb; nb.first=b.first+d[op[time%op.size()]-'0'].first; nb.second=b.second+d[op[time%op.size()]-'0'].second; if(!in(nb)) nb=b; for(int i=0;i<5;i++){ na.first=a.first+d[mp[i]].first; na.second=a.second+d[mp[i]].second; if(in(na)&&s[na.first][na.second]!='#'){ //<<"-------"<<endl; ans=min(ans,ret(na,nb,time+1)); }/*(time%op.size()))*/ } return dp[a.first][a.second][b.first][b.second][time]=ans; } int main(){ d[5]=P(0,0);d[8]=P(-1,0);d[6]=P(0,1);d[4]=P(0,-1);d[2]=P(1,0); mp[0]=5;mp[1]=8;mp[2]=6;mp[3]=4;mp[4]=2; while(cin>>h>>w,h||w){ s.clear(); P a,b; antime=INF; memset(dp,-1,sizeof(dp)); for(int i=0;i<h;i++){ string t; cin>>t; s.pb(t); for(int j=0;j<t.size();j++){ if(t[j]=='A'){ a.first=i;a.second=j; }else if(t[j]=='B'){ b.first=i;b.second=j; } } }cin>>op; ret(a,b,0); if(antime!=INF) cout<<antime<< " "<<q.first<<" "<<q.second<<endl; else cout<<"impossible"<<endl; //f(0); //cout<<<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:74:17: error: 'memset' was not declared in this scope 74 | memset(dp,-1,sizeof(dp)); | ^~~~~~ a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 5 | #include<algorithm> +++ |+#include <cstring> 6 | #define all(c) c.begin(),c.end()
s070810929
p00633
C++
#include<bits/stdc++.h> #define inf 1<<29 #define linf 1e18 #define eps (1e-10) #define mod 1000000007 #define pi M_PI #define f first #define s second #define mp make_pair #define pb push_back #define all(a) (a).begin(),(a).end() #define pd(a) printf("%.10f\n",(double)(a)) #define FOR(i,a,b) for(int i=(a);i<(b);i++) #define equals(a,b) (fabs((a)-(b))<eps) using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair<int,int> pii; typedef vector<int> vi; typedef vector<pii> vpi; 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 k){ return Point(x*k,y*k);} Point operator/(double k){ return Point(x/k,y/k);} bool operator<(Point p)const{ return (x!=p.x ? x<p.x : y<p.y);} bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps;} double abs(){ return sqrt(norm());} double norm(){ return (x*x+y*y);} }; typedef Point Vector; typedef vector<Point> Polygon; class Segment{ public: Point p1,p2; Segment(Point p1=Point(),Point p2=Point()):p1(p1),p2(p2){} }; typedef Segment Line; class Circle{ public: Point c; double r; Circle(Point c=Point(),double r=0.0):c(c),r(r){} }; double norm(Vector a){ return (a.x*a.x+a.y*a.y);} double abs(Vector a){ return sqrt(norm(a));} 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);} double arg(Vector p){ return atan2(p.y,p.x);} Vector polar(double a,double r){ return Point(cos(r)*a,sin(r)*a);} bool in(Circle c,Point p){ if(abs(c.c-p)-c.r<-eps)return true; return false; } bool in(Circle a,Circle b){ if(b.r-a.r<-eps)return false; if(abs(a.c-b.c)+a.r-b.r<eps)return true; return false; } int intersect(Circle a,Circle b){ double dis=abs(a.c-b.c),sumr=a.r+b.r,minr=min(a.r,b.r),maxr=max(a.r,b.r); if((sumr-dis)<-eps)return 4; if(equals(sumr,dis))return 3; if((maxr-(dis+minr))<-eps)return 2; if(equals(dis+minr,maxr))return 1; return 0; } pair<Point,Point> getCrossPoints(Circle c1,Circle c2){ double d=abs(c1.c-c2.c); double a=acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d)); double t=arg(c2.c-c1.c); return mp(c1.c+polar(c1.r,t+a),c1.c+polar(c1.r,t-a)); } Point rotate(Point base,Point a,double r){ Point b=a-base; a.x=b.x*cos((r/180)*M_PI)-b.y*sin((r/180)*M_PI); a.y=b.x*sin((r/180)*M_PI)+b.y*cos((r/180)*M_PI); a=a+base; return a; } vector<Point> arg_sort(vector<Point> vp,Point base){ vector<pair<double,Point> > tmp; vector<Point> res; FOR(i,0,vp.size()){ double targ=arg(vp[i]-base); if(targ<0.0)targ+=2*pi; tmp.push_back(mp(targ,vp[i])); } sort(tmp.begin(),tmp.end()); FOR(i,0,tmp.size())res.push_back(tmp[i].s); return res; } double getAngle(Vector a,Vector b){ double tmp=dot(a,b)/(abs(a)*abs(b)); if(tmp<-1.0)tmp=-1.0; if(1.0<tmp)tmp=1.0; double r=acos(tmp)*180.0/pi; if(cross(a,b)<-eps)r=360.0-r; return r; } int n; vector<Circle> vc; double solve(){ double res=0.0; FOR(i,0,n){ bool bo=false; FOR(j,0,n){ if(i==j)continue; if(in(vc[i],vc[j]))bo=true; } if(bo)continue; vector<Point> vp; FOR(j,0,n){ if(i==j)continue; if(intersect(vc[i],vc[j])!=2)continue; pair<Point,Point> pp=getCrossPoints(vc[i],vc[j]); vp.pb(pp.f); vp.pb(pp.s); } vp=arg_sort(vp,vc[i].c); double sum=2*vc[i].r*pi; FOR(j,0,vp.size()){ Point a=vp[j],b=vp[(j+1)%vp.size()]; double r=getAngle(a-vc[i].c,b-vc[i].c); Point c=rotate(vc[i].c,a,r/2.0); bool flag=true; FOR(k,0,n)if(in(vc[k],c))flag=false; if(!flag)sum-=2*vc[i].r*pi*(r/360); } res+=sum; } return res; } int main() { while(cin>>n && n){ c.clear(); FOR(i,0,n){ int x,y,r; cin>>x>>y>>r; vc.pb(Circle(Point(x,y),r)); } pd(solve()); } return 0; }
a.cc: In function 'int main()': a.cc:156:5: error: 'c' was not declared in this scope; did you mean 'vc'? 156 | c.clear(); | ^ | vc
s371411669
p00633
C++
#include<iostream> #include<cfloat> #include<cassert> #include<cmath> #include<cstdio> #include<vector> using namespace std; #define EPS (1e-10) #define equals(a, b) (fabs((a) - (b)) < EPS ) #define dle(a, b) (equals(a, b) || a < b ) static const double PI = acos(-1); class Point{ public: double x, y; Point ( double x = 0, double y = 0): x(x), y(y){} Point operator + ( Point p ){ return Point(x + p.x, y + p.y); } Point operator - ( Point p ){ return Point(x - p.x, y - p.y); } Point operator * ( double a ){ return Point(x*a, y*a); } double abs() { return sqrt(norm());} double norm() { return x*x + y*y; } bool operator < ( const Point &p ) const { return x != p.x ? x < p.x : y < p.y; } bool operator == ( const Point &p ) const { return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS; } }; typedef Point Vector; class Segment{ public: Point p1, p2; Segment(Point s = Point(), Point t = Point()): p1(s), p2(t){} }; typedef Segment Line; static const int CIRCLE_NON = 0; static const int CIRCLE_OUT = 1; static const int CIRCLE_IN = 2; static const int CIRCLE_CROSS = 3; class Circle{ public: Point c; double r; Circle(Point c = Point(), double r = 0.0): c(c), r(r){} }; double norm( Vector a ){ return a.x*a.x + a.y*a.y; } double abs( Vector a ){ return sqrt(norm(a)); } Point polar( double a, double r ){ return Point(cos(r)*a, sin(r)*a);} double getDistance( Vector a, Vector b ){ return abs(a - b); } 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; } double getAngle(Point p){ double polar = atan2(p.y, p.x); return (dle(0, polar))? polar : 2.0*acos(-1)+polar; } int isIntersect(Circle c1, Circle c2){ double d = abs(c1.c - c2.c); if ( c1.r + c2.r < d ) return CIRCLE_NON; // no overlap if ( d + c2.r < c1.r ) return CIRCLE_IN; // c1 includes c2 if ( d + c1.r < c2.r ) return CIRCLE_OUT; // c2 includes c1 return CIRCLE_CROSS; } double arg(Vector p){ return atan2(p.y, p.x); } pair<Point, Point> getCrossPoints(Circle c1, Circle c2){ assert( isIntersect( c1, c2 ) ); double d = abs(c1.c - c2.c); double a = acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d)); double t = arg(c2.c - c1.c); return make_pair(c1.c+polar(c1.r, t+a), c1.c+polar(c1.r, t-a)); } Circle C[100]; int n; void compute(){ double len = 0.0; for ( int i = 0; i < n; i++ ){ vector<double> angles; for ( int j = 0; j < n; j++ ){ if ( i == j ) continue; if ( isIntersect(C[i], C[j]) != CIRCLE_CROSS ) continue; pair<Point, Point> pp = getCrossPoints(C[i], C[j]); angles.push_back(getAngle(pp.first - C[i].c)); angles.push_back(getAngle(pp.second - C[i].c)); } angles.push_back(0.0); angles.push_back(2*PI); sort( angles.begin(), angles.end() ); for ( int a = 1; a < angles.size(); a++ ) { Point m = C[i].c + polar(C[i].r, (angles[a]+angles[a-1])/2.0); bool included = false; for ( int t = 0; t < n; t++ ){ if ( t == i ) continue; if ( dle(getDistance(m, C[t].c), C[t].r) ) included = true; } if ( !included ){ len += (angles[a] - angles[a-1])*C[i].r; } } } printf("%.12lf\n", len); } int main(){ double x, y, r; while( cin >> n ){ if ( n == 0 ) break; for ( int i = 0; i < n; i++ ){ cin >> x >> y >> r; C[i] = Circle( Point(x, y), r); } compute(); } return 0; }
a.cc: In function 'void compute()': a.cc:110:9: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 110 | sort( angles.begin(), angles.end() ); | ^~~~ | sqrt
s240277087
p00633
C++
#include<iostream> #include<complex> #include<cmath> #include<vector> using namespace std; #define REP(i,b,n) for(int i=b;i<n;i++) #define rep(i,n) REP(i,0,n) typedef complex<double> P; double dot(P a,P b){ return a.real()*b.real()+a.imag()*b.imag(); } //‰~‚Ì’†SÀ•W‚ða,b,”¼Œa‚ðr1,r2‚Æ‚·‚éB //r1‚Ær2‚ÌŠÔ‚Ì‹——£‚ð‹‚ß‚Ä—]Œ·’藝‚É‚æ‚èr1‚Æ‚»‚̕ӂ̂Ȃ·Šp‚ð‹‚ß‚éB //‚ ‚Æ‚Ípolar‚ðŽg‚Á‚čÀ•W‚𐶐¬‚·‚éB //“ñ“_‚̍À•W‚ð•Ô‚·B pair<P,P> CC_intersection(P a,P b,double r1,double r2){//‰~‚Ɖ~‚ÌŒð“_ double r3 = abs(a-b); double theta = acos( (r1*r1 + r3*r3 -r2*r2)/(2*r1*r3) ); if ( dot(polar(r1,theta),b-a) <0)theta=acos(-1)-theta; return make_pair(polar(r1,theta)+a,polar(r1,-theta)+a); } bool cmp(const P &a,const P&b){ return arg(a)<arg(b); } class Circle{ public: vector<P> data; }; double solve(int n,P *in,double *r){ Circle data[n]; double ret =0; rep(i,n){ rep(j,n){ if ( i==j)continue; if ( r[i]+r[j] <abs(in[i]-in[j]))continue; pair<P,P> a=CC_intersection(in[i],in[j],r[i],r[j]); data[i].data.push_back(a.first-in[i]); data[i].data.push_back(a.second-in[i]); } } rep(i,n){ sort(data[i].data.begin(),data[i].data.end(),cmp); } rep(i,n){ cout << i <<endl; rep(j,data[i].data.size()){ cout << data[i].data[j] << " " << arg(data[i].data[j])<<endl; } } rep(i,n)rep(j,data[i].data.size())data[i].data[j]+=in[i]; rep(i,n){ int size=data[i].data.size(); rep(j,size){ P now = data[i].data[j]-in[i],nex=data[i].data[(j+1)%size]-in[i]; P t=now; double theta = (arg(nex)-arg(now))/2; if (arg(nex)<0)theta=(acos(-1)*2+arg(nex)-arg(now))/2; P mid = P(t.real()*cos(theta)-t.imag()*sin(theta),t.real()*sin(theta)+t.imag()*cos(theta))+in[i]; // cout <<abs(mid-in[i]) <<" " << abs(now-in[i]) << " " << abs(nex-in[i]) << endl; //cout << abs(mid-now) << " " << abs(mid-nex) << endl; bool flag=true; rep(k,n){ if ( i == k)continue; if (abs(in[k]-mid)<r[k]){cout << k << endl;flag=false;break;} } if ( flag)ret+=r[i]*abs(theta*2); } } return ret; } main(){ int n; while(cin>>n&&n){ P in[n];double r[n]; rep(i,n)cin>>in[i].real()>>in[i].imag()>>r[i]; printf("%.7lf\n",solve(n,in,r)); } return false; }
a.cc: In function 'double solve(int, P*, double*)': a.cc:48:5: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 48 | sort(data[i].data.begin(),data[i].data.end(),cmp); | ^~~~ | sqrt a.cc: At global scope: a.cc:87:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 87 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:91:16: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'double') 91 | rep(i,n)cin>>in[i].real()>>in[i].imag()>>r[i]; | ~~~^~~~~~~~~~~~~~ | | | | | double | std::istream {aka std::basic_istream<char>} In file included from /usr/include/c++/14/iostream:42, from a.cc:1: /usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed: a.cc:91:28: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double' 91 | rep(i,n)cin>>in[i].real()>>in[i].imag()>>r[i]; | ~~~~~~~~~~^~ /usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed: a.cc:91:28: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'double' 91 | rep(i,n)cin>>in[i].real()>>in[i].imag()>>r[i]; | ~~~~~~~~~~^~ /usr/include/c++/14/istream:177:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(short unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:7: note: conversion of argument 1 would be ill-formed: a.cc:91:28: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'double' 91 | rep(i,n)cin>>in[i].real()>>in[i].imag()>>r[i]; | ~~~~~~~~~~^~ /usr/include/c++/14/istream:181:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match) 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:7: note: conversion of argument 1 would be ill-formed: a.cc:91:28: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'double' 91 | rep(i,n)cin>>in[i].real()>>in[i].imag()>>r[i]; | ~~~~~~~~~~^~ /usr/include/c++/14/istream:184:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:7: note: conversion of argument 1 would be ill-formed: a.cc:91:28: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'double' 91 | rep(i,n)cin>>in[i].real()>>in[i].imag()>>r[i]; | ~~~~~~~~~~^~ /usr/include/c++/14/istream:188:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:7: note: conversion of argument 1 would be ill-formed: a.cc:91:28: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'double' 91 | rep(i,n)cin>>in[i].real()>>in[i].imag()>>r[i]; | ~~~~~~~~~~^~ /usr/include/c++/14/istream:192:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:7: note: conversion of argument 1 would be ill-formed: a.cc:91:28: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'double' 91 | rep(i,n)cin>>in[i].real()>>in[i].imag()>>r[i]; | ~~~~~~~~~~^~ /usr/include/c++/14/istream:199:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:7: note: conversion of argument 1 would be ill-formed: a.cc:91:28: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'double' 91 | rep(i,n)cin>>in[i].real()>>in[i].imag()>>r[i]; | ~~~~~~~~~~^~ /usr/include/c++/14/istream:203:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long long unsigned int&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:7: note: conversion of argument 1 would be ill-formed: a.cc:91:28: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'double' 91 | rep(i,n)cin>>in[i].real()>>in[i].imag()>>r[i]; | ~~~~~~~~~~^~ /usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 219 | operator>>(float& __f) | ^~~~~~~~ /usr/include/c++/14/istream:219:7: note: conversion of argument 1 would be ill-formed: a.cc:91:28: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'double' 91 | rep(i,n)cin>>in[i].real()>>in[i].imag()>>r[i]; | ~~~~~~~~~~^~ /usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 223 | operator>>(double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:223:7: note: conversion of argument 1 would be ill-formed: a.cc:91:28: error: cannot bind non-const lvalue reference of type 'double&' to an rvalue of type 'double' 91 | rep(i,n)cin>>in[i].real()>>in[i].imag()>>r[i]; | ~~~~~~~~~~^~ /usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match) 227 | operator>>(long double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:227:7: note: conversion of argument 1 would be ill-formed: a.cc:91:28: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type 'double' 91 | rep(i,n)cin>>in[i].real()>>in[i].imag()>>r[i]; | ~~~~~~~~~~^~ /usr/include/c++/14/istream:328:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(void*&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:25: note: no known conversion for argument 1 from 'double' to 'void*&' 328 | operator>>(void*& __p) | ~~~~~~~^~~ /usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:36: note: no known conversion for argument 1 from 'double' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]' 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:126:32: note: no known conversion for argument 1 from 'double' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka '
s626798749
p00633
C++
#include<cstdio> #include<vector> #include<complex> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; typedef complex<double> Point; const double EPS=1e-9; const double PI=acos(-1); class Line:public vector<Point>{ public: Line(){} Line(const Point &a,const Point &b){ push_back(a), push_back(b); } }; class Segment:public Line{ public: Segment(){} Segment(const Point &a,const Point &b):Line(a,b){} }; class Circle{ public: Point c; double r; Circle(){} Circle(const Point &C,double R):c(C),r(R){} }; inline double dot(const Point &a,const Point &b){ return a.real()*b.real()+a.imag()*b.imag(); } inline double cross(const Point &a,const Point &b){ return a.real()*b.imag()-a.imag()*b.real(); } inline void calc_abc(const Line &l,double &a,double &b,double &c){ a=l[0].imag()-l[1].imag(); b=l[1].real()-l[0].real(); c=cross(l[0],l[1]); } Point PerpFoot(const Point &p,const Line &l){ double a,b,c; calc_abc(l,a,b,c); Point v(a,b); return p-(dot(p,v)+c)*v/norm(v); } bool cover(const Segment &s,const Point &p){ return dot(s[0]-p,s[1]-p)<EPS; } bool cover(const Circle &c,const Point &p){ return abs(p-c.c)<c.r+EPS; } bool cover(const Circle &c1,const Circle &c2){ return abs(c1.c-c2.c)<c1.r+EPS; } int intersect(const Circle &c,const Line &l,Point &p,Point &q){ Point m=PerpFoot(c.c,l); double d2=norm(c.c-m); if(c.r*c.r+EPS<d2) return 0; else if(abs(c.r*c.r-d2)<EPS){ p=q=m; return 1; } else{ Point v; double n0=norm(l[0]-m),n1=norm(l[1]-m); if(n0<n1) v=l[1]-m, n0=n1; else v=l[0]-m; v*=sqrt((c.r*c.r-d2)/n0); p=m+v, q=m-v; return 2; } } int intersect(const Circle &c,const Segment &s,Point &p,Point &q){ Point pp,qq; int n=intersect(c,Line(s),pp,qq); if(n==0) return 0; else if(n==1){ if(cover(s,pp)){ p=q=pp; return 1; } return 0; } else{ bool bp=cover(s,pp),bq=cover(s,qq); if(bp&&bq){ p=pp, q=qq; return 2; } if(bp||bq){ p=q=(bp?pp:qq); return 1; } return 0; } } int intersect(const Circle &c1,const Circle &c2,Point &p,Point &q){ double d2=norm(c1.c-c2.c); if(d2<EPS && abs(c1.r-c2.r)<EPS) return -1; // c1==c2 if((c1.r+c2.r)*(c1.r+c2.r)+EPS<d2 || d2+EPS<(c1.r-c2.r)*(c1.r-c2.r)) return 0; if(abs(c1.r+c2.r-d2)<EPS){ intersect(c1,Segment(c1.c,c2.c),p,q); return 1; } double d=sqrt(d2); double a=(c1.r*c1.r-c2.r*c2.r+d2)/(2*d); double h=sqrt(c1.r*c1.r-a*a); p=q=c1.c+a/d*(c2.c-c1.c); Point tmp=h*(c2.c-c1.c)/d; p+=tmp*Point(0,-1); q+=tmp*Point(0,+1); return 2; } Point c_cmp; bool cmp_arg(const Point &p,const Point &q){ return arg(p-c_cmp)<arg(q-c_cmp); } int main(){ for(int n;scanf("%d",&n),n;){ Circle C[100]; rep(i,n){ double x,y; scanf("%lf%lf%lf",&x,&y,&C[i].r); C[i].c=Point(x,y); } vector<Point> P[100]; rep(j,n) rep(i,j) { Point p,q; if(intersect(C[i],C[j],p,q)>0){ P[i].push_back(p); P[i].push_back(q); P[j].push_back(p); P[j].push_back(q); } } double ans=0; rep(i,n){ bool cov=false; rep(j,n) if(j!=i && cover(C[j],C[i])) cov=true; if(cov) continue; int m=P[i].size(); c_cmp=C[i].c; sort(P[i].begin(),P[i].end(),cmp_arg); if(m==0) ans+=2*PI*C[i].r; rep(j,m){ const Point &a=P[i][j],&b=P[i][(j+1)%m]; double theta=arg(b-C[i].c)-arg(a-C[i].c); if(theta<0) theta+=2*PI; Point c=C[i].c+(a-C[i].c)*exp(Point(0,theta/2)); bool ok=true; rep(k,n) if(k!=i && cover(C[k],c)) ok=false; if(ok) ans+=C[i].r*theta; } } printf("%.9f\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:158:25: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 158 | sort(P[i].begin(),P[i].end(),cmp_arg); | ^~~~ | sqrt
s993514561
p00633
C++
#include <iostream> #include <vector> #include <set> #include <map> #include <algorithm> #include <cstdio> #include <queue> #include <complex> using namespace std; #define rep(i,n) for(int i = 0 ; i < n ; i++) const double EPS = 1e-10; typedef complex<double> P,point; struct C {P p; double r;C(const P &p, double r) : p(p), r(r) { } C(){} }; vector<P> C_cp(C a,C b){ vector<P> ret; double L = abs(a.p-b.p); if( L-a.r-b.r > EPS || (abs(a.p-b.p)<EPS && fabs(a.r-b.r)<EPS) || abs(a.p-b.p) < abs(a.r-b.r) )return ret; double theta = atan2(b.p.imag()-a.p.imag(),b.p.real()-a.p.real()); double c = (L*L+a.r*a.r-b.r*b.r)/(2*L*a.r); ret.push_back( P(a.p.real()+a.r*cos(theta+acos(c)), a.p.imag()+a.r*sin(theta+acos(c))) ); if(fabs(L-a.r-b.r) > EPS) ret.push_back( P(a.p.real()+a.r*cos(theta-acos(c)), a.p.imag()+a.r*sin(theta-acos(c))) ); return ret; } bool have(C a,C b){ return abs(a.p-b.p) + b.r <= a.r; } bool pHave(C a,P b){ return abs(a.p-b) <= a.r; } bool hit( C a,C b ){ return abs(a.p-b.p) < a.r + b.r; } double Len(const C &a,pair<P,P> cp){ cp[0] -= a.p; cp[1] -= a.p; double U = atan2(cp[1].y,cp[1].x); double D = atan2(cp[0].y,cp[0].x); if( D > U ) D -= 2 * PI; return (2*a.r) * PI * (U - D) / (2 * PI); } int main(){ int n; while(cin >> n && n){ vector<C> c_; for(int i = 0 ; i < n ; i++){ double x,y,r; cin >> x >> y >> r; c_.push_back(C(P(x,y),r)); } bool dead[100] = {}; for(int i = 0 ; i < n ; i++){ for(int j = 0 ; j < n ; j++){ if( i != j ){ if( have(c_[i],c_[j]) ) dead[j] = true; } } } vector<C> c; for(int i = 0 ; i < n ; i++) if( !dead[i] ) c.push_back(c_[i]); vector< pair<P,P> > seg[100]; n = c.size(); for(int i = 0 ; i < n ; i++){ // kottiga for(int j = 0 ; j < n ; j++){ // kottiwo taberu if( i != j && hit(c[i],c[j]) ){ vector<P> cp = C_cp(c[i],c[j]); for(int k = 0 ; k < seg[j].size() ; k++){ if( pHave(c[i],seg[j][k].first) && pHave(c[i],seg[j][k].second) ){ } } } } } } }
a.cc: In function 'double Len(const C&, std::pair<std::complex<double>, std::complex<double> >)': a.cc:51:11: error: no match for 'operator[]' (operand types are 'std::pair<std::complex<double>, std::complex<double> >' and 'int') 51 | cp[0] -= a.p; | ^ a.cc:52:11: error: no match for 'operator[]' (operand types are 'std::pair<std::complex<double>, std::complex<double> >' and 'int') 52 | cp[1] -= a.p; | ^ a.cc:53:28: error: no match for 'operator[]' (operand types are 'std::pair<std::complex<double>, std::complex<double> >' and 'int') 53 | double U = atan2(cp[1].y,cp[1].x); | ^ a.cc:53:36: error: no match for 'operator[]' (operand types are 'std::pair<std::complex<double>, std::complex<double> >' and 'int') 53 | double U = atan2(cp[1].y,cp[1].x); | ^ a.cc:54:28: error: no match for 'operator[]' (operand types are 'std::pair<std::complex<double>, std::complex<double> >' and 'int') 54 | double D = atan2(cp[0].y,cp[0].x); | ^ a.cc:54:36: error: no match for 'operator[]' (operand types are 'std::pair<std::complex<double>, std::complex<double> >' and 'int') 54 | double D = atan2(cp[0].y,cp[0].x); | ^ a.cc:55:30: error: 'PI' was not declared in this scope; did you mean 'P'? 55 | if( D > U ) D -= 2 * PI; | ^~ | P a.cc:56:26: error: 'PI' was not declared in this scope; did you mean 'P'? 56 | return (2*a.r) * PI * (U - D) / (2 * PI); | ^~ | P
s002757347
p00633
C++
#include<iostream> #include<vector> #include<cmath> using namespace std; struct POINT{ double x; double y; }; struct CIRCLE{ POINT p; double r; }; struct DATA{ double radian; int log; }; int CheckCase(const CIRCLE, const CIRCLE); double GetDistance(const CIRCLE, const CIRCLE); void GetDigree(const CIRCLE, const CIRCLE, double&, double&); void PushBackData(vector<DATA>&, double, int); bool Compare(const DATA&, const DATA&); double CalculateLength(const vector<DATA>, double); int main(){ int i, j, n, x, y, r, is_case; double t1, t2, sum; CIRCLE _circle; vector<CIRCLE> circle; vector<DATA> data; while(1){ cin >> n; if(n == 0) break; for(i=0; i<n; ++i){ cin >> x >> y >> r; _circle.p.x = (double)x; _circle.p.y = (double)y; _circle.r = (double)r; circle.push_back(_circle); } for(i=0, sum=0.0; i<circle.size(); ++i){ for(j=0; j<circle.size(); ++j){ is_case = CheckCase(circle[i], circle[j]); if(is_case == 1){ GetDigree(circle[i], circle[j], t1, t2); if(t1 < 0) t1 += 2*M_PI; if(t2 < 0) t2 += 2*M_PI; if(t1 < t2){ PushBackData(data, t1, 1); PushBackData(data, t2, -1); }else{ PushBackData(data, 0.0, 1); PushBackData(data, t2, -1); PushBackData(data, t1, 1); PushBackData(data, 2*M_PI, -1); } }else if(is_case == 2){ data.clear(); PushBackData(data, 0.0, 1); PushBackData(data, 2*M_PI, -1); break; } } sort(data.begin(), data.end(), Compare); sum += CalculateLength(data, circle[i].r); data.clear(); } cout.setf(ios::fixed, ios::floatfield); cout.precision(12); cout << sum << endl; circle.clear(); } return 0; } int CheckCase(const CIRCLE c1, const CIRCLE c2){ double d; d = GetDistance(c1, c2); if(c1.p.x == c2.p.x && c1.p.y == c2.p.y && c1.r == c2.r) return 0; if(d >= c1.r + c2.r) return -1; if(c1.r >= c2.r + d) return 3; if(c2.r >= c1.r + d) return 2; return 1; } double GetDistance(const CIRCLE c1, const CIRCLE c2){ double x, y; x = c1.p.x - c2.p.x; y = c1.p.y - c2.p.y; return sqrt(x*x + y*y); } void GetDigree(const CIRCLE c1, const CIRCLE c2, double& theta1, double& theta2){ double a, b1, b2, t1, t2; CIRCLE c3; if(c1.p.x == c2.p.x){ a = (c1.p.y*c1.p.y - c1.r*c1.r - c2.p.y*c2.p.y + c2.r*c2.r) /(2*(c1.p.y - c2.p.y)); if(c1.p.y < c2.p.y){ t1 = M_PI /2; t2 = acos((a - c1.p.y)/c1.r); }else{ t1 = -M_PI /2; t2 = acos((c1.p.y - a)/c1.r); } }else if(c1.p.y == c2.p.y){ a = (c1.p.x*c1.p.x - c1.r*c1.r - c2.p.x*c2.p.x + c2.r*c2.r) /(2*(c1.p.x - c2.p.x)); if(c1.p.x < c2.p.x){ t1 = 0.0; t2 = acos((a - c1.p.x)/c1.r); }else{ t1 = M_PI; t2 = acos((c1.p.x - a)/c1.r); } }else{ a = (c1.p.y - c2.p.y)/(c1.p.x - c2.p.x); b1 = c1.p.y - a * c1.p.x; b2 = (c1.p.x*c1.p.x + c1.p.y*c1.p.y - c1.r*c1.r - c2.p.x*c2.p.x - c2.p.y*c2.p.y + c2.r*c2.r)/(2*(c1.p.y - c2.p.y)); c3.p.x = a*(b2 - b1)/(a*a + 1); c3.p.y = (b2*a*a + b1)/(a*a + 1); if(c1.p.x < c2.p.x) t1 = atan(a); else t1 = atan(a) + M_PI; t2 = acos(GetDistance(c1, c3)/c1.r); } theta1 = t1 - t2; theta2 = t1 + t2; } void PushBackData(vector<DATA>& data, double radian, int log){ DATA _data; _data.radian = radian; _data.log = log; data.push_back(_data); } bool Compare(const DATA& x, const DATA& y){ if(x.radian == y.radian) return x.log > y.log; else return x.radian < y.radian; } double CalculateLength(const vector<DATA> data, double r){ int i, j, count; double radian; for(i=0, j=0, count=0, radian=0.0; j<data.size(); ++j){ count += data[j].log; if(count == 0){ radian += (data[j].radian - data[i].radian); i = j + 1; } } return r*(2*M_PI - radian); }
a.cc: In function 'int main()': a.cc:71:7: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 71 | sort(data.begin(), data.end(), Compare); | ^~~~ | sqrt
s235365190
p00633
C++
#include <algorithm> #include <cassert> #include <cmath> #include <iomanip> #include <iostream> #include <vector> #define EPSILON 1e-9 class point_t; class vector_t { public: double x; double y; double z; public: vector_t(double x = 0, double y = 0, double z = 0) : x(x), y(y), z(z) {}; vector_t(const point_t& p); public: double operator[](int i) const { return (i == 0) ? x : (i == 1) ? y : z; }; double& operator[](int i) { return (i == 0) ? x : (i == 1) ? y : z; }; public: vector_t operator-() const { return vector_t(-x, -y, -z); }; vector_t operator+(const vector_t& v) const { return vector_t(x + v.x, y + v.y, z + v.z); }; double operator*(const vector_t& v) const { return x * v.x + y * v.y + z * v.z; }; vector_t operator*(double a) const { return vector_t(x * a, y * a, z * a); }; vector_t operator/(double a) const { return vector_t(x / a, y / a, z / a); }; vector_t operator^(const vector_t& v) const { return vector_t(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x); }; vector_t operator-=(const vector_t& v) { x -= v.x; y -= v.y; z -= v.z; return *this; }; public: double length() const { return sqrt(*this * *this); }; vector_t normal() const { return *this / length(); }; }; class point_t { public: double x; double y; double z; double w; public: point_t(double x = 0, double y = 0, double z = 0, double w = 1) : x(x), y(y), z(z), w(w) {}; point_t(const vector_t& v) : x(v.x), y(v.y), z(v.z), w(1) {}; public: double operator[](int i) const { return (i == 0) ? x : (i == 1) ? y : (i == 2) ? z : w; }; double& operator[](int i) { return (i == 0) ? x : (i == 1) ? y : (i == 2) ? z : w; }; public: point_t operator+(const vector_t& v) const { return point_t(x + v.x, y + v.y, z + v.z); }; vector_t operator-(const point_t& p) const { return vector_t(x - p.x, y - p.y, z - p.z); }; }; vector_t::vector_t(const point_t& p) : x(p.x / p.w), y(p.y / p.w), z(p.z / p.w) { } class matrix_t { public: matrix_t() { identitize(); }; public: const double* operator[](int i) const { return matrix_[i]; }; double* operator[](int i) { return matrix_[i]; }; public: void identitize() { memset(matrix_, 0, sizeof(matrix_)); matrix_[0][0] = matrix_[1][1] = matrix_[2][2] = matrix_[3][3] = 1; }; public: matrix_t operator*(const matrix_t& m) const { matrix_t r; for (int i = 0; i < 4; i ++) for (int j = 0; j < 4; j ++) r[i][j] = matrix_[i][0] * m[0][j] + matrix_[i][1] * m[1][j] + matrix_[i][2] * m[2][j] + matrix_[i][3] * m[3][j]; return r; }; vector_t operator*(const vector_t& v) const { vector_t r; for (int i = 0; i < 3; i ++) r[i] = matrix_[i][0] * v.x + matrix_[i][1] * v.y + matrix_[i][2] * v.z + matrix_[i][3]; return r; }; point_t operator*(const point_t& p) const { point_t r; for (int i = 0; i < 4; i ++) r[i] = matrix_[i][0] * p.x + matrix_[i][1] * p.y + matrix_[i][2] * p.z + matrix_[i][3] * p.w; return r; }; public: static matrix_t translation(double x = 0, double y = 0, double z = 0) { matrix_t m; m[0][3] = x; m[1][3] = y; m[2][3] = z; return m; }; static matrix_t rotation(double theta = 0) { matrix_t m; m[0][0] = cos(theta); m[0][1] = -sin(theta); m[1][0] = sin(theta); m[1][1] = cos(theta); return m; }; static matrix_t scale(double s = 1) { matrix_t m; m[0][0] = m[1][1] = m[2][2] = s; return m; }; private: double matrix_[4][4]; }; class point_circle_intersect : public std::unary_function<point_t, bool> { public: point_circle_intersect(const point_t& o, double r) : o_(o), rr_(r * r + EPSILON) {}; public: bool operator()(const point_t& p) const { vector_t v(p - o_); return v * v < rr_; }; private: point_t o_; double rr_; }; class circle_circle_intersect { public: circle_circle_intersect(const point_t& p, double r) : p_(p), r_(r) {}; public: bool operator()(const point_t& p, double r) const { vector_t v(p - p_); r += r_; return v * v - r * r < EPSILON; }; private: point_t p_; double r_; }; int n; std::vector<point_t> points; std::vector<double> rs; double normalize(double a) { while (a < 0) a += 2 * M_PI; while (a > 2 * M_PI) a -= 2 * M_PI; return a; } double dfs(int i, double s, double e, int j) { if (j == n) return rs[i] * (e - s); if (i == j) { return dfs(i, s, e, j + 1); } else if (circle_circle_intersect(points[i], rs[i])(points[j], rs[j])) { vector_t v1(points[i]), v2(points[j]); double r1(rs [i]), r2(rs [j]); double a = -(v1.x - v2.x) / (v1.y - v2.y); double b = (v2 * v2 - v1 * v1 + r1 * r1 - r2 * r2) / 2 / (- v1.y + v2.y); double A = a * a + 1; double B = a * (b - v1.y) - v1.x; double C = b * (b - 2 * v1.y) + v1 * v1 - r1 * r1; double D = sqrt(B * B - A * C); point_t p1((- B + D) / A, a * (- B + D) / A + b); point_t p2((- B - D) / A, a * (- B - D) / A + b); double ss = normalize(atan2(p1.y - v1.y, p1.x - v1.x)); double ee = normalize(atan2(p2.y - v1.y, p2.x - v1.x)); if (ss > ee) std::swap(ss, ee); double m = (ss + ee) / 2; if (point_circle_intersect(v2, r2)(matrix_t::translation(v1.x, v1.y) * matrix_t::scale(r1) * matrix_t::rotation(m) * vector_t(1))) { ; } else { std::swap(ss, ee); ss = normalize(ss); ee = normalize(ee); } if (ss < ee) { if (ss <= s && e <= ee) { return 0; } else if (ee <= s || e <= ss) { return dfs(i, s, e, j + 1); } else if (s <= ss && ee <= e) { return dfs(i, s, ss, j + 1) + dfs(i, ee, e, j + 1); } else if (ss <= e) { return dfs(i, ss, e, j + 1); } else if (ee <= e) { return dfs(i, s, ee, j + 1); } assert(false); } else { return dfs(i, std::max(s, ee), std::min(e, ss), j + 1); } } else { return dfs(i, s, e, j + 1); } } int main(int argc, char** argv) { while (1) { std::cin >> n; if (n == 0) break; points.resize(n); rs .resize(n); for (int i = 0; i < n; i ++) std::cin >> points[i].x >> points[i].y >> rs[i]; double a = 0; for (int i = 0; i < n; i ++) a += dfs(i, 0, 2 * M_PI, 0); std::cout << std::setprecision(14) << a << std::endl; } return 0; }
a.cc: In member function 'void matrix_t::identitize()': a.cc:136:5: error: 'memset' was not declared in this scope 136 | memset(matrix_, 0, sizeof(matrix_)); | ^~~~~~ a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 6 | #include <vector> +++ |+#include <cstring> 7 | a.cc: At global scope: a.cc:220:44: warning: 'template<class _Arg, class _Result> struct std::unary_function' is deprecated [-Wdeprecated-declarations] 220 | class point_circle_intersect : public std::unary_function<point_t, bool> | ^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:49, 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/iomanip:42, from a.cc:4: /usr/include/c++/14/bits/stl_function.h:117:12: note: declared here 117 | struct unary_function | ^~~~~~~~~~~~~~
s872572391
p00633
C++
#include <algorithm> #include <cassert> #include <cmath> #include <cstdlib> #include <iomanip> #include <iostream> #include <vector> #define EPSILON 1e-9 class point_t; class vector_t { public: double x; double y; double z; public: vector_t(double x = 0, double y = 0, double z = 0) : x(x), y(y), z(z) {}; vector_t(const point_t& p); public: double operator[](int i) const { return (i == 0) ? x : (i == 1) ? y : z; }; double& operator[](int i) { return (i == 0) ? x : (i == 1) ? y : z; }; public: vector_t operator-() const { return vector_t(-x, -y, -z); }; vector_t operator+(const vector_t& v) const { return vector_t(x + v.x, y + v.y, z + v.z); }; double operator*(const vector_t& v) const { return x * v.x + y * v.y + z * v.z; }; vector_t operator*(double a) const { return vector_t(x * a, y * a, z * a); }; vector_t operator/(double a) const { return vector_t(x / a, y / a, z / a); }; vector_t operator^(const vector_t& v) const { return vector_t(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x); }; vector_t operator-=(const vector_t& v) { x -= v.x; y -= v.y; z -= v.z; return *this; }; public: double length() const { return sqrt(*this * *this); }; vector_t normal() const { return *this / length(); }; }; class point_t { public: double x; double y; double z; double w; public: point_t(double x = 0, double y = 0, double z = 0, double w = 1) : x(x), y(y), z(z), w(w) {}; point_t(const vector_t& v) : x(v.x), y(v.y), z(v.z), w(1) {}; public: double operator[](int i) const { return (i == 0) ? x : (i == 1) ? y : (i == 2) ? z : w; }; double& operator[](int i) { return (i == 0) ? x : (i == 1) ? y : (i == 2) ? z : w; }; public: point_t operator+(const vector_t& v) const { return point_t(x + v.x, y + v.y, z + v.z); }; vector_t operator-(const point_t& p) const { return vector_t(x - p.x, y - p.y, z - p.z); }; }; vector_t::vector_t(const point_t& p) : x(p.x / p.w), y(p.y / p.w), z(p.z / p.w) { } class matrix_t { public: matrix_t() { identitize(); }; public: const double* operator[](int i) const { return matrix_[i]; }; double* operator[](int i) { return matrix_[i]; }; public: void identitize() { memset(matrix_, 0, sizeof(matrix_)); matrix_[0][0] = matrix_[1][1] = matrix_[2][2] = matrix_[3][3] = 1; }; public: matrix_t operator*(const matrix_t& m) const { matrix_t r; for (int i = 0; i < 4; i ++) for (int j = 0; j < 4; j ++) r[i][j] = matrix_[i][0] * m[0][j] + matrix_[i][1] * m[1][j] + matrix_[i][2] * m[2][j] + matrix_[i][3] * m[3][j]; return r; }; vector_t operator*(const vector_t& v) const { vector_t r; for (int i = 0; i < 3; i ++) r[i] = matrix_[i][0] * v.x + matrix_[i][1] * v.y + matrix_[i][2] * v.z + matrix_[i][3]; return r; }; point_t operator*(const point_t& p) const { point_t r; for (int i = 0; i < 4; i ++) r[i] = matrix_[i][0] * p.x + matrix_[i][1] * p.y + matrix_[i][2] * p.z + matrix_[i][3] * p.w; return r; }; public: static matrix_t translation(double x = 0, double y = 0, double z = 0) { matrix_t m; m[0][3] = x; m[1][3] = y; m[2][3] = z; return m; }; static matrix_t rotation(double theta = 0) { matrix_t m; m[0][0] = cos(theta); m[0][1] = -sin(theta); m[1][0] = sin(theta); m[1][1] = cos(theta); return m; }; static matrix_t scale(double s = 1) { matrix_t m; m[0][0] = m[1][1] = m[2][2] = s; return m; }; private: double matrix_[4][4]; }; class point_circle_intersect : public std::unary_function<point_t, bool> { public: point_circle_intersect(const point_t& o, double r) : o_(o), rr_(r * r + EPSILON) {}; public: bool operator()(const point_t& p) const { vector_t v(p - o_); return v * v < rr_; }; private: point_t o_; double rr_; }; class circle_circle_intersect { public: circle_circle_intersect(const point_t& p, double r) : p_(p), r_(r) {}; public: bool operator()(const point_t& p, double r) const { vector_t v(p - p_); r += r_; return v * v - r * r < EPSILON; }; private: point_t p_; double r_; }; int n; std::vector<point_t> points; std::vector<double> rs; double normalize(double a) { while (a < 0) a += 2 * M_PI; while (a > 2 * M_PI) a -= 2 * M_PI; return a; } double dfs(int i, double s, double e, int j) { if (j == n) return rs[i] * (e - s); if (i == j) { return dfs(i, s, e, j + 1); } else if (circle_circle_intersect(points[i], rs[i])(points[j], rs[j])) { vector_t v1(points[i]), v2(points[j]); double r1(rs [i]), r2(rs [j]); double a = -(v1.x - v2.x) / (v1.y - v2.y); double b = (v2 * v2 - v1 * v1 + r1 * r1 - r2 * r2) / 2 / (- v1.y + v2.y); double A = a * a + 1; double B = a * (b - v1.y) - v1.x; double C = b * (b - 2 * v1.y) + v1 * v1 - r1 * r1; double D = sqrt(B * B - A * C); point_t p1((- B + D) / A, a * (- B + D) / A + b); point_t p2((- B - D) / A, a * (- B - D) / A + b); double ss = normalize(atan2(p1.y - v1.y, p1.x - v1.x)); double ee = normalize(atan2(p2.y - v1.y, p2.x - v1.x)); if (ss > ee) std::swap(ss, ee); double m = (ss + ee) / 2; if (point_circle_intersect(v2, r2)(matrix_t::translation(v1.x, v1.y) * matrix_t::scale(r1) * matrix_t::rotation(m) * vector_t(1))) { ; } else { std::swap(ss, ee); ss = normalize(ss); ee = normalize(ee); } if (ss < ee) { if (ss <= s && e <= ee) { return 0; } else if (ee <= s || e <= ss) { return dfs(i, s, e, j + 1); } else if (s <= ss && ee <= e) { return dfs(i, s, ss, j + 1) + dfs(i, ee, e, j + 1); } else if (ss <= e) { return dfs(i, ss, e, j + 1); } else if (ee <= e) { return dfs(i, s, ee, j + 1); } assert(false); } else { return dfs(i, std::max(s, ee), std::min(e, ss), j + 1); } } else { return dfs(i, s, e, j + 1); } } int main(int argc, char** argv) { while (1) { std::cin >> n; if (n == 0) break; points.resize(n); rs .resize(n); for (int i = 0; i < n; i ++) std::cin >> points[i].x >> points[i].y >> rs[i]; double a = 0; for (int i = 0; i < n; i ++) a += dfs(i, 0, 2 * M_PI, 0); std::cout << std::setprecision(14) << a << std::endl; } return 0; }
a.cc: In member function 'void matrix_t::identitize()': a.cc:137:5: error: 'memset' was not declared in this scope 137 | memset(matrix_, 0, sizeof(matrix_)); | ^~~~~~ a.cc:8:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 7 | #include <vector> +++ |+#include <cstring> 8 | a.cc: At global scope: a.cc:221:44: warning: 'template<class _Arg, class _Result> struct std::unary_function' is deprecated [-Wdeprecated-declarations] 221 | class point_circle_intersect : public std::unary_function<point_t, bool> | ^~~~~~~~~~~~~~ In file included from /usr/include/c++/14/string:49, 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/iomanip:42, from a.cc:5: /usr/include/c++/14/bits/stl_function.h:117:12: note: declared here 117 | struct unary_function | ^~~~~~~~~~~~~~
s376117584
p00634
C++
#include <stdio.h> #include <iostream> #include <vector> #include <list> #include <cmath> #include <fstream> #include <algorithm> #include <string> #include <queue> #include <set> #include <map> #include <complex> #include <iterator> #include <cstdlib> #include <sstream> #include <climits> using namespace std; #define EPS (1e-10) #define EQ(a,b) (abs((a) - (b)) < EPS) #define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag())) typedef long long ll; const int MAX_SIZE = 10000; struct edge{ int to; int cost; }; class Situation{ public: int sumCost; int sit; int sumDist; int node; Situation(int sumCost_,int node_,int sit_,int sumDist_){ sumCost=sumCost_; node=node_; sit=sit_; sumDist=sumDist_; } Situation(); // Å¬”ï—p‡”ԂɃ\[ƒg bool operator<(const Situation &s)const{ return s.sumCost < this->sumCost; } }; //typedef pair<int,int> P; int V; const int MAX_V = 11; vector<edge> G[MAX_V]; int d[MAX_V][1<<15]; int minDist[MAX_V][1<<15]; const int INF = 1000000000; int n;int idx; int q; string obj[20]; map<string,int> sellInfo[20]; map<string,int> dict; void dijkstra2(int s){ priority_queue<Situation> que; for(int i = 0; i < MAX_V; i++){ fill(d[i],d[i]+(1<<15),INF); fill(minDist[i],minDist[i]+(1<<15),INF); } d[s][(1<<q)-1] = 0; minDist[s][(1<<q)-1]=0; que.push(Situation(0,s,(1<<q)-1,0)); while(!que.empty()){ Situation p = que.top(); que.pop(); int v = p.node; int sit=p.sit; if(v==1&&sit==1){ // cout<<endl; } if(d[v][sit] < p.sumCost) continue; // ‚Ü‚¾Ž‚Á‚Ä‚¢‚È‚¢¤•i‚ðŽæ‚è‚ɍs‚­ for(map<string,int>::iterator it=sellInfo[v].begin();it!=sellInfo[v].end();it++){ string name=it->first; int value=it->second; // ŠÖŒW‚È‚¢¤•i if(dict.find(name)==dict.end()) continue; // id‚ðŠm•Û int id=dict[name]; // ƒrƒbƒg‚ª‚Ü‚¾—§‚Á‚Ä‚¢‚é‚È‚ç‚΁A—§‚ĂăLƒ…[‚ɒljÁ if((sit>>id)&1){ int nsit=sit; nsit&=~(1<<id); int ncost=p.sumCost+value; // Å¬ƒRƒXƒg‚ð’ljÁ‚Å‚«‚é‚È‚ç‚Î if(d[v][nsit]>d[v][sit]+value){ // XV d[v][nsit]=d[v][sit]+value; que.push(Situation(ncost,v,nsit,p.sumDist)); minDist[v][nsit]=p.sumDist; } else if(d[v][nsit]==d[v][sit]+value){ if(minDist[v][nsit] > minDist[v][sit]){ minDist[v][nsit] = minDist[v][sit]; } } } } // Œ»Ý‚̏ꏊ‚©‚çˆÚ“®‚·‚é // ˆÚ“®‚̃RƒXƒg‚ªˆê’è’l‚ð’´‚¦‚È‚¯‚ê‚΁AˆÚ“®‰Â”\ for(int i = 0; i < G[v].size(); i++){ edge e = G[v][i]; // ‹àŠz‚ªXV‚Å‚«‚é‚È‚çXV if(d[e.to][sit]>d[v][sit]){ // XV d[e.to][sit]=d[v][sit]; minDist[e.to][sit]=p.sumDist+e.cost; que.push(Situation(p.sumCost,e.to,sit,minDist[e.to][sit])); } // ˆÚ“®æ‚̃RƒXƒg‚ª“¯‚¶ê‡ else if(d[e.to][sit]==d[v][sit]){ // Å¬ƒRƒXƒg‚ðXV‚Å‚«‚é‚È‚çAˆÚ“® if(minDist[e.to][sit] > minDist[v][sit] + e.cost){ minDist[e.to][sit] = minDist[v][sit] + e.cost; que.push(Situation(p.sumCost,e.to,sit,minDist[e.to][sit])); } } // // Å¬ƒRƒXƒg‚ðXV‚Å‚«‚é‚È‚çAˆÚ“® // if(minDist[e.to][sit] > minDist[v][sit] + e.cost){ // minDist[e.to][sit] = minDist[v][sit] + e.cost; // que.push(Situation(p.sumCost,e.to,sit,minDist[e.to][sit])); //} } } } int main(){ while(cin>>n&&n!=0){ idx=0; dict.clear(); for(int i = 0; i <= n; i++){ G[i].clear(); sellInfo[i].clear(); } for(int i = 0; i < 20; i++) obj[i].clear(); for(int i = 0; i < n; i++){ int k; cin>>k; for(int j = 0; j < k; j++){ string name; int value; cin>>name>>value; sellInfo[i+1][name]=value; } } cin>>q; for(int i = 0; i < q; i++){ string name; cin>>name; obj[i]=name; dict[name]=i; } int m; cin>>m; V=n; for(int i = 0; i < m; i++){ int s,t,d; cin>>s>>t>>d; edge e; e.to=t;e.cost=d; G[s].push_back(e); e.to=s; G[t].push_back(e); } // dijkstra‚Å‘S•”W‚ß‚é‚̂ɍŏ¬‚ȃRƒXƒg‚ðŽ‚ÂW‚ß•û‚Ì‚¤‚¿Å’ZŒo˜H‚Ì‚à‚Ì‚ðŠ„‚èo‚· // ÅŒã‚ɉƂɖ߂é‚܂ł̍ŒZŒo˜H‚ð•ʂɌvŽZ‚µ‚Ä‚¨‚¢‚āA‚»‚ê‚ð‘«‚µ‚ďo—Í dijkstra2(0); int minv=d[0][0]; int mind=minDist[0][0]; if(minv==INF) cout<<"impossible"<<endl; else cout<<minv<<" "<<mind<<endl; } return 0; }
a.cc: In function 'void dijkstra2(int)': a.cc:118:39: error: 'i' was not declared in this scope 118 | edge e = G[v][i]; | ^ a.cc: At global scope: a.cc:141:1: error: expected declaration before '}' token 141 | } | ^
s492841407
p00634
C++
#include <stdio.h> #include <iostream> #include <vector> #include <list> #include <cmath> #include <fstream> #include <algorithm> #include <string> #include <queue> #include <set> #include <map> #include <complex> #include <iterator> #include <cstdlib> #include <sstream> #include <climits> using namespace std; #define EPS (1e-10) #define EQ(a,b) (abs((a) - (b)) < EPS) #define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag())) typedef long long ll; const int MAX_SIZE = 10000; struct edge{ int to; int cost; }; class Situation{ public: int sumCost; int sit; int sumDist; int node; Situation(int sumCost_,int node_,int sit_,int sumDist_){ sumCost=sumCost_; node=node_; sit=sit_; sumDist=sumDist_; } Situation(); // Å¬”ï—p‡”ԂɃ\[ƒg bool operator<(const Situation &s)const{ return s.sumCost < this->sumCost; } }; //typedef pair<int,int> P; int V; const int MAX_V = 15; vector<edge> G[MAX_V]; int d[MAX_V][1<<15]; int minDist[MAX_V][1<<15]; const int INF = 1000000000; int n;int idx; int q; string obj[20]; map<string,int> sellInfo[20]; map<string,int> dict; void dijkstra2(int s){ priority_queue<Situation> que; for(int i = 0; i < MAX_V; i++){ fill(d[i],d[i]+(1<<15),INF); fill(minDist[i],minDist[i]+(1<<15),INF); } d[s][(1<<q)-1] = 0; minDist[s][(1<<q)-1]=0; que.push(Situation(0,s,(1<<q)-1,0)); while(!que.empty()){ Situation p = que.top(); que.pop(); int v = p.node; int sit=p.sit; if(d[v][sit] < p.sumCost) continue; // ‚Ü‚¾Ž‚Á‚Ä‚¢‚È‚¢¤•i‚ðŽæ‚è‚ɍs‚­ for(map<string,int>::iterator it=sellInfo[v].begin();it!=sellInfo[v].end();it++){ string name=it->first; int value=it->second; // ŠÖŒW‚È‚¢¤•i if(dict.find(name)==dict.end()) continue; // id‚ðŠm•Û int id=dict[name]; // ƒrƒbƒg‚ª‚Ü‚¾—§‚Á‚Ä‚¢‚é‚È‚ç‚΁A—§‚ĂăLƒ…[‚ɒljÁ if((sit>>id)&1){ int nsit=sit; nsit&=~(1<<id); int ncost=p.sumCost+value; // Å¬ƒRƒXƒg‚ð’ljÁ‚Å‚«‚é‚È‚ç‚Î if(d[v][nsit]>d[v][sit]+value){ // XV d[v][nsit]=d[v][sit]+value; que.push(Situation(ncost,v,nsit,p.sumDist)); minDist[v][nsit]=p.sumDist; } else if(d[v][nsit]==d[v][sit]+value){ if(minDist[v][nsit] > minDist[v][sit]){ minDist[v][nsit] = minDist[v][sit]; } } } } // Œ»Ý‚̏ꏊ‚©‚çˆÚ“®‚·‚é // ˆÚ“®‚̃RƒXƒg‚ªˆê’è’l‚ð’´‚¦‚È‚¯‚ê‚΁AˆÚ“®‰Â”\ for(int i = 0; i < G[v].size(); i++){ edge e = G[v][i]; // ‹àŠz‚ªXV‚Å‚«‚é‚È‚çXV if(d[e.to][sit]>d[v][sit]){ // XV d[e.to][sit]=d[v][sit]; minDist[e.to][sit]=p.sumDist+e.cost; que.push(Situation(p.sumCost,e.to,sit,minDist[e.to][sit])); } // ˆÚ“®æ‚̃RƒXƒg‚ª“¯‚¶ê‡ else if(d[e.to][sit]==d[v][sit]){ // Å¬ƒRƒXƒg‚ðXV‚Å‚«‚é‚È‚çAˆÚ“® if(minDist[e.to][sit] > minDist[v][sit] + e.cost){ minDist[e.to][sit] = minDist[v][sit] + e.cost; que.push(Situation(p.sumCost,e.to,sit,minDist[e.to][sit])); } } } } } int main(){ while(cin>>n&&n!=0){ idx=0; dict.clear(); for(int i = 0; i <= n; i++){ G[i].clear(); sellInfo[i].clear(); } for(int i = 0; i < 20; i++) obj[i].clear(); for(int i = 0; i < n; i++){ int k; cin>>k; for(int j = 0; j < k; j++){ string name; int value; cin>>name>>value; sellInfo[i+1][name]=value; } } cin>>q; for(int i = 0; i < q; i++){ string name; cin>>name; obj[i]=name; dict[name]=i; } int m; cin>>m; V=n; for(int i = 0; i < m; i++){ int s,t,d; cin>>s>>t>>d; edge e; e.to=t;e.cost=d; G[s].push_back(e); e.to=s; G[t].push_back(e); } // dijkstra‚Å‘S•”W‚ß‚é‚̂ɍŏ¬‚ȃRƒXƒg‚ðŽ‚ÂW‚ß•û‚Ì‚¤‚¿Å’ZŒo˜H‚Ì‚à‚Ì‚ðŠ„‚èo‚· // ÅŒã‚ɉƂɖ߂é‚܂ł̍ŒZŒo˜H‚ð•ʂɌvŽZ‚µ‚Ä‚¨‚¢‚āA‚»‚ê‚ð‘«‚µ‚ďo—Í dijkstra2(0); int minv=d[0][0]; int mind=minDist[0][0]; if(minv==INF) cout<<"impossible"<<endl; else cout<<minv<<" "<<mind<<endl; } return 0; }
a.cc: In function 'void dijkstra2(int)': a.cc:115:39: error: 'i' was not declared in this scope 115 | edge e = G[v][i]; | ^ a.cc: At global scope: a.cc:133:1: error: expected declaration before '}' token 133 | } | ^
s640940238
p00634
C++
#include <stdio.h> #include <iostream> #include <vector> #include <list> #include <cmath> #include <fstream> #include <algorithm> #include <string> #include <queue> #include <set> #include <map> #include <complex> #include <iterator> #include <cstdlib> #include <sstream> #include <climits> using namespace std; #define EPS (1e-10) #define EQ(a,b) (abs((a) - (b)) < EPS) #define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag())) typedef long long ll; const int MAX_SIZE = 10000; struct edge{ int to; int cost; }; class Situation{ public: int sumCost; int sit; int sumDist; int node; Situation(int sumCost_,int node_,int sit_,int sumDist_){ sumCost=sumCost_; node=node_; sit=sit_; sumDist=sumDist_; } Situation(); // Å¬”ï—p‡”ԂɃ\[ƒg bool operator<(const Situation &s)const{ return s.sumCost < this->sumCost; } }; //typedef pair<int,int> P; int V; const int MAX_V = 15; vector<edge> G[MAX_V]; int d[MAX_V][1<<15]; int minDist[MAX_V][1<<15]; const int INF = 1000000000; int n;int idx; int q; string obj[20]; map<string,int> sellInfo[20]; map<string,int> dict; void dijkstra2(int s){ priority_queue<Situation> que; for(int i = 0; i < MAX_V; i++){ fill(d[i],d[i]+(1<<15),INF); fill(minDist[i],minDist[i]+(1<<15),INF); } d[s][(1<<q)-1] = 0; minDist[s][(1<<q)-1]=0; que.push(Situation(0,s,(1<<q)-1,0)); while(!que.empty()){ Situation p = que.top(); que.pop(); int v = p.node; int sit=p.sit; if(d[v][sit] < p.sumCost) continue; // ‚Ü‚¾Ž‚Á‚Ä‚¢‚È‚¢¤•i‚ðŽæ‚è‚ɍs‚­ for(map<string,int>::iterator it=sellInfo[v].begin();it!=sellInfo[v].end();it++){ string name=it->first; int value=it->second; // ŠÖŒW‚È‚¢¤•i if(dict.find(name)==dict.end()) continue; // id‚ðŠm•Û int id=dict[name]; // ƒrƒbƒg‚ª‚Ü‚¾—§‚Á‚Ä‚¢‚é‚È‚ç‚΁A—§‚ĂăLƒ…[‚ɒljÁ if((sit>>id)&1){ int nsit=sit; nsit&=~(1<<id); int ncost=p.sumCost+value; // Å¬ƒRƒXƒg‚ð’ljÁ‚Å‚«‚é‚È‚ç‚Î if(d[v][nsit]>d[v][sit]+value){ // XV d[v][nsit]=d[v][sit]+value; que.push(Situation(ncost,v,nsit,p.sumDist)); minDist[v][nsit]=p.sumDist; } else if(d[v][nsit]==d[v][sit]+value){ if(minDist[v][nsit] > minDist[v][sit]){ minDist[v][nsit] = minDist[v][sit]; } } } } // Œ»Ý‚̏ꏊ‚©‚çˆÚ“®‚·‚é // ˆÚ“®‚̃RƒXƒg‚ªˆê’è’l‚ð’´‚¦‚È‚¯‚ê‚΁AˆÚ“®‰Â”\ for(int i = 0; i < G[v].size(); i++){ edge e = G[v][i]; // ‹àŠz‚ªXV‚Å‚«‚é‚È‚çXV if(d[e.to][sit]>d[v][sit]){ // XV d[e.to][sit]=d[v][sit]; minDist[e.to][sit]=p.sumDist+e.cost; que.push(Situation(p.sumCost,e.to,sit,minDist[e.to][sit])); } // ˆÚ“®æ‚̃RƒXƒg‚ª“¯‚¶ê‡ else if(d[e.to][sit]==d[v][sit]){ // Å¬ƒRƒXƒg‚ðXV‚Å‚«‚é‚È‚çAˆÚ“® if(minDist[e.to][sit] > minDist[v][sit] + e.cost){ minDist[e.to][sit] = minDist[v][sit] + e.cost; que.push(Situation(p.sumCost,e.to,sit,minDist[e.to][sit])); } } } } } int main(){ while(cin>>n&&n!=0){ idx=0; dict.clear(); for(int i = 0; i <= n; i++){ G[i].clear(); sellInfo[i].clear(); } for(int i = 0; i < 20; i++) obj[i].clear(); for(int i = 0; i < n; i++){ int k; cin>>k; for(int j = 0; j < k; j++){ string name; int value; cin>>name>>value; sellInfo[i+1][name]=value; } } cin>>q; for(int i = 0; i < q; i++){ string name; cin>>name; obj[i]=name; dict[name]=i; } int m; cin>>m; V=n; for(int i = 0; i < m; i++){ int s,t,d; cin>>s>>t>>d; edge e; e.to=t;e.cost=d; G[s].push_back(e); e.to=s; G[t].push_back(e); } dijkstra2(0); int minv=d[0][0]; int mind=minDist[0][0]; if(minv==INF) cout<<"impossible"<<endl; else cout<<minv<<" "<<mind<<endl; } return 0; }
a.cc: In function 'void dijkstra2(int)': a.cc:115:39: error: 'i' was not declared in this scope 115 | edge e = G[v][i]; | ^ a.cc: At global scope: a.cc:133:1: error: expected declaration before '}' token 133 | } | ^
s942458975
p00634
C++
#include <stdio.h> #include <iostream> #include <vector> #include <list> #include <cmath> #include <fstream> #include <algorithm> #include <string> #include <queue> #include <set> #include <map> #include <complex> #include <iterator> #include <cstdlib> #include <sstream> #include <climits> using namespace std; #define EPS (1e-10) #define EQ(a,b) (abs((a) - (b)) < EPS) #define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag())) typedef long long ll; const int MAX_SIZE = 10000; struct edge{ int to; int cost; }; class Situation{ public: int sumCost; int sit; int sumDist; int node; Situation(int sumCost_,int node_,int sit_,int sumDist_){ sumCost=sumCost_; node=node_; sit=sit_; sumDist=sumDist_; } Situation(); // Å¬”ï—p‡”ԂɃ\[ƒg bool operator<(const Situation &s)const{ return s.sumCost < this->sumCost; } }; //typedef pair<int,int> P; int V; const int MAX_V = 15; vector<edge> G[MAX_V]; int d[MAX_V][1<<15]; int minDist[MAX_V][1<<15]; const int INF = 1000000000; int n;int idx; int q; string obj[20]; map<string,int> sellInfo[20]; map<string,int> dict; void dijkstra2(int s){ priority_queue<Situation> que; for(int i = 0; i < MAX_V; i++){ fill(d[i],d[i]+(1<<15),INF); fill(minDist[i],minDist[i]+(1<<15),INF); } d[s][(1<<q)-1] = 0; minDist[s][(1<<q)-1]=0; que.push(Situation(0,s,(1<<q)-1,0)); while(!que.empty()){ Situation p = que.top(); que.pop(); int v = p.node; int sit=p.sit; if(d[v][sit] < p.sumCost) continue; // ‚Ü‚¾Ž‚Á‚Ä‚¢‚È‚¢¤•i‚ðŽæ‚è‚ɍs‚­ for(map<string,int>::iterator it=sellInfo[v].begin();it!=sellInfo[v].end();it++){ string name=it->first; int value=it->second; // ŠÖŒW‚È‚¢¤•i if(dict.find(name)==dict.end()) continue; // id‚ðŠm•Û int id=dict[name]; // ƒrƒbƒg‚ª‚Ü‚¾—§‚Á‚Ä‚¢‚é‚È‚ç‚΁A—§‚ĂăLƒ…[‚ɒljÁ if((sit>>id)&1){ int nsit=sit; nsit&=~(1<<id); int ncost=p.sumCost+value; // Å¬ƒRƒXƒg‚ð’ljÁ‚Å‚«‚é‚È‚ç‚Î if(d[v][nsit]>d[v][sit]+value){ // XV d[v][nsit]=d[v][sit]+value; que.push(Situation(ncost,v,nsit,p.sumDist)); minDist[v][nsit]=p.sumDist; } else if(d[v][nsit]==d[v][sit]+value){ if(minDist[v][nsit] > minDist[v][sit]){ minDist[v][nsit] = minDist[v][sit]; } } } } // // Œ»Ý‚̏ꏊ‚©‚çˆÚ“®‚·‚é // // ˆÚ“®‚̃RƒXƒg‚ªˆê’è’l‚ð’´‚¦‚È‚¯‚ê‚΁AˆÚ“®‰Â”\ // for(int i = 0; i < G[v].size(); i++){ // edge e = G[v][i]; // // ‹àŠz‚ªXV‚Å‚«‚é‚È‚çXV // if(d[e.to][sit]>d[v][sit]){ // // XV // d[e.to][sit]=d[v][sit]; // minDist[e.to][sit]=p.sumDist+e.cost; // que.push(Situation(p.sumCost,e.to,sit,minDist[e.to][sit])); // } // // ˆÚ“®æ‚̃RƒXƒg‚ª“¯‚¶ê‡ // else if(d[e.to][sit]==d[v][sit]){ // // Å¬ƒRƒXƒg‚ðXV‚Å‚«‚é‚È‚çAˆÚ“® // if(minDist[e.to][sit] > minDist[v][sit] + e.cost){ // minDist[e.to][sit] = minDist[v][sit] + e.cost; // que.push(Situation(p.sumCost,e.to,sit,minDist[e.to][sit])); // } // } // } //} } int main(){ while(cin>>n&&n!=0){ idx=0; dict.clear(); for(int i = 0; i <= n; i++){ G[i].clear(); sellInfo[i].clear(); } for(int i = 0; i < 20; i++) obj[i].clear(); for(int i = 0; i < n; i++){ int k; cin>>k; for(int j = 0; j < k; j++){ string name; int value; cin>>name>>value; sellInfo[i+1][name]=value; } } cin>>q; for(int i = 0; i < q; i++){ string name; cin>>name; obj[i]=name; dict[name]=i; } int m; cin>>m; V=n; for(int i = 0; i < m; i++){ int s,t,d; cin>>s>>t>>d; edge e; e.to=t;e.cost=d; G[s].push_back(e); e.to=s; G[t].push_back(e); } dijkstra2(0); int minv=d[0][0]; int mind=minDist[0][0]; if(minv==INF) cout<<"impossible"<<endl; else cout<<minv<<" "<<mind<<endl; } return 0; }
a.cc: In function 'void dijkstra2(int)': a.cc:135:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse] 135 | int main(){ | ^~ a.cc:135:9: note: remove parentheses to default-initialize a variable 135 | int main(){ | ^~ | -- a.cc:135:9: note: or replace parentheses with braces to value-initialize a variable a.cc:135:11: error: a function-definition is not allowed here before '{' token 135 | int main(){ | ^ a.cc:185:2: error: expected '}' at end of input 185 | } | ^ a.cc:68:22: note: to match this '{' 68 | void dijkstra2(int s){ | ^
s897109372
p00634
C++
#include <stdio.h> #include <iostream> #include <vector> #include <list> #include <cmath> #include <fstream> #include <algorithm> #include <string> #include <queue> #include <set> #include <map> #include <complex> #include <iterator> #include <cstdlib> #include <sstream> #include <climits> using namespace std; #define EPS (1e-10) #define EQ(a,b) (abs((a) - (b)) < EPS) #define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag())) typedef long long ll; const int MAX_SIZE = 10000; struct edge{ int to; int cost; }; class Situation{ public: int sumCost; int sit; int sumDist; int node; Situation(int sumCost_,int node_,int sit_,int sumDist_){ sumCost=sumCost_; node=node_; sit=sit_; sumDist=sumDist_; } Situation(); // Å¬”ï—p‡”ԂɃ\[ƒg bool operator<(const Situation &s)const{ return s.sumCost < this->sumCost; } }; //typedef pair<int,int> P; int V; const int MAX_V = 15; vector<edge> G[MAX_V]; int d[MAX_V][1<<15]; int minDist[MAX_V][1<<15]; const int INF = 1000000000; int n;int idx; int q; string obj[20]; map<string,int> sellInfo[20]; map<string,int> dict; void dijkstra2(int s){ priority_queue<Situation> que; for(int i = 0; i < MAX_V; i++){ fill(d[i],d[i]+(1<<15),INF); fill(minDist[i],minDist[i]+(1<<15),INF); } d[s][(1<<q)-1] = 0; minDist[s][(1<<q)-1]=0; que.push(Situation(0,s,(1<<q)-1,0)); while(!que.empty()){ Situation p = que.top(); que.pop(); int v = p.node; int sit=p.sit; if(d[v][sit] < p.sumCost) continue; // ‚Ü‚¾Ž‚Á‚Ä‚¢‚È‚¢¤•i‚ðŽæ‚è‚ɍs‚­ for(map<string,int>::iterator it=sellInfo[v].begin();it!=sellInfo[v].end();it++){ string name=it->first; int value=it->second; // ŠÖŒW‚È‚¢¤•i if(dict.find(name)==dict.end()) continue; // id‚ðŠm•Û int id=dict[name]; // ƒrƒbƒg‚ª‚Ü‚¾—§‚Á‚Ä‚¢‚é‚È‚ç‚΁A—§‚ĂăLƒ…[‚ɒljÁ if((sit>>id)&1){ int nsit=sit; nsit&=~(1<<id); int ncost=p.sumCost+value; // Å¬ƒRƒXƒg‚ð’ljÁ‚Å‚«‚é‚È‚ç‚Î if(d[v][nsit]>d[v][sit]+value){ // XV d[v][nsit]=d[v][sit]+value; que.push(Situation(ncost,v,nsit,p.sumDist)); minDist[v][nsit]=p.sumDist; } else if(d[v][nsit]==d[v][sit]+value){ if(minDist[v][nsit] > minDist[v][sit]){ minDist[v][nsit] = minDist[v][sit]; } } } } // Œ»Ý‚̏ꏊ‚©‚çˆÚ“®‚·‚é // ˆÚ“®‚̃RƒXƒg‚ªˆê’è’l‚ð’´‚¦‚È‚¯‚ê‚΁AˆÚ“®‰Â”\ for(int i = 0; i < G[v].size(); i++){ edge e = G[v][i]; // // ‹àŠz‚ªXV‚Å‚«‚é‚È‚çXV // if(d[e.to][sit]>d[v][sit]){ // // XV // d[e.to][sit]=d[v][sit]; // minDist[e.to][sit]=p.sumDist+e.cost; // que.push(Situation(p.sumCost,e.to,sit,minDist[e.to][sit])); // } // // ˆÚ“®æ‚̃RƒXƒg‚ª“¯‚¶ê‡ // else if(d[e.to][sit]==d[v][sit]){ // // Å¬ƒRƒXƒg‚ðXV‚Å‚«‚é‚È‚çAˆÚ“® // if(minDist[e.to][sit] > minDist[v][sit] + e.cost){ // minDist[e.to][sit] = minDist[v][sit] + e.cost; // que.push(Situation(p.sumCost,e.to,sit,minDist[e.to][sit])); // } // } } } } int main(){ while(cin>>n&&n!=0){ idx=0; dict.clear(); for(int i = 0; i <= n; i++){ G[i].clear(); sellInfo[i].clear(); } for(int i = 0; i < 20; i++) obj[i].clear(); for(int i = 0; i < n; i++){ int k; cin>>k; for(int j = 0; j < k; j++){ string name; int value; cin>>name>>value; sellInfo[i+1][name]=value; } } cin>>q; for(int i = 0; i < q; i++){ string name; cin>>name; obj[i]=name; dict[name]=i; } int m; cin>>m; V=n; for(int i = 0; i < m; i++){ int s,t,d; cin>>s>>t>>d; edge e; e.to=t;e.cost=d; G[s].push_back(e); e.to=s; G[t].push_back(e); } dijkstra2(0); int minv=d[0][0]; int mind=minDist[0][0]; if(minv==INF) cout<<"impossible"<<endl; else cout<<minv<<" "<<mind<<endl; } return 0; }
a.cc: In function 'void dijkstra2(int)': a.cc:115:27: error: 'i' was not declared in this scope 115 | edge e = G[v][i]; | ^ a.cc: At global scope: a.cc:133:1: error: expected declaration before '}' token 133 | } | ^
s322054271
p00634
C++
#include <stdio.h> #include <iostream> #include <vector> #include <list> #include <cmath> #include <fstream> #include <algorithm> #include <string> #include <queue> #include <set> #include <map> #include <complex> #include <iterator> #include <cstdlib> #include <sstream> #include <climits> using namespace std; #define EPS (1e-10) #define EQ(a,b) (abs((a) - (b)) < EPS) #define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag())) typedef long long ll; const int MAX_SIZE = 10000; struct edge{ int to; int cost; }; class Situation{ public: int sumCost; int sit; int sumDist; int node; Situation(int sumCost_,int node_,int sit_,int sumDist_){ sumCost=sumCost_; node=node_; sit=sit_; sumDist=sumDist_; } Situation(); // Å¬”ï—p‡”ԂɃ\[ƒg bool operator<(const Situation &s)const{ return s.sumCost < this->sumCost; } }; //typedef pair<int,int> P; int V; const int MAX_V = 15; vector<edge> G[MAX_V]; int d[MAX_V][1<<15]; int minDist[MAX_V][1<<15]; const int INF = 1000000000; int n;int idx; int q; string obj[20]; map<string,int> sellInfo[20]; map<string,int> dict; void dijkstra2(int s){ priority_queue<Situation> que; for(int i = 0; i < MAX_V; i++){ fill(d[i],d[i]+(1<<15),INF); fill(minDist[i],minDist[i]+(1<<15),INF); } d[s][(1<<q)-1] = 0; minDist[s][(1<<q)-1]=0; que.push(Situation(0,s,(1<<q)-1,0)); while(!que.empty()){ Situation p = que.top(); que.pop(); int v = p.node; int sit=p.sit; if(d[v][sit] < p.sumCost) continue; // ‚Ü‚¾Ž‚Á‚Ä‚¢‚È‚¢¤•i‚ðŽæ‚è‚ɍs‚­ for(map<string,int>::iterator it=sellInfo[v].begin();it!=sellInfo[v].end();it++){ string name=it->first; int value=it->second; // ŠÖŒW‚È‚¢¤•i if(dict.find(name)==dict.end()) continue; // id‚ðŠm•Û int id=dict[name]; // ƒrƒbƒg‚ª‚Ü‚¾—§‚Á‚Ä‚¢‚é‚È‚ç‚΁A—§‚ĂăLƒ…[‚ɒljÁ if((sit>>id)&1){ int nsit=sit; nsit&=~(1<<id); int ncost=p.sumCost+value; // Å¬ƒRƒXƒg‚ð’ljÁ‚Å‚«‚é‚È‚ç‚Î if(d[v][nsit]>d[v][sit]+value){ // XV d[v][nsit]=d[v][sit]+value; que.push(Situation(ncost,v,nsit,p.sumDist)); minDist[v][nsit]=p.sumDist; } else if(d[v][nsit]==d[v][sit]+value){ if(minDist[v][nsit] > minDist[v][sit]){ minDist[v][nsit] = minDist[v][sit]; } } } } // Œ»Ý‚̏ꏊ‚©‚çˆÚ“®‚·‚é // ˆÚ“®‚̃RƒXƒg‚ªˆê’è’l‚ð’´‚¦‚È‚¯‚ê‚΁AˆÚ“®‰Â”\ for(int j = 0; j < G[v].size(); j++){ //edge e = G[v][j]; // // ‹àŠz‚ªXV‚Å‚«‚é‚È‚çXV // if(d[e.to][sit]>d[v][sit]){ // // XV // d[e.to][sit]=d[v][sit]; // minDist[e.to][sit]=p.sumDist+e.cost; // que.push(Situation(p.sumCost,e.to,sit,minDist[e.to][sit])); // } // // ˆÚ“®æ‚̃RƒXƒg‚ª“¯‚¶ê‡ // else if(d[e.to][sit]==d[v][sit]){ // // Å¬ƒRƒXƒg‚ðXV‚Å‚«‚é‚È‚çAˆÚ“® // if(minDist[e.to][sit] > minDist[v][sit] + e.cost){ // minDist[e.to][sit] = minDist[v][sit] + e.cost; // que.push(Situation(p.sumCost,e.to,sit,minDist[e.to][sit])); // } // } } } } int main(){ while(cin>>n&&n!=0){ idx=0; dict.clear(); for(int i = 0; i <= n; i++){ G[i].clear(); sellInfo[i].clear(); } for(int i = 0; i < 20; i++) obj[i].clear(); for(int i = 0; i < n; i++){ int k; cin>>k; for(int j = 0; j < k; j++){ string name; int value; cin>>name>>value; sellInfo[i+1][name]=value; } } cin>>q; for(int i = 0; i < q; i++){ string name; cin>>name; obj[i]=name; dict[name]=i; } int m; cin>>m; V=n; for(int i = 0; i < m; i++){ int s,t,d; cin>>s>>t>>d; edge e; e.to=t;e.cost=d; G[s].push_back(e); e.to=s; G[t].push_back(e); } dijkstra2(0); int minv=d[0][0]; int mind=minDist[0][0]; if(minv==INF) cout<<"impossible"<<endl; else cout<<minv<<" "<<mind<<endl; } return 0; }
a.cc:133:1: error: expected declaration before '}' token 133 | } | ^
s934160624
p00634
C++
#include <stdio.h> #include <iostream> #include <vector> #include <list> #include <cmath> #include <fstream> #include <algorithm> #include <string> #include <queue> #include <set> #include <map> #include <complex> #include <iterator> #include <cstdlib> #include <sstream> #include <climits> using namespace std; #define EPS (1e-10) #define EQ(a,b) (abs((a) - (b)) < EPS) #define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag())) typedef long long ll; const int MAX_SIZE = 10000; struct edge{ int to; int cost; }; class Situation{ public: int sumCost; int sit; int sumDist; int node; Situation(int sumCost_,int node_,int sit_,int sumDist_){ sumCost=sumCost_; node=node_; sit=sit_; sumDist=sumDist_; } Situation(); // Å¬”ï—p‡”ԂɃ\[ƒg bool operator<(const Situation &s)const{ return s.sumCost < this->sumCost; } }; //typedef pair<int,int> P; int V; const int MAX_V = 15; vector<edge> G[MAX_V]; int d[MAX_V][1<<15]; int minDist[MAX_V][1<<15]; const int INF = 1000000000; int n;int idx; int q; string obj[20]; map<string,int> sellInfo[20]; map<string,int> dict; void dijkstra2(int s){ priority_queue<Situation> que; for(int i = 0; i < MAX_V; i++){ fill(d[i],d[i]+(1<<15),INF); fill(minDist[i],minDist[i]+(1<<15),INF); } d[s][(1<<q)-1] = 0; minDist[s][(1<<q)-1]=0; que.push(Situation(0,s,(1<<q)-1,0)); while(!que.empty()){ Situation p = que.top(); que.pop(); int v = p.node; int sit=p.sit; if(d[v][sit] < p.sumCost) continue; // ‚Ü‚¾Ž‚Á‚Ä‚¢‚È‚¢¤•i‚ðŽæ‚è‚ɍs‚­ for(map<string,int>::iterator it=sellInfo[v].begin();it!=sellInfo[v].end();it++){ string name=it->first; int value=it->second; // ŠÖŒW‚È‚¢¤•i if(dict.find(name)==dict.end()) continue; // id‚ðŠm•Û int id=dict[name]; // ƒrƒbƒg‚ª‚Ü‚¾—§‚Á‚Ä‚¢‚é‚È‚ç‚΁A—§‚ĂăLƒ…[‚ɒljÁ if((sit>>id)&1){ int nsit=sit; nsit&=~(1<<id); int ncost=p.sumCost+value; // Å¬ƒRƒXƒg‚ð’ljÁ‚Å‚«‚é‚È‚ç‚Î if(d[v][nsit]>d[v][sit]+value){ // XV d[v][nsit]=d[v][sit]+value; que.push(Situation(ncost,v,nsit,p.sumDist)); minDist[v][nsit]=p.sumDist; } else if(d[v][nsit]==d[v][sit]+value){ if(minDist[v][nsit] > minDist[v][sit]){ minDist[v][nsit] = minDist[v][sit]; } } } } // Œ»Ý‚̏ꏊ‚©‚çˆÚ“®‚·‚é // ˆÚ“®‚̃RƒXƒg‚ªˆê’è’l‚ð’´‚¦‚È‚¯‚ê‚΁AˆÚ“®‰Â”\ for(int j = 0; j < G[v].size(); j++){ } } } int main(){ while(cin>>n&&n!=0){ idx=0; dict.clear(); for(int i = 0; i <= n; i++){ G[i].clear(); sellInfo[i].clear(); } for(int i = 0; i < 20; i++) obj[i].clear(); for(int i = 0; i < n; i++){ int k; cin>>k; for(int j = 0; j < k; j++){ string name; int value; cin>>name>>value; sellInfo[i+1][name]=value; } } cin>>q; for(int i = 0; i < q; i++){ string name; cin>>name; obj[i]=name; dict[name]=i; } int m; cin>>m; V=n; for(int i = 0; i < m; i++){ int s,t,d; cin>>s>>t>>d; edge e; e.to=t;e.cost=d; G[s].push_back(e); e.to=s; G[t].push_back(e); } dijkstra2(0); int minv=d[0][0]; int mind=minDist[0][0]; if(minv==INF) cout<<"impossible"<<endl; else cout<<minv<<" "<<mind<<endl; } return 0; }
a.cc:117:1: error: expected declaration before '}' token 117 | } | ^
s341587411
p00634
C++
#include <iostream> #include <fstream> #include <sstream> #include <iomanip> #include <complex> #include <string> #include <vector> #include <list> #include <deque> #include <stack> #include <queue> #include <set> #include <map> #include <bitset> #include <functional> #include <utility> #include <algorithm> #include <numeric> #include <typeinfo> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <climits> #include <ctime> using namespace std; typedef pair<string,int> P; int n,q,m; vector<P> v[11]; vector<string> name; int root[11][11]; const int INF=100000000; int dpc[11][1<<11]; int dpd[11][1<<11]; int ac; int ad; void rec(int x,int bit,int c,int d){ if(dpc[x][bit]<c)return; if(dpc[x][bit]==c && dpd[x][bit]<d)return; if(bit==(1<<n)-1){ if(c<ac || (c==ac && d<ad)){ ac=c; ad=d; } } else{ for(int i=0;i<v[x].size;i++){ for(int j=0;j<name.size;j++){ if(name[j]==v[x][i].first && !(bit >> j & 1)){ int nbit |= 1<<j; int nc=c+v[x][i].second; if(dpc[x][nbit]>vc || (dpc[x][nbit]==nc && dpd[x][nbit]<d)){ dpc[x][nbit]=vc; dpd[x][nbit]=d; rec(x,nbit,vc,d); } } } } for(int i=0;i<=n;i++){ int nd=d+root[i][x]; if(dpc[x][bit]>c || (dpc[x][bit]==c && dpd[x][bit]<nd){ dpc[x][nbit]=c; dpd[x][nbit]=vd; rec(i,bit,c,nd); } } } } int main(void){ while(1){ ac=INF; ad=INF; for(int i=0;i<=10;i++){ for(int j=0;j<=10;j++){ root[i][j]=INF; } root[i][i]=0; } for(int i=0;i<11;i++){ v[i].clear(); } name.clear(); cin >> n; for(int i=1;i<=n;i++){ int k; cin >> k; for(int j=0;j<k;j++){ string str; int cost; cin >> str >> cost; v[i].push_back(P(str,cost)); } } cin >> q; for(int i=0;i<q;i++){ string str; cin >> str; name.push_back(str); } cin >> m; for(int i=0;i<m;i++){ int s,t,d; cin >> s >> t >> d; root[s][t]=min(d,root[s][t]); root[t][s]=min(d,root[t][s]); } for(int k=0;k<=n;k++){ for(int i=0;i<=n;i++){ for(int j=0;j<=n;j++){ root[i][j]=min(root[i][j],root[i][k]+root[k][j]); } } } for(int i=0;i<=n;i++){ for(int j=0;j<=(1<<n)-1;j++){ dp[i][j]=INF; } } rec(0,0,0,0); if(ac==INF)cout << "impossible" << endl; else cout << ac << " " << ad << endl; } return 0; }
a.cc: In function 'void rec(int, int, int, int)': a.cc:49:36: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<std::__cxx11::basic_string<char>, int>; _Alloc = std::allocator<std::pair<std::__cxx11::basic_string<char>, int> >; size_type = long unsigned int]' (did you forget the '()' ?) 49 | for(int i=0;i<v[x].size;i++){ | ~~~~~^~~~ | () a.cc:50:44: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; size_type = long unsigned int]' (did you forget the '()' ?) 50 | for(int j=0;j<name.size;j++){ | ~~~~~^~~~ | () a.cc:52:50: error: expected initializer before '|=' token 52 | int nbit |= 1<<j; | ^~ a.cc:54:51: error: 'nbit' was not declared in this scope; did you mean 'bit'? 54 | if(dpc[x][nbit]>vc || (dpc[x][nbit]==nc && dpd[x][nbit]<d)){ | ^~~~ | bit a.cc:54:57: error: 'vc' was not declared in this scope; did you mean 'nc'? 54 | if(dpc[x][nbit]>vc || (dpc[x][nbit]==nc && dpd[x][nbit]<d)){ | ^~ | nc a.cc:64:79: error: expected ')' before '{' token 64 | if(dpc[x][bit]>c || (dpc[x][bit]==c && dpd[x][bit]<nd){ | ~ ^ | ) a.cc:69:17: error: expected primary-expression before '}' token 69 | } | ^ a.cc: In function 'int main()': a.cc:121:33: error: 'dp' was not declared in this scope; did you mean 'dpd'? 121 | dp[i][j]=INF; | ^~ | dpd
s692692554
p00634
C++
#include <iostream> #include <fstream> #include <sstream> #include <iomanip> #include <complex> #include <string> #include <vector> #include <list> #include <deque> #include <stack> #include <queue> #include <set> #include <map> #include <bitset> #include <functional> #include <utility> #include <algorithm> #include <numeric> #include <typeinfo> #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <climits> #include <ctime> using namespace std; typedef pair<string,int> P; int n,q,m; vector<P> v[11]; vector<string> name; int root[11][11]; const int INF=100000000; int dpc[11][1<<11]; int dpd[11][1<<11]; int ac; int ad; void rec(int x,int bit,int c,int d){ if(dpc[x][bit]<c)return; if(dpc[x][bit]==c && dpd[x][bit]<d)return; if(bit==(1<<n)-1){ if(c<ac || (c==ac && d<ad)){ ac=c; ad=d; } } else{ for(int i=0;i<v[x].size;i++){ for(int j=0;j<name.size;j++){ if(name[j]==v[x][i].first && !(bit >> j & 1)){ int nbit |= 1<<j; int nc=c+v[x][i].second; if(dpc[x][nbit]>vc || (dpc[x][nbit]==nc && dpd[x][nbit]<d)){ dpc[x][nbit]=vc; dpd[x][nbit]=d; rec(x,nbit,vc,d); } } } } for(int i=0;i<=n;i++){ int nd=d+root[i][x]; if(dpc[x][bit]>c || (dpc[x][bit]==c && dpd[x][bit]<nd){ dpc[x][nbit]=c; dpd[x][nbit]=vd; rec(i,bit,c,nd); } } } } int main(void){ while(1){ ac=INF; ad=INF; for(int i=0;i<=10;i++){ for(int j=0;j<=10;j++){ root[i][j]=INF; } root[i][i]=0; } for(int i=0;i<11;i++){ v[i].clear(); } name.clear(); cin >> n; for(int i=1;i<=n;i++){ int k; cin >> k; for(int j=0;j<k;j++){ string str; int cost; cin >> str >> cost; v[i].push_back(P(str,cost)); } } cin >> q; for(int i=0;i<q;i++){ string str; cin >> str; name.push_back(str); } cin >> m; for(int i=0;i<m;i++){ int s,t,d; cin >> s >> t >> d; root[s][t]=min(d,root[s][t]); root[t][s]=min(d,root[t][s]); } for(int k=0;k<=n;k++){ for(int i=0;i<=n;i++){ for(int j=0;j<=n;j++){ root[i][j]=min(root[i][j],root[i][k]+root[k][j]); } } } for(int i=0;i<=n;i++){ for(int j=0;j<=(1<<n)-1;j++){ dp[i][j]=INF; } } rec(0,0,0,0); if(ac==INF)cout << "impossible" << endl; else cout << ac << " " << ad << endl; } return 0; }
a.cc: In function 'void rec(int, int, int, int)': a.cc:49:36: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::pair<std::__cxx11::basic_string<char>, int>; _Alloc = std::allocator<std::pair<std::__cxx11::basic_string<char>, int> >; size_type = long unsigned int]' (did you forget the '()' ?) 49 | for(int i=0;i<v[x].size;i++){ | ~~~~~^~~~ | () a.cc:50:44: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = std::__cxx11::basic_string<char>; _Alloc = std::allocator<std::__cxx11::basic_string<char> >; size_type = long unsigned int]' (did you forget the '()' ?) 50 | for(int j=0;j<name.size;j++){ | ~~~~~^~~~ | () a.cc:52:50: error: expected initializer before '|=' token 52 | int nbit |= 1<<j; | ^~ a.cc:54:51: error: 'nbit' was not declared in this scope; did you mean 'bit'? 54 | if(dpc[x][nbit]>vc || (dpc[x][nbit]==nc && dpd[x][nbit]<d)){ | ^~~~ | bit a.cc:54:57: error: 'vc' was not declared in this scope; did you mean 'nc'? 54 | if(dpc[x][nbit]>vc || (dpc[x][nbit]==nc && dpd[x][nbit]<d)){ | ^~ | nc a.cc:64:79: error: expected ')' before '{' token 64 | if(dpc[x][bit]>c || (dpc[x][bit]==c && dpd[x][bit]<nd){ | ~ ^ | ) a.cc:69:17: error: expected primary-expression before '}' token 69 | } | ^ a.cc: In function 'int main()': a.cc:121:33: error: 'dp' was not declared in this scope; did you mean 'dpd'? 121 | dp[i][j]=INF; | ^~ | dpd
s449674382
p00635
C++
#include <iostream> #include <algorithm> using namespace std; int main() { int n, ne[11], a[11][11], res, t; while(cin>>n && n){ res = INT_MAX; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ cin >> a[i][j]; } } for(int i = 0; i < n; i++){ for(int j = i+1; j < n; j++){ a[i][j] = a[j][i] = max(a[i][j], a[j][i]); } ne[i] = i; } do { t = 0; for(int i = 0; i < n-1 && t < res; i++){ t += a[ne[i]][ne[i+1]]; } res = min(res, t); } while(next_permutation(ne, ne+n)); cout << res << endl; } return 0; }
a.cc: In function 'int main()': a.cc:11:23: error: 'INT_MAX' was not declared in this scope 11 | res = INT_MAX; | ^~~~~~~ a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 2 | #include <algorithm> +++ |+#include <climits> 3 |
s711204720
p00635
C++
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; int main() { int n, ne[11], a[11][11], res, t; while(cin>>n && n){ res = INT_MAX; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ cin >> a[i][j]; } } for(int i = 0; i < n; i++){ for(int j = i+1; j < n; j++){ a[i][j] = a[j][i] = max(a[i][j], a[j][i]); } ne[i] = i; } do { t = 0; for(int i = 0; i < n-1 && t < res; i++){ t += a[ne[i]][ne[i+1]]; } res = min(res, t); } while(next_permutation(ne, ne+n)); cout << res << endl; } return 0; }
a.cc: In function 'int main()': a.cc:12:23: error: 'INT_MAX' was not declared in this scope 12 | res = INT_MAX; | ^~~~~~~ a.cc:4:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 3 | #include <algorithm> +++ |+#include <climits> 4 |
s551170205
p00635
C++
#include <iostream> #include <algorithm> using namespace std; int main() { int n, ne[11], a[11][11], res, t; while(cin>>n && n){ res = INT_MAX; for(int i = 0; i < n; i++){ for(int j = 0; j < n; j++){ cin >> a[i][j]; } ne[i] = i; } do { t = 0; for(int i = 0; i < n-1 && t < res; i++){ t += max(a[ne[i]][ne[i+1]], a[ne[i+1]][ne[i]]); } res = min(res, t); } while(next_permutation(ne, ne+n)); cout << res << endl; } return 0; }
a.cc: In function 'int main()': a.cc:11:23: error: 'INT_MAX' was not declared in this scope 11 | res = INT_MAX; | ^~~~~~~ a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 2 | #include <algorithm> +++ |+#include <climits> 3 |
s758695395
p00635
C++
#include <iostream> #include <sstream> #include <iomanip> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <climits> #include <cfloat> using namespace std; int dfs(vector<vector<int> >& a, bitset<10>& bs, vector<int>& pos, int& minX) { int n = a.size(); int m = bs.count(); int maxX = *(max_element(pos.begin(), pos.end())); if(n == m) return minX = min(minX, maxX); if(maxX + (n-m) >= minX) return INT_MAX; int ret = INT_MAX; for(int i=0; i<n; ++i){ if(bs[i]) continue; int tmp = 0; for(int j=0; j<n; ++j){ if(bs[j]) tmp = max(tmp, pos[j] + a[i][j]); } bs[i] = true; pos[i] = tmp; ret = min(ret, dfs(a, bs, pos, minX)); ois[i] = 0; bs[i] = false; } return ret; } int solve(vector<vector<int> >& a) { int n = a.size(); bitset<10> bs(0); vector<int> pos(n, 0); int minX = INT_MAX; return dfs(a, bs, pos, minX); } int main() { for(;;){ int n; cin >> n; if(n == 0) return 0; vector<vector<int> > a(n, vector<int>(n, 0)); for(int i=0; i<n; ++i){ for(int j=0; j<n; ++j){ int tmp; cin >> tmp; a[i][j] = a[j][i] = max(a[i][j], max(a[j][i], tmp)); } } cout << solve(a) << endl; } }
a.cc: In function 'int dfs(std::vector<std::vector<int> >&, std::bitset<10>&, std::vector<int>&, int&)': a.cc:41:9: error: 'ois' was not declared in this scope 41 | ois[i] = 0; | ^~~
s112006186
p00637
Java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int f = 0; int i = 0; for(;;){ int n = sc.nextInt(); if(n==0){ System.exit(0); }else{ int p[] = new int[n]; p[0]= sc.nextInt(); for(i=1;i<n;i++){ p[i] = sc.nextInt(); if((p[i-1]+1)==p[i]){ }else{ if(p[f]==p[i-1]){ System.out.print(p[i-1]+" "); f=i; }else{ System.out.print(p[z]+"-"+p[i-1]+" "); f=i; } } } if(a[f]==a[i-1]){ System.out.print(a[i-1]); }else{ System.out.print(a[z]+"-"+a[i-1]); } System.out.print("\n"); f=0; } } } }
Main.java:24: error: cannot find symbol System.out.print(p[z]+"-"+p[i-1]+" "); ^ symbol: variable z location: class Main Main.java:29: error: cannot find symbol if(a[f]==a[i-1]){ ^ symbol: variable a location: class Main Main.java:29: error: cannot find symbol if(a[f]==a[i-1]){ ^ symbol: variable a location: class Main Main.java:30: error: cannot find symbol System.out.print(a[i-1]); ^ symbol: variable a location: class Main Main.java:32: error: cannot find symbol System.out.print(a[z]+"-"+a[i-1]); ^ symbol: variable a location: class Main Main.java:32: error: cannot find symbol System.out.print(a[z]+"-"+a[i-1]); ^ symbol: variable z location: class Main Main.java:32: error: cannot find symbol System.out.print(a[z]+"-"+a[i-1]); ^ symbol: variable a location: class Main 7 errors
s338987307
p00637
Java
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int f = 0; int i = 0; for(;;){ int n = sc.nextInt(); if(n==0){ System.exit(0); }else{ int p[] = new int[n]; p[0]= sc.nextInt(); for(i=1;i<n;i++){ p[i] = sc.nextInt(); if((p[i-1]+1)==p[i]){ }else{ if(p[f]==p[i-1]){ System.out.print(p[i-1]+" "); f=i; }else{ System.out.print(p[f]+"-"+p[i-1]+" "); f=i; } } } if(a[f]==a[i-1]){ System.out.print(a[i-1]); }else{ System.out.print(a[f]+"-"+a[i-1]); } System.out.print("\n"); f=0; } } } }
Main.java:29: error: cannot find symbol if(a[f]==a[i-1]){ ^ symbol: variable a location: class Main Main.java:29: error: cannot find symbol if(a[f]==a[i-1]){ ^ symbol: variable a location: class Main Main.java:30: error: cannot find symbol System.out.print(a[i-1]); ^ symbol: variable a location: class Main Main.java:32: error: cannot find symbol System.out.print(a[f]+"-"+a[i-1]); ^ symbol: variable a location: class Main Main.java:32: error: cannot find symbol System.out.print(a[f]+"-"+a[i-1]); ^ symbol: variable a location: class Main 5 errors
s602916326
p00637
Java
import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc=new Scanner(System.in); int i,n; for(int k=0;k<10000000;k++){ n=sc.nextInt(); if(n==0){ break; } int p[] = new int[n]; for(i=0;i<n;i++){ p[i]=sc.nextInt(); } for(i=0;i<n;i++){ if(i==0){ if(n==1){ System.out.print(p[0]+"\n"); }else{ System.out.print(p[0]); } } }else if(i==n-1){ if(p[i]-1==p[i-1]){ System.out.print("-"+p[i]+"\n"); }else{ System.out.print(" "+p[i]+"\n"); } }else{ if(p[i]-1!=p[i-1]){ System.out.print(" "+p[i]); } if(p[i]-1==p[i-1]&&p[i]+1!=p[i+1]){ System.out.print("-"+p[i]); } } } } } }
Main.java:26: error: 'else' without 'if' }else if(i==n-1){ ^ Main.java:43: error: class, interface, enum, or record expected } ^ 2 errors
s867627920
p00637
C
#include <stdio.h> int main(void){ int n,t,a[100]; while(1){ scanf("%d",&n); if(n==0){ return 0; } for(t=0;t<n;t++){ scanf("%d",&a[t]); } if(n==1){ printf("%d\n",a[0]); } else{ printf("%d",a[0]); for(t=1;t<n-1;t++){ if((a[t-1]+1!=a[t])&&(a[t]+1==a[t+1])){ printf(" %d",a[t]); } if((a[t-1]+1!=a[t])&&(a[t]+1!=a[t+1])){ printf(" %d",a[t]); } if((a[t-1]+1==a[t])&&(a[t]+1!=a[t+1])){ printf("-%d",a[t]); } } if(a[n-2]+==a[n-1]){ printf("-%d\n",a[n-1]); } else{ printf(" %d\n",a[n-1]); } } } }
main.c: In function 'main': main.c:29:36: error: expected expression before '=' token 29 | if(a[n-2]+==a[n-1]){ | ^
s248756439
p00637
C
main(n,p,i,a[51]){for(;~scanf("%d",&n),n;){for(a[n]=p=i=0;i<n;i++)scanf("%d",a+i);for(i=1;i<=n;i++)if(a[i-1]-a[i]+1)printf(i-p-1?n-i?"%d-%d ":"%d-%d\n":n-i?"%d ":"%d\n",a[p],a[i-1]),p=i;}exit(0);}
main.c:1:13: error: expected ')' before '[' token 1 | main(n,p,i,a[51]){for(;~scanf("%d",&n),n;){for(a[n]=p=i=0;i<n;i++)scanf("%d",a+i);for(i=1;i<=n;i++)if(a[i-1]-a[i]+1)printf(i-p-1?n-i?"%d-%d ":"%d-%d\n":n-i?"%d ":"%d\n",a[p],a[i-1]),p=i;}exit(0);} | ^ | )
s296488539
p00637
C
#include<string.h> #include<stdio.h> int main(){ int up;//?????? bool b[10000][51]; int c=-1; int i2; int itizi; int i; int con;//?¶?????????? int saisyo[10000]; for(i=0;c==-1;i++){ scanf("%d",&up); if(up==0){c=i;break;} scanf("%d",&itizi); saisyo[i]=itizi; b[i][itizi]=true; for(i2=1;i2<up;i2++){ scanf("%d",&itizi); b[i][itizi]=true; } } for(i=0;i<c;i++){ con=-1; for(i2=1;i2<=50;i2++){ if(con==-1&&b[i][i2]==true){ con=i2; } else if(b[i][i2]==true){} else if(con!=-1&&b[i][i2]!=true){ if(con==saisyo[i])printf("%d-%d",con,i2-1); else printf(" %d-%d",con,i2-1); con=-1; } } printf("\n"); } return 0; }
main.c: In function 'main': main.c:6:1: error: unknown type name 'bool' 6 | bool b[10000][51]; | ^~~~ main.c:3:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 2 | #include<stdio.h> +++ |+#include <stdbool.h> 3 | main.c:18:29: error: 'true' undeclared (first use in this function) 18 | b[i][itizi]=true; | ^~~~ main.c:18:29: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:18:29: note: each undeclared identifier is reported only once for each function it appears in
s941924312
p00637
C
#include<stdio.h> int main(){ int up;//?????? bool b[100000][51]; int c=-1; int i2; int itizi; int i; int con;//?¶?????????? int saisyo[100000]; for(i=0;c==-1;i++){ scanf("%d",&up); if(up==0){c=i;break;} scanf("%d",&itizi); saisyo[i]=itizi; b[i][itizi]=true; for(i2=1;i2<up;i2++){ scanf("%d",&itizi); b[i][itizi]=true; } } for(i=0;i<c;i++){ con=-1; for(i2=1;i2<=50;i2++){ if(con==-1&&b[i][i2]==true){ con=i2; } else if(b[i][i2]==true){} else if(con!=-1&&b[i][i2]!=true){ if(con==saisyo[i])printf("%d-%d",con,i2-1); else printf(" %d-%d",con,i2-1); con=-1; } } printf("\n"); } return 0; }
main.c: In function 'main': main.c:5:1: error: unknown type name 'bool' 5 | bool b[100000][51]; | ^~~~ main.c:2:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 1 | #include<stdio.h> +++ |+#include <stdbool.h> 2 | main.c:17:29: error: 'true' undeclared (first use in this function) 17 | b[i][itizi]=true; | ^~~~ main.c:17:29: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:17:29: note: each undeclared identifier is reported only once for each function it appears in
s412242644
p00637
C
#include<stdio.h> int main(){ int up;//?????? bool b[1000000][51]; int c=-1; int i2; int itizi; int i; int con;//?¶?????????? int saisyo[1000000]; for(i=0;c==-1;i++){ scanf("%d",&up); if(up==0){c=i;break;} scanf("%d",&itizi); saisyo[i]=itizi; b[i][itizi]=true; for(i2=1;i2<up;i2++){ scanf("%d",&itizi); b[i][itizi]=true; } } for(i=0;i<c;i++){ con=-1; for(i2=1;i2<=50;i2++){ if(con==-1&&b[i][i2]==true){ con=i2; } else if(b[i][i2]==true){} else if(con!=-1&&b[i][i2]!=true){ if(con==saisyo[i])printf("%d-%d",con,i2-1); else printf(" %d-%d",con,i2-1); con=-1; } } printf("\n"); } return 0; }
main.c: In function 'main': main.c:5:1: error: unknown type name 'bool' 5 | bool b[1000000][51]; | ^~~~ main.c:2:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 1 | #include<stdio.h> +++ |+#include <stdbool.h> 2 | main.c:17:29: error: 'true' undeclared (first use in this function) 17 | b[i][itizi]=true; | ^~~~ main.c:17:29: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:17:29: note: each undeclared identifier is reported only once for each function it appears in
s184867032
p00637
C
#include<stdio.h> int main(){ int up;//?????? bool b[10000000][51]; int c=-1; int i2; int itizi; int i; int con;//?¶?????????? int saisyo[10000000]; for(i=0;c==-1;i++){ scanf("%d",&up); if(up==0){c=i;break;} scanf("%d",&itizi); saisyo[i]=itizi; b[i][itizi]=true; for(i2=1;i2<up;i2++){ scanf("%d",&itizi); b[i][itizi]=true; } } for(i=0;i<c;i++){ con=-1; for(i2=1;i2<=50;i2++){ if(con==-1&&b[i][i2]==true){ con=i2; } else if(b[i][i2]==true){} else if(con!=-1&&b[i][i2]!=true){ if(con==saisyo[i])printf("%d-%d",con,i2-1); else printf(" %d-%d",con,i2-1); con=-1; } } printf("\n"); } return 0; }
main.c: In function 'main': main.c:5:1: error: unknown type name 'bool' 5 | bool b[10000000][51]; | ^~~~ main.c:2:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 1 | #include<stdio.h> +++ |+#include <stdbool.h> 2 | main.c:17:29: error: 'true' undeclared (first use in this function) 17 | b[i][itizi]=true; | ^~~~ main.c:17:29: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:17:29: note: each undeclared identifier is reported only once for each function it appears in
s080101516
p00637
C
#include<stdio.h> int main(){ int up;//?????? bool b[100000][52]; int c=-1; int i2; int itizi; int i; int con;//?¶?????????? int saisyo[100000]; for(i=0;c==-1;i++){ scanf("%d",&up); if(up==0){c=i;break;} scanf("%d",&itizi); saisyo[i]=itizi; b[i][itizi]=true; for(i2=1;i2<up;i2++){ scanf("%d",&itizi); b[i][itizi]=true; } } for(i=0;i<c;i++){ con=-1; for(i2=1;i2<=50;i2++){ if(con==-1&&b[i][i2]==true){ con=i2; } else if(b[i][i2]==true){} else if(con!=-1&&b[i][i2]!=true){ if(con==saisyo[i])printf("%d-%d",con,i2-1); else printf(" %d-%d",con,i2-1); con=-1; } } printf("\n"); } return 0; }
main.c: In function 'main': main.c:5:1: error: unknown type name 'bool' 5 | bool b[100000][52]; | ^~~~ main.c:2:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 1 | #include<stdio.h> +++ |+#include <stdbool.h> 2 | main.c:17:29: error: 'true' undeclared (first use in this function) 17 | b[i][itizi]=true; | ^~~~ main.c:17:29: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:17:29: note: each undeclared identifier is reported only once for each function it appears in
s576768198
p00637
C
#include<stdio.h> int main(){ int up;//?????? bool b[10000][1000]; int c=-1; int i2; int itizi; int i; int con;//?¶?????????? int saisyo[10000]; for(i=0;c==-1;i++){ scanf("%d",&up); if(up==0){c=i;break;} scanf("%d",&itizi); saisyo[i]=itizi; b[i][itizi]=true; for(i2=1;i2<up;i2++){ scanf("%d",&itizi); b[i][itizi]=true; } } for(i=0;i<c;i++){ con=-1; for(i2=1;i2<=1000;i2++){ if(con==-1&&b[i][i2]==true){ con=i2; } else if(b[i][i2]==true){} else if(con!=-1&&b[i][i2]!=true){ if(con==saisyo[i]){ if(con==i2-1){printf("%d",con);} else {printf("%d-%d",con,i2-1);} } else { if(con==i2-1){printf(" %d",con);} else {printf(" %d-%d",con,i2-1);} } con=-1; } } printf("\n"); } return 0; }
main.c: In function 'main': main.c:5:1: error: unknown type name 'bool' 5 | bool b[10000][1000]; | ^~~~ main.c:2:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 1 | #include<stdio.h> +++ |+#include <stdbool.h> 2 | main.c:17:29: error: 'true' undeclared (first use in this function) 17 | b[i][itizi]=true; | ^~~~ main.c:17:29: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:17:29: note: each undeclared identifier is reported only once for each function it appears in
s782348628
p00637
C++
n,p,i,a[50]; main(){ while(~scanf("%d", &n),n) { for(i=0;i<n;i++)scanf("%d",&a[i]);p=0; for(i=1;i<n;i++){ if(a[i-1]+1!=a[i]) { if(i-p-1)printf("%d-%d ",a[p],a[i-1]); else printf("%d ",a[p]); p=i; } } if(n-p-1)printf("%d-%d\n",a[p],a[n-1]); else printf("%d\n",a[p]); } }
a.cc:1:1: error: 'n' does not name a type 1 | n,p,i,a[50]; | ^ a.cc:2:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 2 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:3:29: error: 'n' was not declared in this scope 3 | while(~scanf("%d", &n),n) { | ^ a.cc:3:16: error: 'scanf' was not declared in this scope 3 | while(~scanf("%d", &n),n) { | ^~~~~ a.cc:4:21: error: 'i' was not declared in this scope 4 | for(i=0;i<n;i++)scanf("%d",&a[i]);p=0; | ^ a.cc:4:45: error: 'a' was not declared in this scope 4 | for(i=0;i<n;i++)scanf("%d",&a[i]);p=0; | ^ a.cc:4:51: error: 'p' was not declared in this scope 4 | for(i=0;i<n;i++)scanf("%d",&a[i]);p=0; | ^ a.cc:5:21: error: 'i' was not declared in this scope 5 | for(i=1;i<n;i++){ | ^ a.cc:6:28: error: 'a' was not declared in this scope 6 | if(a[i-1]+1!=a[i]) { | ^ a.cc:7:42: error: 'printf' was not declared in this scope 7 | if(i-p-1)printf("%d-%d ",a[p],a[i-1]); | ^~~~~~ a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' +++ |+#include <cstdio> 1 | n,p,i,a[50]; a.cc:8:38: error: 'printf' was not declared in this scope 8 | else printf("%d ",a[p]); | ^~~~~~ a.cc:8:38: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' a.cc:12:43: error: 'a' was not declared in this scope 12 | if(n-p-1)printf("%d-%d\n",a[p],a[n-1]); | ^ a.cc:12:26: error: 'printf' was not declared in this scope 12 | if(n-p-1)printf("%d-%d\n",a[p],a[n-1]); | ^~~~~~ a.cc:12:26: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' a.cc:13:36: error: 'a' was not declared in this scope 13 | else printf("%d\n",a[p]); | ^ a.cc:13:22: error: 'printf' was not declared in this scope 13 | else printf("%d\n",a[p]); | ^~~~~~ a.cc:13:22: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
s903194674
p00637
C++
50#include <bits/stdc++.h> using namespace std ; #define pb(n) push_back(n) #define fi first #define se second #define X real() #define Y imag() #define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h) #define all(r) (r).begin(),(r).end() #define gsort(st,en) sort((st),(en),greater<int>()) #define vmax(ary) *max_element(all(ary)) #define vmin(ary) *min_element(all(ary)) #define debug(x) cout<<#x<<": "<<x<<endl #define fcout(n) cout<<fixed<<setprecision((n)) #define scout(n) cout<<setw(n) #define vary(type,name,size,init) vector< type> name(size,init) #define rep(i,n) for(int i = 0; i < (int)(n);++i) #define REP(i,a,b) for(int i = (a);i < (int)(b);++i) #define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it) #define repa(n,array) for(auto &n :(array)) using ll = long long; using vi = vector<int>; using vl = vector<ll>; using dict = map<string,int>; using comd = complex<double>; using pii = pair<int,int> ; constexpr int imax = ((1<<30)-1)*2+1 ; constexpr int inf = 100000000; constexpr double PI = acos(-1.0) ; double eps = 1e-10 ; const int dy[] = {-1,0,1,0}; const int dx[] = {0,-1,0,1}; double CalcDist(comd p1, comd p2){ return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0)); } template <typename T> void out(deque < T > d) { for(size_t i = 0; i < d.size(); i++) { debug(d[i]); } } template<typename T> T ston(string& str, T n){ istringstream sin(str) ; T num ; sin >> num ; return num ; } int main(){ cin.tie(0); ios::sync_with_stdio(false); int n; while(cin >> n){ if(n == 0) break; string ans = ""; int c; int a = 0,len = 0; rep(i,n){ cin >> c; if(a == 0){ ans += to_string(c); a = c ; ++len; } else{ if(c - 1 == a){ if(i == n-1){ if(a == c-1){ ans += '-'; ans += to_string(c); } } a = c ; ++len; } else{ if(len > 1){ ans += '-'; ans += to_string(a); } ans += ' '; ans += to_string(c); a = c ; len = 0; } } } cout << ans << endl; } return 0; }
a.cc:1:3: error: stray '#' in program 1 | 50#include <bits/stdc++.h> | ^ a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 50#include <bits/stdc++.h> | ^~ a.cc:25:12: error: 'vector' does not name a type 25 | using vi = vector<int>; | ^~~~~~ a.cc:26:12: error: 'vector' does not name a type 26 | using vl = vector<ll>; | ^~~~~~ a.cc:27:14: error: 'map' does not name a type 27 | using dict = map<string,int>; | ^~~ a.cc:28:14: error: 'complex' does not name a type 28 | using comd = complex<double>; | ^~~~~~~ a.cc:29:13: error: 'pair' does not name a type 29 | using pii = pair<int,int> ; | ^~~~ a.cc:33:23: error: 'acos' was not declared in this scope 33 | constexpr double PI = acos(-1.0) ; | ^~~~ a.cc:38:17: error: 'comd' was not declared in this scope 38 | double CalcDist(comd p1, comd p2){ | ^~~~ a.cc:38:26: error: 'comd' was not declared in this scope 38 | double CalcDist(comd p1, comd p2){ | ^~~~ a.cc:38:33: error: expression list treated as compound expression in initializer [-fpermissive] 38 | double CalcDist(comd p1, comd p2){ | ^ a.cc:43:6: error: variable or field 'out' declared void 43 | void out(deque < T > d) | ^~~ a.cc:43:10: error: 'deque' was not declared in this scope 43 | void out(deque < T > d) | ^~~~~ a.cc:43:20: error: expected primary-expression before '>' token 43 | void out(deque < T > d) | ^ a.cc:43:22: error: 'd' was not declared in this scope 43 | void out(deque < T > d) | ^ a.cc:52:8: error: 'string' was not declared in this scope 52 | T ston(string& str, T n){ | ^~~~~~ a.cc:52:16: error: 'str' was not declared in this scope; did you mean 'std'? 52 | T ston(string& str, T n){ | ^~~ | std a.cc:52:23: error: expected primary-expression before 'n' 52 | T ston(string& str, T n){ | ^ a.cc:52:25: error: expected ';' before '{' token 52 | T ston(string& str, T n){ | ^ | ; a.cc: In function 'int main()': a.cc:60:3: error: 'cin' was not declared in this scope 60 | cin.tie(0); | ^~~ a.cc:61:3: error: 'ios' has not been declared 61 | ios::sync_with_stdio(false); | ^~~ a.cc:65:5: error: 'string' was not declared in this scope 65 | string ans = ""; | ^~~~~~ a.cc:71:9: error: 'ans' was not declared in this scope 71 | ans += to_string(c); | ^~~ a.cc:71:16: error: 'to_string' was not declared in this scope 71 | ans += to_string(c); | ^~~~~~~~~ a.cc:79:15: error: 'ans' was not declared in this scope 79 | ans += '-'; | ^~~ a.cc:80:22: error: 'to_string' was not declared in this scope 80 | ans += to_string(c); | ^~~~~~~~~ a.cc:88:13: error: 'ans' was not declared in this scope 88 | ans += '-'; | ^~~ a.cc:89:20: error: 'to_string' was not declared in this scope 89 | ans += to_string(a); | ^~~~~~~~~ a.cc:91:11: error: 'ans' was not declared in this scope 91 | ans += ' '; | ^~~ a.cc:92:18: error: 'to_string' was not declared in this scope 92 | ans += to_string(c); | ^~~~~~~~~ a.cc:98:5: error: 'cout' was not declared in this scope; did you mean 'scout'? 98 | cout << ans << endl; | ^~~~ | scout a.cc:98:13: error: 'ans' was not declared in this scope 98 | cout << ans << endl; | ^~~ a.cc:98:20: error: 'endl' was not declared in this scope 98 | cout << ans << endl; | ^~~~
s545682985
p00637
C++
#include<iostream> #include<vector> using namespace std; int main(){ int n,a,p; while(cin>>n,n){ vector<int>v; for(int i=0;i<n;i++){ cin>>a; v.push_back(a); } sort(v.begin(),v.end()); p=v[0]; cout<<p<<"-"; for(int i=1;i<n-1;i++) if(v[i]-p>1) cout<<p<<" "<<v[i]<<"-"; else p++; cout<<v[n-1]<<endl; } }
a.cc: In function 'int main()': a.cc:12:9: error: 'sort' was not declared in this scope; did you mean 'short'? 12 | sort(v.begin(),v.end()); | ^~~~ | short
s778331572
p00637
C++
#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; //#define int long long #define DBG 1 #define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;} #define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;} #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--) #define each(it,c) for(auto it=(c).begin();it!=(c).end();it++) #define all(c) c.begin(),c.end() const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f; const int MOD = (int)(1e9 + 7); int N = 50; signed main() { int n; while (cin >> n, n) { vector<int>v(n); rep(i, 0, n)cin >> v[i]; vector<bool>vf(N, false); rep(i, 0, n)vf[v[i]] = true; bool f(false),first(true); dumpc(vf); rep(i, 0, N) { if (vf[i]) { if (f == false) { if (first)first = false; else cout << " "; cout << i << "-"; f = true; } } else { if (f == true) { cout << i - 1; f = false; } } } cout << endl; } return 0; }
a.cc: In function 'int main()': a.cc:8:50: error: cannot bind non-const lvalue reference of type 'std::_Bit_reference&' to an rvalue of type 'std::_Bit_iterator::reference' 8 | #define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;} | ^ a.cc:22:17: note: in expansion of macro 'dumpc' 22 | dumpc(vf); | ^~~~~
s186044681
p00637
C++
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);String r;for(int n,a,b,c;(n=s.nextInt())>0;System.out.println(r+a+(a<c?"-"+c:"")))for(r="",a=c=s.nextInt();n-->1;){b=s.nextInt();if(b-c>1){r+=a+(a<c?"-"+c:"")+" ";a=b;}c=b;}}}
a.cc:1:1: error: 'import' does not name a type 1 | import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);String r;for(int n,a,b,c;(n=s.nextInt())>0;System.out.println(r+a+(a<c?"-"+c:"")))for(r="",a=c=s.nextInt();n-->1;){b=s.nextInt();if(b-c>1){r+=a+(a<c?"-"+c:"")+" ";a=b;}c=b;}}} | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:1:37: error: expected ':' before 'static' 1 | import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);String r;for(int n,a,b,c;(n=s.nextInt())>0;System.out.println(r+a+(a<c?"-"+c:"")))for(r="",a=c=s.nextInt();n-->1;){b=s.nextInt();if(b-c>1){r+=a+(a<c?"-"+c:"")+" ";a=b;}c=b;}}} | ^~~~~~~ | : a.cc:1:55: error: 'String' has not been declared 1 | import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);String r;for(int n,a,b,c;(n=s.nextInt())>0;System.out.println(r+a+(a<c?"-"+c:"")))for(r="",a=c=s.nextInt();n-->1;){b=s.nextInt();if(b-c>1){r+=a+(a<c?"-"+c:"")+" ";a=b;}c=b;}}} | ^~~~~~ a.cc:1:63: error: expected ',' or '...' before 'z' 1 | import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);String r;for(int n,a,b,c;(n=s.nextInt())>0;System.out.println(r+a+(a<c?"-"+c:"")))for(r="",a=c=s.nextInt();n-->1;){b=s.nextInt();if(b-c>1){r+=a+(a<c?"-"+c:"")+" ";a=b;}c=b;}}} | ^ a.cc:1:274: error: expected ';' after class definition 1 | import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);String r;for(int n,a,b,c;(n=s.nextInt())>0;System.out.println(r+a+(a<c?"-"+c:"")))for(r="",a=c=s.nextInt();n-->1;){b=s.nextInt();if(b-c>1){r+=a+(a<c?"-"+c:"")+" ";a=b;}c=b;}}} | ^ | ; a.cc: In static member function 'static void Main::main(int*)': a.cc:1:66: error: 'Scanner' was not declared in this scope 1 | import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);String r;for(int n,a,b,c;(n=s.nextInt())>0;System.out.println(r+a+(a<c?"-"+c:"")))for(r="",a=c=s.nextInt();n-->1;){b=s.nextInt();if(b-c>1){r+=a+(a<c?"-"+c:"")+" ";a=b;}c=b;}}} | ^~~~~~~ a.cc:1:99: error: 'String' was not declared in this scope 1 | import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);String r;for(int n,a,b,c;(n=s.nextInt())>0;System.out.println(r+a+(a<c?"-"+c:"")))for(r="",a=c=s.nextInt();n-->1;){b=s.nextInt();if(b-c>1){r+=a+(a<c?"-"+c:"")+" ";a=b;}c=b;}}} | ^~~~~~ a.cc:1:127: error: 's' was not declared in this scope 1 | import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);String r;for(int n,a,b,c;(n=s.nextInt())>0;System.out.println(r+a+(a<c?"-"+c:"")))for(r="",a=c=s.nextInt();n-->1;){b=s.nextInt();if(b-c>1){r+=a+(a<c?"-"+c:"")+" ";a=b;}c=b;}}} | ^ a.cc:1:142: error: 'System' was not declared in this scope 1 | import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);String r;for(int n,a,b,c;(n=s.nextInt())>0;System.out.println(r+a+(a<c?"-"+c:"")))for(r="",a=c=s.nextInt();n-->1;){b=s.nextInt();if(b-c>1){r+=a+(a<c?"-"+c:"")+" ";a=b;}c=b;}}} | ^~~~~~ a.cc:1:161: error: 'r' was not declared in this scope 1 | import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);String r;for(int n,a,b,c;(n=s.nextInt())>0;System.out.println(r+a+(a<c?"-"+c:"")))for(r="",a=c=s.nextInt();n-->1;){b=s.nextInt();if(b-c>1){r+=a+(a<c?"-"+c:"")+" ";a=b;}c=b;}}} | ^ a.cc:1:257: error: invalid operands of types 'const char*' and 'const char [2]' to binary 'operator+' 1 | import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);String r;for(int n,a,b,c;(n=s.nextInt())>0;System.out.println(r+a+(a<c?"-"+c:"")))for(r="",a=c=s.nextInt();n-->1;){b=s.nextInt();if(b-c>1){r+=a+(a<c?"-"+c:"")+" ";a=b;}c=b;}}} | ~~~~~~~~~~~~~~~~^~~~ | | | | const char* const char [2]
s244717508
p00637
C++
g#include <iostream> using namespace std; const int INF = 1 << 28; int main() { int n; while (cin >> n, n != 0) { int page[n+1]; for (int i = 0; i < n; i++) cin >> page[i]; page[n] = INF; int from_idx = 0; for (int i = 1; i <= n; i++) { if (page[i] != page[i-1] + 1) { if (i-1 == from_idx) { cout << ' ' << page[i-1]; } else { cout << ' ' << page[from_idx] << '-' << page[i-1]; } from_idx = i; } } cout << endl; } return 0; }
a.cc:1:2: error: stray '#' in program 1 | g#include <iostream> | ^ a.cc:1:1: error: 'g' does not name a type 1 | g#include <iostream> | ^ a.cc: In function 'int main()': a.cc:9:12: error: 'cin' was not declared in this scope 9 | while (cin >> n, n != 0) { | ^~~ a.cc:17:41: error: 'cout' was not declared in this scope 17 | cout << ' ' << page[i-1]; | ^~~~ a.cc:19:41: error: 'cout' was not declared in this scope 19 | cout << ' ' << page[from_idx] << '-' << page[i-1]; | ^~~~ a.cc:24:17: error: 'cout' was not declared in this scope 24 | cout << endl; | ^~~~ a.cc:24:25: error: 'endl' was not declared in this scope 24 | cout << endl; | ^~~~
s302705833
p00638
Java
public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); a: while(true){ int N = sc.nextInt(); if(N==0)break; TreeMap<Integer, Integer> map = new TreeMap<>(); for(int i=0;i<N;i++){ int a = sc.nextInt(); int b = sc.nextInt(); if(map.get(b)!=null){ map.put(b,a+map.get(b)); }else{ map.put(b, a); } } int c=0; for (Entry<Integer, Integer> m : map.entrySet()) { c+=m.getValue(); if(c>m.getKey()){ System.out.println("No"); continue a; } } System.out.println("Yes"); } } }
Main.java:3: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:3: error: cannot find symbol Scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:7: error: cannot find symbol TreeMap<Integer, Integer> map = new TreeMap<>(); ^ symbol: class TreeMap location: class Main Main.java:7: error: cannot find symbol TreeMap<Integer, Integer> map = new TreeMap<>(); ^ symbol: class TreeMap location: class Main Main.java:18: error: cannot find symbol for (Entry<Integer, Integer> m : map.entrySet()) { ^ symbol: class Entry location: class Main 5 errors
s731230845
p00638
Java
import java.awt.Point; import java.util.*; public class Main { public static int [] t ={0,1,2,3,5,7,8,9}; public static void main(String[] args) throws java.io.IOException{ Scanner scan = new Scanner(System.in); while(true){ int n = scan.nextInt(); if(n==0)break; Point [] p =new Point[n]; for(int i=0;i<n;i++){ p[i] = new Point(scan.nextInt(),scan.nextInt()); } Arrays.sort(p,new DataComparator()); long sum=0; boolean flag = true; for(int i=0;i<n;i++){ if(sum+p[i].x<=p[i].y){ sum+=p[i].x; } else flag=false; } System.out.println(flag?"Yes":"No"); } } } class unlocked DataComparator implements java.util.Comparator{ public int compare(Object o1, Object o2) { Point p1 = (Point) o1; Point p2 = (Point) o2; return p1.y - p2.y; } }
Main.java:32: error: '{' expected class unlocked DataComparator implements java.util.Comparator{ ^ 1 error
s679475472
p00638
Java
import java.util.*; public class AOJ_1052{ class Island implements Comparable{ public int weight; public int limit; public Island(int weight, int limit){ this.weight = weight; this.limit = limit; } public int compareTo(Object other){ Island is = (Island)other; return this.limit - is.limit; } } void run(){ Scanner sc = new Scanner(System.in); while(true){ int n = sc.nextInt(); if(n == 0){ break; } Island[] islands = new Island[n]; for(int i = 0; i < n; i++){ islands[i] = new Island(sc.nextInt(), sc.nextInt()); } /* for(int i = 0; i < n; i++){ System.out.println(i + ": " + islands[i].weight + " " + islands[i].limit); } */ Arrays.sort(islands); boolean ans = true; int sum = 0; for(Island is: islands){ sum += is.weight; if(is.limit < sum){ ans = false; break; } } System.out.println(ans?"Yes":"No"); } } public static void main(String[] args){ new AOJ_1052().run(); } }
Main.java:3: error: class AOJ_1052 is public, should be declared in a file named AOJ_1052.java public class AOJ_1052{ ^ 1 error
s310294943
p00638
Java
import java.util.Scanner; public class AOJ1052 { void run() { Scanner sc = new Scanner(System.in); int n; while (true) { n = sc.nextInt(); if (n == 0) break; int total = 0; int max = 0; for (int i = 0; i < n; i++) { total += sc.nextInt(); max = Math.max(max, sc.nextInt()); } if (total <= max) System.out.println("Yes"); else System.out.println("No"); } } public static void main(String[] args) { new AOJ1052().run(); } }
Main.java:3: error: class AOJ1052 is public, should be declared in a file named AOJ1052.java public class AOJ1052 { ^ 1 error
s029810708
p00638
C
#include<vector> #include<list> #include<map> #include<set> #include<deque> #include<queue> #include<stack> #include<bitset> #include<algorithm> #include<functional> #include<numeric> #include<utility> #include<iostream> #include<sstream> #include<iomanip> #include<cstdio> #include<cmath> #include<cstdlib> #include<cctype> #include<string> #include<cstring> #include<cstdio> #include<cmath> #include<cstdlib> #include<ctime> #include<climits> #include<complex> #define sz(x) (int)((x).size()) #define rep(i,n) for (int i=0;i<n;i++) #define mp make_pair #define pb push_back #define all(x) x.begin(),x.end() #define clr(x) memset((x),0,sizeof(x)) using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; typedef vector<string> vs; typedef pair<int,int> pii; typedef vector<pii> vpi; pair<int,int>a[222]; int main() { int i,j,k,n; while (scanf("%d",&n)!=EOF,n) { int b=0; for (i=0;i<n;i++) { scanf("%d%d",&a[i].second,&a[i].first); } sort(a,a+n); for (i=0;i<n;i++) { b+=a[i].second; if (a[i].first<b)break; } puts(i==n?"Yes":"No"); } return 0; }
main.c:1:9: fatal error: vector: No such file or directory 1 | #include<vector> | ^~~~~~~~ compilation terminated.
s030537945
p00638
C++
#include <iostream> #include <cstdio> #include <algorithm> #include <vector> using namespace std; int main() { int n; int a, b; int i; int g = 0; vector<pair<int, int>> v; while (1) { scanf("%d", &n); if (n == 0) break; for (i = 0; i < n; i++) { scanf("%d%d", &a, &b); v.push_back(make_pair(b, a)); } sort(begin(v), end(v)); for (i = 0; i < n; i++) { g += v[i].second; if (g > v[i].first) break; } if (i == n) printf("Yse\n"); else printf("No\n"); } return (0); }
a.cc:4:2: error: extended character   is not valid in an identifier 4 | #include <vector> | ^ a.cc:4:2: error: invalid preprocessing directive #include\U00003000 4 | #include <vector> | ^~~~~~~~~ a.cc: In function 'int main()': a.cc:14:9: error: 'vector' was not declared in this scope 14 | vector<pair<int, int>> v; | ^~~~~~ a.cc:4:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>' 3 | #include <algorithm> +++ |+#include <vector> 4 | #include <vector> a.cc:14:29: error: expected primary-expression before '>' token 14 | vector<pair<int, int>> v; | ^~ a.cc:14:32: error: 'v' was not declared in this scope 14 | vector<pair<int, int>> v; | ^
s213660274
p00638
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ while(1){ int n; cin>>n; if(n==0)return; vector<pair <int,int>>v; for(int i=0;i<n;i++){ int a,b; cin>>a>>b; v.push_back(make_pair(b,a)); } sort(begin(v),end(v)); int w=0; for(int i=0;i<n;i++){ w+=v[i].second; if(w>v[i].first){ cout<<"No"<<endl; goto next; } } cout<<"Yes"<<endl; next:; } return 0; }
a.cc: In function 'int main()': a.cc:11:25: error: return-statement with no value, in function returning 'int' [-fpermissive] 11 | if(n==0)return; | ^~~~~~
s884266638
p00638
C++
#include <iostream> #include <utility> using namespace std; #define REP(i,n) for(int i=0; i<n; ++i) pair<int, int> p[25]; int main() { while (true) { int n; cin >> n; if (n == 0) break; REP(i, n) cin >> p[i].second >> p[i].first; sort(p, p + n); long long total = 0; REP(i, n) { total += p[i].second; if (total > p[i].first) { cout << "No" << endl; break; } if (i == n - 1) cout << "Yes" << endl; } } }
a.cc: In function 'int main()': a.cc:13:17: error: 'sort' was not declared in this scope; did you mean 'short'? 13 | sort(p, p + n); | ^~~~ | short
s280493326
p00638
C++
#include<bits/stdc++.h> #define rep(i,n) for(int i=0;i<(int)(n);i++) #define all(a) (a).begin(),(a),end() using namespace std; typedef long long ll; typedef pair<ll,ll> pll; int main(){ int n; while(cin >> n, n){ vector<pll> a(n); rep(i,n)cin >> a[i].second >> a[i].first; sort(all(a)); bool ans = true; ll sum = 0; rep(i,n){ sum += a[i].second; if(sum > a[i].first) ans = false; } cout << (ans?"Yes":"No") << endl; } }
a.cc: In function 'int main()': a.cc:3:35: error: no matching function for call to 'end()' 3 | #define all(a) (a).begin(),(a),end() | ~~~^~ a.cc:13:10: note: in expansion of macro 'all' 13 | sort(all(a)); | ^~~ In file included from /usr/include/c++/14/bits/algorithmfwd.h:39, from /usr/include/c++/14/bits/stl_algo.h:59, from /usr/include/c++/14/algorithm:61, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/initializer_list:99:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)' 99 | end(initializer_list<_Tp> __ils) noexcept | ^~~ /usr/include/c++/14/initializer_list:99:5: note: candidate expects 1 argument, 0 provided In file included from /usr/include/c++/14/string:53, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/range_access.h:74:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)' 74 | end(_Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:74:5: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/range_access.h:85:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)' 85 | end(const _Container& __cont) -> decltype(__cont.end()) | ^~~ /usr/include/c++/14/bits/range_access.h:85:5: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/bits/range_access.h:106:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])' 106 | end(_Tp (&__arr)[_Nm]) noexcept | ^~~ /usr/include/c++/14/bits/range_access.h:106:5: note: candidate expects 1 argument, 0 provided In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166: /usr/include/c++/14/valarray:1249:5: note: candidate: 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)' 1249 | end(valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/valarray:1249:5: note: candidate expects 1 argument, 0 provided /usr/include/c++/14/valarray:1265:5: note: candidate: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)' 1265 | end(const valarray<_Tp>& __va) noexcept | ^~~ /usr/include/c++/14/valarray:1265:5: note: candidate expects 1 argument, 0 provided
s335643737
p00638
C++
#include<iostream> #include<vector> using namespace std; int main(){ int n; while(cin>>n,n){ vector<pair<int,int> >vec; for(int i=0;i<n;i++){ int a,b; cin>>a>>b; vec.push_back(make_pair(b, a)); } sort(vec.begin(),vec.end()); int all=0; bool o=true; for(int i=0;i<vec.size();i++){ all+=vec[i].second; if(all>vec[i].first){ o=false; cout<<"No"<<endl; break; } } if(o)cout<<"Yes"<<endl; } }
a.cc: In function 'int main()': a.cc:14:9: error: 'sort' was not declared in this scope; did you mean 'short'? 14 | sort(vec.begin(),vec.end()); | ^~~~ | short
s607097509
p00638
C++
#include <iostream> #include <map> #include <stdio.h> using namespace std; int n;//?????? int b; int c; int po=0; int i; int i2; int d=-1; bool dame[100000]; map<int,int>name; int po; int main(){ for(i=0;i<100000;i++){ dame[i]=false; } for(i2=0;d==-1;i2++){ po=0; scanf("%d",&n); if(n==0){ d=i2; break; } for(i=0;i<n;i++){ scanf("%d %d",&b,&c); name.insert(map<int,int>::value_type(c,b)); } map<int,int>::iterator it=name.begin(); while(it!=name.end()&&dame[i2]!=true){ po+=(*it).second; if((*it).first<po){ dame[i2]=true; } ++it; } name.clear(); } for(i=0;i<d;i++){ if(dame[i]==true)cout<<"No\n"; else cout<<"Yes\n"; } return 0; }
a.cc:15:5: error: redefinition of 'int po' 15 | int po; | ^~ a.cc:9:5: note: 'int po' previously defined here 9 | int po=0; | ^~
s163786926
p00638
C++
#include<iostream> #include<string> #include<vector> #include<algorithm> #include<fstream> #define A '.' #define S 'S' #define G 'G' #define D '#' using namespace std; int N,T; void getInputs(vector< vector<int> > &maze){ cin >> N >> T; cin.ignore(); for(int i=0;i<N;i++){ int a,b; vector<int> row; cin >> a >> b; row.push_back(a); row.push_back(b); maze.push_back(row); } } int main(){ vector< vector<int> > cow; getInputs(cow); vector< pair<int,int> > pea(N); int ans = 0; int start = 1; int end = 1; for(int i=0;i<N;i++){ pea[i] = make_pair(cow[i][0],cow[i][1]); } sort(pea.begin(),pea.end()); for(int i=N-1;i>=0;i--){ cout << pea[i].second << "," << pea[i].first << endl; } end = T; start = T; for(int i=N-1;i>=0;i--){ if(pea[i].second >= end ){ end = pea[i].first; if(end == 1){ break; } } } //cout << "end=" << end << endl; if(end > 1){ cout << -1 << endl; return 0; } end = 1; for(int i=0;i<N;i++){ if(t >= pea[i].first){ if(t < pea[i].second){ t = pea[i].second; } } } for(int i = 0;i<N;i++){ if(start >= pea[i].first && end < pea[i].second){ ans ++; start = pea[i].first; end = pea[i].second; } } cout << ans << endl; return 0; }
a.cc: In function 'int main()': a.cc:80:12: error: 't' was not declared in this scope 80 | if(t >= pea[i].first){ | ^
s827839484
p00638
C++
#include <iostream> #include <vector> #include <string> #include <array> using namespace std; bool myComparison(const pair<int,int> &a,const pair<int,int> &b) { return a.second<b.second; } int main(){ int n=0; cin>>n; vector< pair<int,int > > v; for(int i=0;i<n;i++){ int t1,t2; cin>>t1>>t2; v.push_back(make_pair(t1,t2)); } sort(v.begin(),v.end(),myComparison); int flag=0; int load=0; for(int i=0;i<v.size();i++){ load+=v[i].first; if(load>v[i].second){ flag=1; break; } } if(flag==0){ cout<<"YES"<<endl; }else{ cout<<"NO"<<endl; } } //ワーシャルフロイド法
a.cc: In function 'int main()': a.cc:22:9: error: 'sort' was not declared in this scope; did you mean 'short'? 22 | sort(v.begin(),v.end(),myComparison); | ^~~~ | short
s081393594
p00638
C++
#include <iostream> #include <vector> #include <string> #include <array> using namespace std; bool myComparison(const pair<int,int> &a,const pair<int,int> &b) { return a.second<b.second; } int main(){ int n=0; cin>>n; vector< pair<int,int > > v; for(int i=0;i<n;i++){ int t1,t2; cin>>t1>>t2; v.push_back(make_pair(t1,t2)); } sort(v.begin(),v.end(),myComparison); int flag=0; int load=0; for(int i=0;i<v.size();i++){ load+=v[i].first; if(load>v[i].second){ flag=1; break; } } if(flag==0){ cout<<"YES"<<endl; }else{ cout<<"NO"<<endl; } } //ワーシャルフロイド法
a.cc: In function 'int main()': a.cc:22:9: error: 'sort' was not declared in this scope; did you mean 'short'? 22 | sort(v.begin(),v.end(),myComparison); | ^~~~ | short
s604256942
p00638
C++
#include <iostream> #include <vector> #include <string> #include <array> using namespace std; bool myComparison(const pair<int,int> &a,const pair<int,int> &b) { return a.second<b.second; } int main(){ int n=0; cin>>n; vector< pair<int,int > > v; for(int i=0;i<n;i++){ int t1,t2; cin>>t1>>t2; v.push_back(make_pair(t1,t2)); } sort(v.begin(),v.end(),myComparison); int flag=0; int load=0; for(int i=0;i<v.size();i++){ load+=v[i].first; if(load>v[i].second){ flag=1; break; } } if(flag==0){ cout<<"YES"<<endl; }else{ cout<<"NO"<<endl; } } //ワーシャルフロイド法
a.cc: In function 'int main()': a.cc:22:9: error: 'sort' was not declared in this scope; did you mean 'short'? 22 | sort(v.begin(),v.end(),myComparison); | ^~~~ | short
s449840650
p00638
C++
#include <iostream> #include <vector> #include <string> #include <array> using namespace std; bool myComparison(const pair<int,int> &a,const pair<int,int> &b) { return a.second<b.second; } int main(){ int n=0; cin>>n; vector< pair<int,int > > v; for(int i=0;i<n;i++){ int t1,t2; cin>>t1>>t2; v.push_back(make_pair(t1,t2)); } sort(v.begin(),v.end(),myComparison); int flag=0; int load=0; for(int i=0;i<v.size();i++){ load+=v[i].first; if(load>v[i].second){ flag=1; break; } } if(flag==0){ cout<<"YES"<<endl; }else{ cout<<"NO"<<endl; } } //ワーシャルフロイド法
a.cc: In function 'int main()': a.cc:22:9: error: 'sort' was not declared in this scope; did you mean 'short'? 22 | sort(v.begin(),v.end(),myComparison); | ^~~~ | short
s468346940
p00638
C++
#include <iostream> #include <vector> #include <string> using namespace std; bool myComparison(const pair<int,int> &a,const pair<int,int> &b) { return a.second<b.second; } int main(){ int n=0; cin>>n; vector< pair<int,int > > v; for(int i=0;i<n;i++){ int t1,t2; cin>>t1>>t2; v.push_back(make_pair(t1,t2)); } sort(v.begin(),v.end(),myComparison); int flag=0; int load=0; for(int i=0;i<v.size();i++){ load+=v[i].first; if(load>v[i].second){ flag=1; break; } } if(flag==0){ cout<<"YES"<<endl; }else{ cout<<"NO"<<endl; } } //ワーシャルフロイド法
a.cc: In function 'int main()': a.cc:21:9: error: 'sort' was not declared in this scope; did you mean 'short'? 21 | sort(v.begin(),v.end(),myComparison); | ^~~~ | short
s225047889
p00638
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n; while(cin>>n,n){ int tre; int total=0; int bridge; int max=0; for(int i=0;i<n;++i){ cin>>tre>>bridge; total+=tre; max=max(max,bridge); } if(total<=bridge) cout<<"Yes"<<endl; else cout<<"No"<<endl; } }
a.cc: In function 'int main()': a.cc:19:18: error: 'max' cannot be used as a function 19 | max=max(max,bridge); | ~~~^~~~~~~~~~~~
s514330638
p00638
C++
#include <iostream> #include <vector> #include <algorithm> using namespace std; struct islands { int t; int w; bool operator>(const islands &left) const { return w > left.w; } }; int main() { int n, i; vector<islands> island; while(1) { cin >> n; if(n == 0) break; for(i = 0; i < n; i++) { islands I; cin >> I.t >> I.w; island.push_back(I); } sort(island.begin(), island.end()); int sum = 0; int flag = 0; for(i = 0; i < n; i++) { sum += island[i].t; if(island[i].w < sum) { cout << "NO" << endl; flag = 1; break; } } if(flag != 1) cout << "YES" << endl; island.clear(); } return 0; }
In file included from /usr/include/c++/14/bits/stl_algobase.h:71, from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:1: /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'constexpr bool __gnu_cxx::__ops::_Iter_less_iter::operator()(_Iterator1, _Iterator2) const [with _Iterator1 = __gnu_cxx::__normal_iterator<islands*, std::vector<islands> >; _Iterator2 = __gnu_cxx::__normal_iterator<islands*, std::vector<islands> >]': /usr/include/c++/14/bits/stl_algo.h:1777:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<islands*, vector<islands> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1777 | if (__comp(__i, __first)) | ~~~~~~^~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<islands*, vector<islands> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<islands*, vector<islands> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4772:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<islands*, vector<islands> >]' 4772 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:30:9: required from here 30 | sort(island.begin(), island.end()); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:45:23: error: no match for 'operator<' (operand types are 'islands' and 'islands') 45 | { return *__it1 < *__it2; } | ~~~~~~~^~~~~~~~ In file included from /usr/include/c++/14/string:48: /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:45:23: note: 'islands' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 45 | { return *__it1 < *__it2; } | ~~~~~~~^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:45:23: note: 'islands' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 45 | { return *__it1 < *__it2; } | ~~~~~~~^~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_less_iter::operator()(_Value&, _Iterator) const [with _Value = islands; _Iterator = __gnu_cxx::__normal_iterator<islands*, std::vector<islands> >]': /usr/include/c++/14/bits/stl_algo.h:1757:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<islands*, vector<islands> >; _Compare = __gnu_cxx::__ops::_Val_less_iter]' 1757 | while (__comp(__val, __next)) | ~~~~~~^~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1785:36: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<islands*, vector<islands> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1785 | std::__unguarded_linear_insert(__i, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ 1786 | __gnu_cxx::__ops::__val_comp_iter(__comp)); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1817:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<islands*, vector<islands> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1817 | std::__insertion_sort(__first, __first + int(_S_threshold), __comp); | ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1908:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<islands*, vector<islands> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 1908 | std::__final_insertion_sort(__first, __last, __comp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:4772:18: required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = __gnu_cxx::__normal_iterator<islands*, vector<islands> >]' 4772 | std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter()); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:30:9: required from here 30 | sort(island.begin(), island.end()); | ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/predefined_ops.h:98:22: error: no match for 'operator<' (operand types are 'islands' and 'islands') 98 | { return __val < *__it; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: candidate: 'template<class _IteratorL, class _IteratorR, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_IteratorL, _Container>&, const __normal_iterator<_IteratorR, _Container>&)' 1241 | operator<(const __normal_iterator<_IteratorL, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1241:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:98:22: note: 'islands' is not derived from 'const __gnu_cxx::__normal_iterator<_IteratorL, _Container>' 98 | { return __val < *__it; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: candidate: 'template<class _Iterator, class _Container> bool __gnu_cxx::operator<(const __normal_iterator<_Iterator, _Container>&, const __normal_iterator<_Iterator, _Container>&)' 1249 | operator<(const __normal_iterator<_Iterator, _Container>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1249:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/predefined_ops.h:98:22: note: 'islands' is not derived from 'const __gnu_cxx::__normal_iterator<_Iterator, _Container>' 98 | { return __val < *__it; } | ~~~~~~^~~~~~~ /usr/include/c++/14/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_less_val::operator()(_Iterator, _Value&) const [with _Iterator = __gnu_cxx::__normal_iterator<islands*, std::vector<islands> >; _Value = islands]': /usr/include/c++/14/bits/stl_heap.h:140:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<islands*, vector<islands> >; _Distance = long int; _Tp = islands; _Compare = __gnu_cxx::__ops::_Iter_less_val]' 140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:247:23: required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<islands*, vector<islands> >; _Distance = long int; _Tp = islands; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 247 | std::__push_heap(__first, __holeIndex, __topIndex, | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 248 | _GLIBCXX_MOVE(__value), __cmp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:356:22: required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<islands*, vector<islands> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 356 | std::__adjust_heap(__first, __parent, __len, _GLIBCXX_MOVE(__value), | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 357 | __comp); | ~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1593:23: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<islands*, vector<islands> >; _Compare = __gnu_cxx::__ops::_Iter_less_iter]' 15
s382220210
p00638
C++
#include <iostream> #include <cmath> #include <string> #include <vector> #define P pair<int,int> #define rep(i,n) for(int i = 0;i<n;i++) #define pb(n) push_back(n) using namespace std; int n; int main() { while(true){ cin >> n; if(n == 0) break; vector<P> V; rep(i,n){ int d,w; cin >> w >> d; V.push_back(P(d,w)); } sort(V.begin(),V.end()); int sw = 0; bool ans = true; rep(i,n){ sw += V[i].second; if(sw > V[i].first){ ans = false; break; } } cout << (ans ? "Yes" : "No") << endl; } return 0; }
a.cc: In function 'int main()': a.cc:20:17: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 20 | sort(V.begin(),V.end()); | ^~~~ | sqrt