submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s840373859
p00618
C
int __builtin_popcount(int i,int n) { int j,res; res = 0; for(j = 0;j<n;j++) if((i >> j) & 1) res++; return res; }
main.c:1:5: warning: conflicting types for built-in function '__builtin_popcount'; expected 'int(unsigned int)' [-Wbuiltin-declaration-mismatch] 1 | int __builtin_popcount(int i,int n) | ^~~~~~~~~~~~~~~~~~ /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s926957518
p00618
C
#include<iostream> #include<cstdio> #include<vector> using namespace std; typedef vector<int> VI; typedef vector<VI> VVI; int ans,U; void dfs(VI& G,VI& c,int total,int cost,int b) { if(cost >= ans) return; int n = G.size(); for(int i=0;i<n;i++) { if((b>>i) & 1) continue; int pre = G[i]; pre &= b; if(pre == G[i]) { if(total+c[i] < U) dfs(G,c,total+c[i],cost+1,b|(1<<i)); else ans = min(ans,cost+1); } } } int main() { int n; while(cin >> n >> U,n|U) { vector<int> G; G.resize(n); vector<int> c; c.resize(n); for(int i=0;i<n;i++) { int k; cin >> c[i] >> k; G[i] = 0; for(int j=0;j<k;j++) { int r; cin >> r; G[i] |= (1<<r); } } ans = n; dfs(G,c,0,0,0); cout << ans << endl; } return 0; }
main.c:1:9: fatal error: iostream: No such file or directory 1 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s495641409
p00618
C
#include<cstdio> #include<iostream> #include<bitset> #include<deque> #include<algorithm> using namespace std; struct Pox { int state,cost; Pox(int state,int cost):state(state),cost(cost){} }; int main() { while(1) { int n,U,k,r; scanf("%d %d",&n,&U); if(n+U == 0) break; deque<Pox> deq; int G[n]; int c[n]; for(int i = 0;i<n;i++) { scanf("%d %d",&c[i],&k); G[i] = 0; if(!k) deq.push_back(Pox((1<<i),c[i])); for(int j=0;j<k;j++) { scanf("%d",&r); G[i] |= (1<<r); } } int ans = n; while(!deq.empty()) { Pox pox = deq.front(); deq.pop_front(); int num = __builtin_popcount(pox.state); if(num >= ans) continue; for(int i=0;i<n;i++) { if((pox.state >> i) & 1) continue; int pre = G[i]; pre &= pox.state; if(pre != G[i]) continue; if(pox.cost + c[i] < U) deq.push_back(Pox(pox.state|(1<<i),pox.cost+c[i])); else ans = min(ans,num+1); } } cout << ans << endl; } return 0; }
main.c:1:9: fatal error: cstdio: No such file or directory 1 | #include<cstdio> | ^~~~~~~~ compilation terminated.
s396872565
p00618
C++
#include<iostream> #include<algorithm> using namespace std; int popcount32(unsigned int x){ x = (x>>1 & 0x55555555)+(x & 0x55555555); x = (x>>2 & 0x33333333)+(x & 0x33333333); x = (x>>4 & 0x0f0f0f0f)+(x & 0x0f0f0f0f); x = (x>>8 & 0x00ff00ff)+(x & 0x00ff00ff); return (x>>16)+(x & 0x0000ffff); } int tanni[20]; int prelearn[20]; int main(){ int n,u; while(cin>>n>>u,n|u){ memset(tanni,0,sizeof(tanni)); memset(prelearn,0,sizeof(prelearn)); for(int i=0;i<n;i++){ int c,k; cin>>c>>k; tanni[i]=c; for(int j=0;j<k;j++){ int r; cin>>r; prelearn[i]|=1<<r; } } int ans=n; for(int i=0;i<(1<<n);i++){ int pop=popcount32(i); if(ans<pop)continue; bool valid=true; for(int j=0;j<n;j++){ if((i>>j&1)&&(prelearn[j]&i)!=prelearn[j]){ valid=false; break; } } if(!valid)continue; int s=0; for(int j=0;j<n;j++){ if(i>>j&1)s+=tanni[j]; } if(u<=s)ans=pop; } cout<<ans<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:20:17: error: 'memset' was not declared in this scope 20 | memset(tanni,0,sizeof(tanni)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<algorithm> +++ |+#include <cstring> 3 | using namespace std;
s409623895
p00618
C++
#include <iostream> #include <algorithm> #include <queue> using namespace std; #define MAX 20 #define INF 1e9 struct State{ int total,sub,S; State(int total,int sub,int S) : total(total),sub(sub),S(S) {} }; int main(){ int N,U,c[MAX],k,r; while(cin >> N >> U, (N | U)){ int arr[MAX]; for(int i = 0 ; i < N ; i++){ cin >> c[i] >> k; int S = 0; for(int j = 0 ; j < k ; j++){ cin >> r; S |= 1<<r; } arr[i] = S; } bool visited[1<<N]; memset(visited,false,sizeof(visited)); visited[0] = true; queue<State> Q; Q.push(State(0,0,0)); while(!Q.empty()){ State now = Q.front(); Q.pop(); if(now.total >= U){ cout << now.sub << endl; break; } for(int i = 0 ; i < N ; i++){ int S = now.S; S |= 1<<i; if(!visited[S] && (S & arr[i] == arr[i])){ Q.push(State(now.total+c[i],now.sub+1,S)); } } } } return 0; }
a.cc: In function 'int main()': a.cc:31:5: error: 'memset' was not declared in this scope 31 | memset(visited,false,sizeof(visited)); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <queue> +++ |+#include <cstring> 4 |
s207827619
p00618
C++
#include <iostream> #include <vector> #include <cmath> #include <map> #include <stack> #include <algorithm> using namespace std; int main() { for( int a,worse; cin>>a>>worse , a|worse ; ) { map< int , int > m; map< int , vector<int> > flg; for( int i=0 ; i<a ; i++ ) { int num1,num2; cin>> num1 >> num2; m[i] = num1 ; if( num2 ){ for( int j=0 ; j<num2 ; j++ ){ int before;cin>>before; flg[i].push_back( before ); } } flg[i].push_back( -1 ); } int result=0; while( worse > 0 ){ int max=0; int maxIndex=INT_MAX; for( int i=0 ; i<a ; i++ ){ if( flg[i].size() <= 1 ){ if( max<m[i] ){ max=m[i]; maxIndex=i; } } } for( int i=0 ; i<a ; i++ ){ vector<int>::iterator point=find( flg[i].begin() , flg[i].end() , maxIndex ); if( point != flg[i].end() ){ flg[i].erase( point ); } } worse-=max; result++; m[ maxIndex ] = 0; //cout << maxIndex << ":"; } cout << endl; cout << result << endl; } }
a.cc: In function 'int main()': a.cc:34:38: error: 'INT_MAX' was not declared in this scope 34 | int maxIndex=INT_MAX; | ^~~~~~~ a.cc:7:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 6 | #include <algorithm> +++ |+#include <climits> 7 | using namespace std;
s004651226
p00618
C++
#include<cstdio> #include<algorithm> using namespace std; #define REP(i, N) for(int i=0;i<(int)(N);++i) int unit[20]; int need[20]; int nextInt() { int r = 0, ch; while( isspace(ch = getchar())); do { r = r * 10 + ch - '0'; }while( isdigit( ch = getchar() ) ); return r; } int main() { for(;;) { int N, U; scanf("%d%d", &N, &U); if( N == 0 && U == 0 ) break; REP(i, N) need[i] = 0; int all = 0; REP(i, N) { scanf("%d", &unit[i]); all += unit[i]; int K; scanf("%d", &K); REP(k, K) { int x; scanf("%d", &x); need[i] |= (1 << x); } } if( all == U ) { printf("%d\n", N); continue; } int best = N; for(int mask = 0; mask < 1 << N; mask++) { int one = __builtin_popcount(mask); if( best <= one ) continue; int have = 0; for(int k = 0; k < N; k++) if( mask & (1 << k) ) have += unit[k]; if( have < U ) continue; bool can = true; for(int k = 0; k < N; k++) if( mask & (1 << k) ) { if( (mask | (need[k])) != mask ) { can = false; break; } } if( can ) best =one; } printf("%d\n", best); } }
a.cc: In function 'int nextInt()': a.cc:12:10: error: 'isspace' was not declared in this scope 12 | while( isspace(ch = getchar())); | ^~~~~~~ a.cc:15:11: error: 'isdigit' was not declared in this scope 15 | }while( isdigit( ch = getchar() ) ); | ^~~~~~~
s258379881
p00618
C++
#include<stdio.h> static inline int getint(){ int ret = 0; int g; while(!isdigit(g = getchar())); ret = g-'0'; while(isdigit(g = getchar())){ ret *= 10; ret += g-'0'; } return ret;; } static inline int cnt(unsigned int bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff); } int main(){ int c[20],k,r[20]; int n,u; unsigned int i,j,l; while(n=getint(), u=getint(), n+u){ int ans = n; for(i=0; i<n; i++){ c[i]=getint(); k=getint(); r[i] = 0; for(j=0; j<k; j++){ int t = getint(); r[i] |= (1<<t); } } for(i=(1<<n)-1; i; i--){ int tni = 0; int ok = 1; int cc = cnt(i); if(cc >= ans) continue; for(j=0; ok & j<n; j++){ if(i & (1<<j)) tni += c[j]; if((i & (1<<j)) & ((i & r[j]) ^ r[j])) ok = 0; } if(tni >= u & ok) ans = cc; } printf("%d\n",ans); } }
a.cc: In function 'int getint()': a.cc:6:10: error: 'isdigit' was not declared in this scope 6 | while(!isdigit(g = getchar())); | ^~~~~~~ a.cc:8:9: error: 'isdigit' was not declared in this scope 8 | while(isdigit(g = getchar())){ | ^~~~~~~
s517104933
p00618
C++
#include<iostream> #include<vector> #include<cstring> #include<queue> using namespace std; #define REP(i,a,b) for(i=a; i<b; ++i) #define rep(i,n) REP(i,0,n) vector<int> cv,pv; int n,U; int memo[1<<20]; struct state { int used,cost,depth; state(int used,int depth,int cost) : used(used), depth(depth), cost(cost) {;} }; int bfs() { queue<state> Q; Q.push(state(0,0,0)); state ns(0,0,0);; int i; while(!Q.empty()) { ns = Q.front(); Q.pop(); for(i=0; i<n; ++i) { if((ns.used>>i) & 1 || memo[ns.used|k] || (ns.used & pv[i] != pv[i])) continue; memo[ns.used|(1<<i)] = 1; if(ns.cost+cv[i] >= U) return ns.depth+1; Q.push(state((ns.used|(1<<i)),ns.depth+1,ns.cost+cv[i])); } } } int main() { int i,j,k,c,r,tmp; while(cin>>n>>U, n|U) { cv.clear(); pv.clear(); pv.resize(n); memset(memo, 0, sizeof(memo)); rep(i,n) { cin>>c>>k; cv.push_back(c); tmp = 0; rep(j,k) { cin>>r; tmp |= (1<<r); } pv[i] = tmp; } cout<<bfs()<<endl; } }
a.cc: In function 'int bfs()': a.cc:30:26: error: 'k' was not declared in this scope 30 | || memo[ns.used|k] | ^ a.cc:37:1: warning: control reaches end of non-void function [-Wreturn-type] 37 | } | ^
s649821628
p00618
C++
#include <stdio.h> #include <stdlib.h> typedef struct { int unit; int k; int end_sub[20]; } SUBJECT; int main(void) { unsigned int bit; SUBJECT sub[20]; int ans; int u; int n; while (1){ scanf("%d%d", &n, &u); if (!n) break; for (int i = 0; i < n; i++){ scanf("%d%d", &sub[i].unit, &sub[i].k); for (int j = 0; j < sub[i].k; j++){ scanf("%d", &sub[i].end_sub[j]); } } ans = n; for (bit = 0; bit < 1 << n; bit++){ int sum; int sub_cnt; sum = sub_cnt = 0; for (int i = 0; i < n; i++){ int j; if ((bit >> i) & 1 == 1){ sub_cnt++; for (j = 0; j < sub[i].k; j++){ if ((bit >> sub[i].end_sub[j]) & 1 != 1){ break; } } if (j == sub[i].k){ sum += sub[i].unit; } } } if (sum == u){ ans = min(ans, sub_cnt); } } printf("%d\n", ans); } return (0); }
a.cc: In function 'int main()': a.cc:52:39: error: 'min' was not declared in this scope; did you mean 'main'? 52 | ans = min(ans, sub_cnt); | ^~~ | main
s050729012
p00618
C++
k#include <iostream> #include <vector> #include <algorithm> using namespace std; int tani[21]; int needs[21]; // i‚̏ó‘Ô‚©‚çUˆÈã‚Ì’PˆÊ‚É‚½‚ǂ蒅‚­Å¬—šC” int dp[1<<20]; // s‚«æ //vector<int> tos[1<<20]; int U; int n; int dfs(int s,int sum){ if(dp[s]!=-1) return dp[s]; else if(sum>=U){ dp[s]=0; return dp[s]; } else{ int minCost=1000000; //bool used[21]; //for(int i = 0; i < n; i++){ // if((s>>i)&1) // used[i]=true; //} // ‚‚¬‚ɂǂ±‚Ö‘JˆÚ‚·‚é‚© //for(int i = 0; i < tos[s].size(); i++){ // minCost=min(minCost,dfs(s|(1<<(tos[s][i])),sum+tani[tos[s][i]])+1); // if(minCost==1) // break; //} for(int i = 0; i < n; i++){ // ‚Ü‚¾‘JˆÚ‚µ‚ĂȂ©‚Á‚½‚ç if(!((s>>i)&1)){ if(((needs[i])&s)==needs[i]){ minCost=min(minCost,dfs(s|(1<<i),sum+tani[i])+1); if(minCost==1) break; } //for(int j = 0; j < vpii[i].second.size(); j++){ // if(!used[vpii[i].second[j]]){ // f=true; // break; // } //} //if(!f) // minCost=min(minCost,dfs(s|(1<<i),sum+vpii[i].first)+1); } } dp[s]=minCost; return dp[s]; } } int main(){ int c,k; int t; int tn; while(cin>>n>>U&&!(n==0&&U==0)){ fill(dp,dp+(1<<20),-1); for(int i = 0; i < n; i++){ cin>>c>>k; tn=0; for(int j = 0; j < k; j++){ cin>>t; tn|=(1<<t); } tani[i]=c; needs[i]=tn; } //for(int s = 0; s < (1<<n); s++){ // for(int i = 0; i < n; i++){ // if(!((s>>i)&1)){ // if(((needs[i])&s)==needs[i]){ // tos[s].push_back(i); // } // } // } //} cout<<dfs(0,0)<<endl; //for(int i = 0; i < (1<<n); i++) // tos[i].clear(); } return 0; }
a.cc:1:2: error: stray '#' in program 1 | k#include <iostream> | ^ a.cc:1:1: error: 'k' does not name a type 1 | k#include <iostream> | ^ In file included from /usr/include/c++/14/bits/stl_algobase.h:62, from /usr/include/c++/14/vector:62, from a.cc:2: /usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity 164 | __is_null_pointer(std::nullptr_t) | ^ /usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)' 159 | __is_null_pointer(_Type) | ^~~~~~~~~~~~~~~~~ /usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std' 164 | __is_null_pointer(std::nullptr_t) | ^~~~~~~~~ In file included from /usr/include/c++/14/bits/stl_pair.h:60, from /usr/include/c++/14/bits/stl_algobase.h:64: /usr/include/c++/14/type_traits:295:27: error: 'size_t' has not been declared 295 | template <typename _Tp, size_t = sizeof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std' 666 | struct is_null_pointer<std::nullptr_t> | ^~~~~~~~~ /usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid 666 | struct is_null_pointer<std::nullptr_t> | ^ /usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid 670 | struct is_null_pointer<const std::nullptr_t> | ^ /usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid 674 | struct is_null_pointer<volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid 678 | struct is_null_pointer<const volatile std::nullptr_t> | ^ /usr/include/c++/14/type_traits:984:26: error: 'size_t' has not been declared 984 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:985:40: error: '_Size' was not declared in this scope 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:985:46: error: template argument 1 is invalid 985 | struct __is_array_known_bounds<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std' 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^~~~~~ /usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid 1429 | : public integral_constant<std::size_t, alignof(_Tp)> | ^ /usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std' 1438 | : public integral_constant<std::size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid 1438 | : public integral_constant<std::size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared 1440 | template<typename _Tp, std::size_t _Size> | ^~~ /usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope 1441 | struct rank<_Tp[_Size]> | ^~~~~ /usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid 1441 | struct rank<_Tp[_Size]> | ^ /usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std' 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid 1442 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std' 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid 1446 | : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; | ^ /usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1451:32: error: 'size_t' was not declared in this scope 1451 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:64:1: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' 63 | #include <bits/version.h> +++ |+#include <cstddef> 64 | /usr/include/c++/14/type_traits:1451:41: error: template argument 1 is invalid 1451 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1451:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1453:26: error: 'size_t' has not been declared 1453 | template<typename _Tp, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1454:23: error: '_Size' was not declared in this scope 1454 | struct extent<_Tp[_Size], 0> | ^~~~~ /usr/include/c++/14/type_traits:1454:32: error: template argument 1 is invalid 1454 | struct extent<_Tp[_Size], 0> | ^ /usr/include/c++/14/type_traits:1455:32: error: 'size_t' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1455:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1455:40: error: '_Size' was not declared in this scope 1455 | : public integral_constant<size_t, _Size> { }; | ^~~~~ /usr/include/c++/14/type_traits:1455:45: error: template argument 1 is invalid 1455 | : public integral_constant<size_t, _Size> { }; | ^ /usr/include/c++/14/type_traits:1455:45: error: template argument 2 is invalid /usr/include/c++/14/type_traits:1457:42: error: 'size_t' has not been declared 1457 | template<typename _Tp, unsigned _Uint, size_t _Size> | ^~~~~~ /usr/include/c++/14/type_traits:1458:23: error: '_Size' was not declared in this scope 1458 | struct extent<_Tp[_Size], _Uint> | ^~~~~ /usr/include/c++/14/type_traits:1458:36: error: template argument 1 is invalid 1458 | struct extent<_Tp[_Size], _Uint> | ^ /usr/include/c++/14/type_traits:1463:32: error: 'size_t' was not declared in this scope 1463 | : public integral_constant<size_t, 0> { }; | ^~~~~~ /usr/include/c++/14/type_traits:1463:32: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1463:41: error: template argument 1 is invalid 1463 | : public integral_constant<size_t, 0> { }; | ^ /usr/include/c++/14/type_traits:1463:41: note: invalid template non-type parameter /usr/include/c++/14/type_traits:1857:26: error: 'size_t' does not name a type 1857 | { static constexpr size_t __size = sizeof(_Tp); }; | ^~~~~~ /usr/include/c++/14/type_traits:1857:26: note: 'size_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>' /usr/include/c++/14/type_traits:1859:14: error: 'size_t' has not been declared 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~~~~ /usr/include/c++/14/type_traits:1859:48: error: '_Sz' was not declared in this scope 1859 | template<size_t _Sz, typename _Tp, bool = (_Sz <= _Tp::__size)> | ^~~ /usr/include/c++/14/type_traits:1860:14: error: no default argument for '_Tp' 1860 | struct __select; | ^~~~~~~~ /usr/include/c++/14/type_traits:1862:14: error: 'size_t' has not been declared 1862 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1863:23: error: '_Sz' was not declared in this scope 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^~~ /usr/include/c++/14/type_traits:1863:57: error: template argument 1 is invalid 1863 | struct __select<_Sz, _List<_Uint, _UInts...>, true> | ^ /usr/include/c++/14/type_traits:1866:14: error: 'size_t' has not been declared 1866 | template<size_t _Sz, typename _Uint, typename... _UInts> | ^~~~~~ /usr/include/c++/14/type_traits:1867:23: error: '_Sz' was not declared in this scope 1867 | struct __select<_Sz, _List<_Uint, _UInts...>, false> | ^~~ /usr/include/c++/14/type_traits:1867:58: error: template argument 1 is invalid 1867 |
s225189942
p00618
C++
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int main(){ int n,U; int c[30],k[30],r[30][30]; while(scanf("%d%d",&n,&U),(n||U)){ for(int i=0;i<n;i++){ scanf("%d%d",&c[i],&k[i]); for(int j=0;j<k[i];j++)scanf("%d",&r[i][j]); } int res = n; for(int i=0;i<(1<<n);i++){ int num = __builtin_popcount(i), sum = 0; if(res <= num)continue; for(int j=0;j<n;j++){ if( (i>>j)&1 )sum += c[j]; } if(sum<U)continue; bool f = true; for(int j=0;j<n;j++){ if( (i>>j)&1 ){ for(int l=0;l<k[j];l++){ f &= (i>>r[j][l])&1; if(!f)break;Darsein } if(!f)break; } } if(f && U<=sum)res = min(res,num); } printf("%d\n",res); } }
a.cc: In function 'int main()': a.cc:30:25: error: 'Darsein' was not declared in this scope 30 | if(!f)break;Darsein | ^~~~~~~
s582347125
p00619
C++
#include <cstdio> #include <cstdlib> #include <cmath> #include <climits> #include <cfloat> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> using namespace std; static const double EPS = 1e-10; const double INF = 1e12; typedef complex<double> P,point; std::istream& operator>>(std::istream& is,P& p) { is >> p.real() >> p.imag(); return is; } typedef vector<P> G,polygon; struct L : public vector<P> {L(const P &a, const P &b) {push_back(a); push_back(b);} L(){push_back(P(0,0)); push_back(P(0,0));}}; namespace std {bool operator < (const P& a, const P& b) {return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);} } double cross(const P& a, const P& b) {return imag(conj(a)*b);} double dot(const P& a, const P& b) {return real(conj(a)*b);} bool intersectLL(const L &l, const L &m) {return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;} P crosspoint(const L &l, const L &m) { double A = cross(l[1] - l[0], m[1] - m[0]); double B = cross(l[1] - l[0], l[1] - m[0]); if (abs(A) < EPS && abs(B) < EPS) return m[0]; return m[0] + B / A * (m[1] - m[0]); } bool intersectSP(const L &s, const P &p) {return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS;} struct Node{ int id; double dir; double cost; Node(int id,double dir,double cost) : id(id),dir(dir),cost(cost){} }; bool operator <(const Node &a,const Node &b){ return a.cost > b.cost; } double PI = acos(-1); double fix(double x){ while( x >= 2 * PI ) x -= 2 * PI; while( x < 0) x += 2 * PI; return x; } int main(){ int n; while(cin >> n && n){ L l[n]; for(int i = 0 ; i < n ; i++) cin >> l[i][0] >> l[i][1]; vector<P> tar; for(int i = 0 ; i < n ; i++){ tar.push_back(l[i][0]); tar.push_back(l[i][1]); for(int j = 0 ; j < n ; j++){ if( intersectLL(l[i],l[j]) ) tar.push_back(crosspoint(l[i],l[j])); } } P s,g; cin >> s >> g; tar.push_back(s); tar.push_back(g); vector< vector<int> > connect(tar.size()); for(int i = 0 ; i < tar.size() ; i++){ for(int j = i+1 ; j < tar.size() ; j++){ for(int k = 0 ; k < n ; k++){ if( abs(tar[i]-tar[j]) < EPS || intersectSP(l[k],tar[i]) && intersectSP(l[k],tar[j]) ){ connect[i].push_back(j); connect[j].push_back(i); break; } } } } priority_queue<Node> Q; Q.push(Node(tar.size()-2,-114514,0)); map< pair<int,double> , int> done; double res = -1; while( Q.size() ){ Node q = Q.top(); Q.pop(); if( done[make_pair(q.id,q.dir)]++ ) continue; P my = tar[q.id]; if( tar.size() - 1 == q.id ){ res = q.cost; break; } for(int i = 0 ; i < connect[q.id].size() ; i++){ int eid = connect[q.id][i]; P ene = tar[eid]; ene -= my; double rad = atan2(ene.imag(),ene.real()); rad = fix(rad); double diff = fabs(q.dir-rad); diff = min(2*PI-diff,diff); if( q.dir == -114514 ) diff = 0; Q.push(Node(eid,rad,q.cost+diff)); } } if( res < 0 ){ cout << -1 << endl; }else{ printf("%.10lf\n",res*180/PI); } } }
a.cc: In function 'std::istream& operator>>(std::istream&, P&)': a.cc:27:12: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'double') 27 | is >> p.real() >> p.imag(); | ~~ ^~ ~~~~~~~~ | | | | | double | std::istream {aka std::basic_istream<char>} In file included from /usr/include/c++/14/iostream:42, from a.cc:9: /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:27:21: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double' 27 | is >> p.real() >> p.imag(); | ~~~~~~^~ /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:27:21: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'double' 27 | is >> p.real() >> p.imag(); | ~~~~~~^~ /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:27:21: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'double' 27 | is >> p.real() >> p.imag(); | ~~~~~~^~ /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:27:21: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'double' 27 | is >> p.real() >> p.imag(); | ~~~~~~^~ /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:27:21: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'double' 27 | is >> p.real() >> p.imag(); | ~~~~~~^~ /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:27:21: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'double' 27 | is >> p.real() >> p.imag(); | ~~~~~~^~ /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:27:21: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'double' 27 | is >> p.real() >> p.imag(); | ~~~~~~^~ /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:27:21: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'double' 27 | is >> p.real() >> p.imag(); | ~~~~~~^~ /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:27:21: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'double' 27 | is >> p.real() >> p.imag(); | ~~~~~~^~ /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:27:21: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'double' 27 | is >> p.real() >> p.imag(); | ~~~~~~^~ /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:27:21: error: cannot bind non-const lvalue reference of type 'double&' to an rvalue of type 'double' 27 | is >> p.real() >> p.imag(); | ~~~~~~^~ /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:27:21: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type 'double' 27 | is >> p.real() >> p.imag(); | ~~~~~~^~ a.cc:25:15: note: candidate: 'std::istream& operator>>(std::istream&, P&)' (near match) 25 | std::istream& operator>>(std::istream& is,P& p) | ^~~~~~~~ a.cc:25:15: note: conversion of argument 2 would be ill-formed: a.cc:27:21: error: cannot bind non-const lvalue reference of type 'P&' {aka 'std::complex<double>&'} to an rvalue of type 'P' {aka 'std::complex<double>'} 27 | is >> p.real() >> p.imag(); | ~~~~~~^~ In file included from a.cc:16: /usr/include/c++/14/complex:1514:26: note: after user-defined conversion: 'constexpr std::complex<double>::complex(double, double)' 1514 | _GLIBCXX_CONSTEXPR complex(double __r = 0.0, double __i = 0.0) | ^~~~~~~ /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
s646092391
p00619
C++
#include <bits/stdc++.h> using namespace std; #define EPS (1e-6) #define equal(a,b) (fabs(a-b) < EPS) #define lt(a,b) (a-b < -EPS) #define MAX 252 #define INF (1e9) #define PI acos(-1) struct Point{ double x,y; Point(){} Point(double x,double y) : x(x),y(y) {} Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); } Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); } Point operator * (const double &k)const{ return Point(x*k,y*k); } Point operator / (const double &k)const{ return Point(x/k,y/k); } bool operator < (const Point &p)const{ return x != p.x ? x < p.x : y < p.y; } bool operator == (const Point &p)const{ return (x == p.x && y == p.y); } }; double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; } double cross(const Point &a,const Point &b){ return a.x*b.y - b.x*a.y; } double norm(const Point &p){ return dot(p,p); } double abs(const Point &p){ return sqrt(norm(p)); } double dist(const Point &a,const Point &b){ return sqrt(pow(a.x-b.x,2) + pow(a.y-b.y,2)); } double toRad(double ang){ return ang*PI/180; } double toAng(double rad){ return rad*180/PI; } #define COUNTER_CLOCKWISE 1 #define CLOCKWISE -1 #define ONLINE_BACK 2 #define ONLINE_FRONT -2 #define ON_SEGMENT 0 typedef Point Vector; int ccw(Point p0,Point p1,Point p2){ Vector a = p1 - p0; Vector b = p2 - p0; if(cross(a,b) > EPS) return COUNTER_CLOCKWISE; if(cross(a,b) < -EPS) return CLOCKWISE; if(dot(a,b) < -EPS) return ONLINE_BACK; if(norm(a) < norm(b)) return ONLINE_FRONT; return ON_SEGMENT; } map<Point,int> mp; double mem[MAX][MAX]; double getAngle(const Point &a,const Point &b,const Point &c){ Vector v1 = b-a, v2 = c-b; double aa = mem[mp[b]][mp[a]]; double ba = mem[mp[c]][mp[b]]; if(aa == -1){ aa = atan2(v1.y,v1.x); mem[mp[b]][mp[a]] = aa; } if(ba == -1){ ba = atan2(v2.y,v2.x); mem[mp[c]][mp[b]] = ba; } if(aa > ba) swap(aa,ba); double rad = ba - aa; double ang = toAng(rad); return min(ang,180-ang); } struct Segment{ Point s,t; Segment(){} Segment(Point &s,Point &t) : s(s),t(t) {} }; bool isIntersectSP(const Segment &s,const Point &p){ return (ccw(s.s,s.t,p) == 0); } bool isIntersectSS(const Segment &a,const Segment &b){ Point s[2] = {a.s,a.t}, t[2] = {b.s,b.t}; return (ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 && ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0); } Point crosspointSS(const Segment &a,const Segment &b){ Vector va = a.t-a.s, vb = b.t-b.s; double d = cross(vb,va); if(abs(d) < EPS) return b.s; return a.s+va*cross(vb,b.t-a.s)*(1.0/d); } typedef vector<int> Edges; typedef vector<Edges> Graph; Graph segmentArrangement(vector<Segment> &segs,vector<Point> &ps){ Graph G; int N = segs.size(); ps.clear(); for(int i = 0 ; i < N ; i++){ ps.push_back(segs[i].s); ps.push_back(segs[i].t); for(int j = i+1 ; j < N ; j++){ Vector a = segs[i].t - segs[i].s; Vector b = segs[j].t - segs[j].s; if(equal(cross(a,b),0)) continue; if(isIntersectSS(segs[i],segs[j])){ ps.push_back(crosspointSS(segs[i],segs[j])); } } } sort(ps.begin(),ps.end()); ps.erase(unique(ps.begin(),ps.end()),ps.end()); int N2 = ps.size(); G.resize(N2); for(int i = 0 ; i < N ; i++){ vector<int> vec; for(int j = 0 ; j < N2 ; j++){ if(isIntersectSP(segs[i],ps[j])){ vec.push_back(j); } } sort(vec.begin(),vec.end()); for(int j = 0 ; j < (int)vec.size()-1 ; j++){ int u = vec[j], v = vec[j+1]; G[u].push_back(v); G[v].push_back(u); } } return G; } struct State{ double w; int p,n; State(){} State(double w,int p,int n) : w(w),p(p),n(n) {} bool operator > (const State &s)const{ return lt(w,s.w); } }; double add(double a,double b){ if(abs(a+b) < EPS * (abs(a) + abs(b))){ return 0; } return a + b; } double dijkstra(Graph &G,Point &s,Point &t,vector<Point> &ps){ mp.clear(); memset(mem,-1,sizeof(mem)); for(int i = 0 ; i < (int)ps.size() ; i++){ mp[ps[i]] = i; } double d[MAX][MAX]; for(int i = 0 ; i < MAX ; i++){ for(int j = 0 ; j < MAX ; j++){ d[i][j] = INF; } } priority_queue<State> Q; for(int i = 0 ; i < (int)G[mp[s]].size() ; i++){ int to = G[mp[s]][i]; Q.push(State(0,mp[s],to)); d[mp[s]][to] = 0; } while(!Q.empty()){ State st = Q.top(); Q.pop(); int p = st.p,n = st.n; if(lt(d[p][n],st.w)) continue; Point p1 = ps[p],p2 = ps[n]; if(p2 == t) return d[p][n]; for(int i = 0 ; i < (int)G[n].size() ; i++){ int to = G[n][i]; Point p3 = ps[to]; if(p1 == p3) continue; double ncost = add(st.w,getAngle(p1,p2,p3)); if(lt(ncost,d[n][to])){ d[n][to] = ncost; Q.push(State(d[n][to],n,to)); } } } return INF; } int main(){ int N; while(cin >> N, N){ Point s,t; vector<Segment> segs(N); for(int i = 0 ; i < N ; i++){ cin >> segs[i].s.x >> segs[i].s.y; cin >> segs[i].t.x >> segs[i].t.y; } cin >> s.x >> s.y >> t.x >> t.y; vector<Point> ps; Graph G = segmentArrangement(segs,ps); double res = dijkstra(G,s,t,ps); if(res == INF){ cout << -1 << endl; }else{ printf("%.12f\n",res); } } return 0; }
In file included from /usr/include/c++/14/string:49, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52, from a.cc:1: /usr/include/c++/14/bits/stl_function.h: In instantiation of 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = State]': /usr/include/c++/14/bits/predefined_ops.h:196:23: required from 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<State*, std::vector<State, std::allocator<State> > >; _Value = State; _Compare = std::less<State>]' 196 | { return bool(_M_comp(*__it, __val)); } | ~~~~~~~^~~~~~~~~~~~~~ /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<State*, vector<State, allocator<State> > >; _Distance = long int; _Tp = State; _Compare = __gnu_cxx::__ops::_Iter_comp_val<less<State> >]' 140 | while (__holeIndex > __topIndex && __comp(__first + __parent, __value)) | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_heap.h:216:23: required from 'void std::push_heap(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<State*, vector<State, allocator<State> > >; _Compare = less<State>]' 216 | std::__push_heap(__first, _DistanceType((__last - __first) - 1), | ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 217 | _DistanceType(0), _GLIBCXX_MOVE(__value), __cmp); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_queue.h:747:16: required from 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = State; _Sequence = std::vector<State, std::allocator<State> >; _Compare = std::less<State>; value_type = State]' 747 | std::push_heap(c.begin(), c.end(), comp); | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~ a.cc:174:15: required from here 174 | Q.push(State(0,mp[s],to)); | ~~~~~~^~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_function.h:405:20: error: no match for 'operator<' (operand types are 'const State' and 'const State') 405 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const State' is not derived from 'const std::pair<_T1, _T2>' 405 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const State' is not derived from 'const std::reverse_iterator<_Iterator>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const State' is not derived from 'const std::reverse_iterator<_Iterator>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const State' is not derived from 'const std::move_iterator<_IteratorL>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const State' is not derived from 'const std::move_iterator<_IteratorL>' 405 | { return __x < __y; } | ~~~~^~~~~
s309718711
p00620
C++
#include <stdio.h> #include <list> #include <iostream> #include <conio.h> using namespace std; #define GU (-100) list<unsigned long long> LineData[32]; int map[8 + 2][8 + 2]; int n; int make_line(int x, int y, int now, int goal, unsigned long long flag, int start_id) { if (now == goal){ LineData[start_id].push_back(flag); return (0); } if (map[x][y] <= 0 || now > goal || (flag >> ((y - 1) * 8 + (x - 1))) & 1 == 1){ return (0); } now += map[x][y]; int d = (((y - 1) * 8) + (x - 1)); *(((int *)(&flag)) + (d / 32)) |= 1 << (d % 32); make_line(x + 1, y, now, goal, flag, start_id); make_line(x - 1, y, now, goal, flag, start_id); make_line(x, y + 1, now, goal, flag, start_id); make_line(x, y - 1, now, goal, flag, start_id); return (0); } bool is_clear(int depth, int start_cnt, unsigned long long flag) { list<unsigned long long>::iterator it; if (depth == start_cnt){ int st_cnt; st_cnt = 0; for (int i = 0; i < 64; i++){ st_cnt += (*(((int *)(&flag)) + (i / 32)) >> i % 32) & 1; } return (st_cnt == n * n ? true : false); } for (it = LineData[depth].begin(); it != LineData[depth].end(); it++){ if (flag ^ *it == flag | *it && is_clear(depth + 1, start_cnt, flag | *it) == true){ return (true); } } return (false); } int main(void) { int start_cnt; long long start_flag; while (1){ for (int i = 0; i < 32; i++){ LineData[i].clear(); } for (int y = 0; y < 10; y++){ for (int x = 0; x < 10; x++){ map[x][y] = GU; } } scanf("%d", &n); if (n == 0)break; for (int y = 1; y <= n; y++){ for (int x = 1; x <= n; x++){ scanf("%d", &map[x][y]); } } start_cnt = start_flag = 0; for (int y = 1; y <= n; y++){ for (int x = 1; x <= n; x++){ if (map[x][y] < 0){ make_line(x + 1, y, 0, -map[x][y], 0, start_cnt); make_line(x - 1, y, 0, -map[x][y], 0, start_cnt); make_line(x, y + 1, 0, -map[x][y], 0, start_cnt); make_line(x, y - 1, 0, -map[x][y], 0, start_cnt); int d = ((y - 1) * 8 + (x - 1)); *(((int *)(&start_flag)) + (d / 32)) |= 1 << (d % 32); start_cnt++; } } } for (int i = 0; i < start_cnt; i++){ LineData[i].sort(); LineData[i].unique(); #if 0 for (list<unsigned long long>::iterator it = LineData[i].begin(); it != LineData[i].end(); it++){ int sum = 0; for (int i = 0; i < 8; i++){ for (int j = 0; j < 8; j++){ printf("%d", (*it >> i * 8 + j) & 1); if ((*it >> i * 8 + j) & 1 == 1){ sum += map[j + 1][i + 1]; } } puts(""); } printf("%d\n", sum); // getch(); } #endif } printf("%s\n", is_clear(0, start_cnt, start_flag) == true ? "YES" : "NO"); } return (0); }
a.cc:4:10: fatal error: conio.h: No such file or directory 4 | #include <conio.h> | ^~~~~~~~~ compilation terminated.
s149729042
p00620
C++
#include<bits/stdc++.h> #define REP(i,s,n) for(int i=s;i<n;i++) #define rep(i,n) REP(i,0,n) #define IINF (INT_MAX) #define MAX 9 using namespace std; typedef unsigned long long ull; const string Y = "YES", N = "NO"; int n,field[MAX][MAX],V; vector<int> V_sum; vector<int> coor; int dx[] = {0,1,0,-1}; int dy[] = {1,0,-1,0}; inline bool isValid(int x,int y){ return 0 <= x && x < n && 0 <= y && y < n; } bool check(ull used,int cur,int x,int y){ int sp_x = x, sp_y = y; REP(i,cur,V){ ull tmp_used = used; if( i != cur ) sp_x = coor[i] % n, sp_y = coor[i] / n; deque<int> deq; deq.push_back(sp_x+sp_y*n); bool ok = false; int score = V_sum[i]; if( score == 0 ) ok = true; while(!deq.empty()){ int p = deq.front(); deq.pop_front(); int cx = p % n, cy = p / n; if(ok)break; rep(j,4){ int nx = cx + dx[j]; int ny = cy + dy[j]; if(!isValid(nx,ny))continue; if((tmp_used>>(nx+ny*n))&1)continue; tmp_used |= (1ULL<<(nx+ny*n)); score += field[ny][nx]; if( score >= 0 ){ ok = true; break; } deq.push_back(nx+ny*n); } } if(!ok)return false; } return true; } bool dfs(ull used,int cur,int pre,int x,int y,int sum){ if( cur >= V ){ if( used == (1ULL<<(n*n))-1ULL ) return true; return false; } //if(!check(used,cur,x,y))return false; rep(i,4){ if( i == pre ) continue; int nx = x + dx[i]; int ny = y + dy[i]; if( !isValid(nx,ny) ) continue; if( (used>>(nx+ny*n)) & 1 ) continue; if( field[ny][nx] < 0 ) continue; if( sum + field[ny][nx] > V_sum[cur] ) continue; int ncur = cur; int npre = ( i + 2 ) % 4; int nsum = sum + field[ny][nx]; ull nused = used | (1ULL<<(nx+ny*n)); if( sum + field[ny][nx] == V_sum[cur] ){ ncur++; npre = -1; nsum = 0; nx = coor[ncur] % n; ny = coor[ncur] / n; } if( dfs(nused,ncur,npre,nx,ny,nsum) ) return true; } return false; } int main(){ while( scanf("%d",&n), n ){ visited.clear(); ull initial_state = 0ULL; V = 0; coor.clear(); V_sum.clear(); int sum = 0; rep(i,n)rep(j,n){ scanf("%d",&field[i][j]); sum += field[i][j]; if( field[i][j] < 0 ){ V++; ull tmp = (1ULL<<(j+i*n)); coor.push_back(j+i*n); initial_state |= (1ULL<<(j+i*n)); V_sum.push_back(-field[i][j]); } } /* if( sum != 0 ){ cout << N << endl; continue; } */ bool res = dfs(initial_state,0,-1,coor[0]%n,coor[0]/n,0); cout << (res?Y:N) << endl; } return 0; }
a.cc: In function 'int main()': a.cc:94:5: error: 'visited' was not declared in this scope 94 | visited.clear(); | ^~~~~~~
s008002856
p00621
Java
import javafx.beans.property.ReadOnlyIntegerProperty; import java.io.*; import java.util.*; public class Main { void run() { while (true) { int W = readInt(); int Q = readInt(); if (W == 0 && Q == 0) break; int[] used = new int[W]; Arrays.fill(used, -1); for (int q = 0; q < Q; q++) { char c = read().charAt(0); if (c == 's') { int id = readInt(); int w = readInt(); int p = -1; for (int i = 0; i + w <= W; i++) { boolean ok = true; for (int j = 0; j < w; j++) { if (used[i + j] != -1) ok = false; } if (ok) { p = i; break; } } if (p != -1) { for (int i = 0; i < w; i++) { used[p + i] = id; } sysout.println(p); } else { sysout.println("impossible"); } } else { int id = readInt(); for (int i = 0; i < W; i++) { if (used[i] == id) used[i] = -1; } } } sysout.println("END"); } } public static void main(String[] args) { new Main().run(); } // flush automatically iff you call `println` or `printf` or `format`. PrintWriter sysout = new PrintWriter(System.out, true); BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer buffer = null; String read() { if (buffer == null || !buffer.hasMoreTokens()) { try { buffer = new StringTokenizer(in.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return buffer.nextToken(); } int readInt() { return Integer.parseInt(read()); } long readLong() { return Long.parseLong(read()); } double readDouble() { return Double.parseDouble(read()); } String readLine() { buffer = null; try { return in.readLine(); } catch (IOException e) { throw new RuntimeException(e); } } }
Main.java:1: error: package javafx.beans.property does not exist import javafx.beans.property.ReadOnlyIntegerProperty; ^ 1 error
s993120014
p00621
Java
import java.until.Scanner; class Main{ Main(){ readscores(); showResult(); System.out.println("END"); } void readscores(){ scanner sc = new Scanner(System.in); while(sc.hasNext){ int W = sc.nextInt(); int Q = sc.nextInt(); } while(sc.hasNext){ String c = sc.nextInt(); int id = sc.nextInt(); int w = sc.nextInt(); } } void showResult(){ if(W = 0 && Q = 0) break; else if(w <= W && c = "s"){ W = W - w; System.out.println(W); } else if(w > W && c = "s"){ System.out.println("impossible"); } else if(c = "w"){ W = W + w; } } public static void main(String[] args){ new Main(); } }
Main.java:1: error: package java.until does not exist import java.until.Scanner; ^ Main.java:12: error: cannot find symbol scanner sc = new Scanner(System.in); ^ symbol: class scanner location: class Main Main.java:12: error: cannot find symbol scanner sc = new Scanner(System.in); ^ symbol: class Scanner location: class Main Main.java:25: error: cannot find symbol if(W = 0 && Q = 0) break; ^ symbol: variable W location: class Main Main.java:25: error: cannot find symbol if(W = 0 && Q = 0) break; ^ symbol: variable Q location: class Main Main.java:25: error: break outside switch or loop if(W = 0 && Q = 0) break; ^ Main.java:26: error: cannot find symbol else if(w <= W && c = "s"){ ^ symbol: variable w location: class Main Main.java:26: error: cannot find symbol else if(w <= W && c = "s"){ ^ symbol: variable W location: class Main Main.java:26: error: cannot find symbol else if(w <= W && c = "s"){ ^ symbol: variable c location: class Main Main.java:27: error: cannot find symbol W = W - w; ^ symbol: variable W location: class Main Main.java:27: error: cannot find symbol W = W - w; ^ symbol: variable W location: class Main Main.java:27: error: cannot find symbol W = W - w; ^ symbol: variable w location: class Main Main.java:28: error: cannot find symbol System.out.println(W); ^ symbol: variable W location: class Main Main.java:30: error: cannot find symbol else if(w > W && c = "s"){ ^ symbol: variable w location: class Main Main.java:30: error: cannot find symbol else if(w > W && c = "s"){ ^ symbol: variable W location: class Main Main.java:30: error: cannot find symbol else if(w > W && c = "s"){ ^ symbol: variable c location: class Main Main.java:33: error: cannot find symbol else if(c = "w"){ ^ symbol: variable c location: class Main Main.java:34: error: cannot find symbol W = W + w; ^ symbol: variable W location: class Main Main.java:34: error: cannot find symbol W = W + w; ^ symbol: variable W location: class Main Main.java:34: error: cannot find symbol W = W + w; ^ symbol: variable w location: class Main 20 errors
s846663086
p00621
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #define wall_max 100 #define pos(a) struct wall{ int iti; int catid; int catleng; struct wall* nextcat; }; int typechk(char record[], int* num1, int* num2){ char *wkptr = NULL; char wkchar[256]; int wknum = 0; int slen = 0; if(strncmp(record,"0",1) == 0){ return 1; }else if(strncmp(record,"s",1) == 0){ wkptr = strrchr(record, ' '); if(wkptr!=NULL){ (*num2) = atoi(wkptr+1); (*wkptr) = NULL; } wkptr = strrchr(record, ' '); if(wkptr!=NULL){ (*num1) = atoi(wkptr+1); (*wkptr) = NULL; } return 2; }else if(strncmp(record,"w",1) == 0){ wkptr = strrchr(record, ' '); if(wkptr!=NULL){ (*num1) = atoi(wkptr+1); (*wkptr) = NULL; } return 3; }else{ wkptr = strrchr(record, ' '); if(wkptr!=NULL){ (*num2) = atoi(wkptr+1); (*wkptr) = NULL; } (*num1) = atoi(record); return 4; } } void initwall(wall* rewall){ int i=0; for(i=0;i<wall_max;i++){ rewall[i].iti= i; rewall[i].catid = -1; rewall[i].catleng = 0; rewall[i].nextcat = NULL; } return; } int main(){ int num1, num2; int i=0; int type=0; char kiroku[256]; int dataset = 0; wall myhouse[wall_max]; int wallend; wall *bfpt = NULL; wall *nxpt = NULL; wall *curpt = NULL; int cmcatid; int cmcatleng; int tindex; int flg=0; while(1){ // ?¨???????????????? gets_s(kiroku); type = typechk(kiroku, &num1, &num2); if(type == 1){ // ??????????????? printf("END\n"); break; } else if(type == 4){ // ??\?????\ if(flg!=0){ printf("END\n"); }else{ flg = 1; } initwall(myhouse); wallend = num1; } else if(type == 2){ // ?????\??? cmcatid = num1; cmcatleng = num2; curpt = myhouse; while(1){ if(curpt->catid == -1){ if(curpt->nextcat != NULL){ if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti))){ curpt->catid = cmcatid; curpt->catleng = cmcatleng; printf("%d\n",curpt->iti); break; } else{ curpt = curpt->nextcat; } } else{ if(cmcatleng <= (wallend - curpt->iti)){ // ???????????? curpt->catid = cmcatid; curpt->catleng = cmcatleng; printf("%d\n",curpt->iti); break; } } } else{ if(curpt->nextcat == NULL){ // ??????????????????????????£??? if(cmcatleng <= (wallend - (curpt->iti + curpt->catleng))){ // ?¬?????????? bfpt = curpt; curpt+=curpt->catleng; bfpt->nextcat = curpt; curpt->catid = cmcatid; curpt->catleng = cmcatleng; printf("%d\n",curpt->iti); break; } else{ printf("impossible\n"); // ????????°??? break; } } else{ // ?¬??????? // ?????????????????? if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti+curpt->catleng))){ bfpt = curpt; nxpt = curpt->nextcat; curpt+=curpt->catleng; bfpt->nextcat = curpt; curpt->catid = cmcatid; curpt->catleng = cmcatleng; curpt->nextcat = nxpt; printf("%d\n",curpt->iti); break; } else{ curpt = curpt->nextcat; } } } } } else if(type == 3){ // ?????°??£??? cmcatid = num1; bfpt = NULL; curpt = myhouse; while(1){ if(curpt->catid == cmcatid){ if(bfpt!=NULL){ bfpt->nextcat = curpt->nextcat; } curpt->catid = -1; curpt->catleng = 0; if( curpt->iti != 0){ curpt->nextcat = NULL; } break; } else{ bfpt = curpt; if(curpt->nextcat!=NULL){ curpt = curpt->nextcat; } else{ break; // ????????????????????? } } } } } return 0; }
main.c: In function 'typechk': main.c:25:34: error: assignment to 'char' from 'void *' makes integer from pointer without a cast [-Wint-conversion] 25 | (*wkptr) = NULL; | ^ main.c:30:34: error: assignment to 'char' from 'void *' makes integer from pointer without a cast [-Wint-conversion] 30 | (*wkptr) = NULL; | ^ main.c:37:34: error: assignment to 'char' from 'void *' makes integer from pointer without a cast [-Wint-conversion] 37 | (*wkptr) = NULL; | ^ main.c:44:34: error: assignment to 'char' from 'void *' makes integer from pointer without a cast [-Wint-conversion] 44 | (*wkptr) = NULL; | ^ main.c: At top level: main.c:51:15: error: unknown type name 'wall' 51 | void initwall(wall* rewall){ | ^~~~ main.c: In function 'main': main.c:68:9: error: unknown type name 'wall'; use 'struct' keyword to refer to the type 68 | wall myhouse[wall_max]; | ^~~~ | struct main.c:70:9: error: unknown type name 'wall'; use 'struct' keyword to refer to the type 70 | wall *bfpt = NULL; | ^~~~ | struct main.c:71:9: error: unknown type name 'wall'; use 'struct' keyword to refer to the type 71 | wall *nxpt = NULL; | ^~~~ | struct main.c:72:9: error: unknown type name 'wall'; use 'struct' keyword to refer to the type 72 | wall *curpt = NULL; | ^~~~ | struct main.c:80:17: error: implicit declaration of function 'gets_s' [-Wimplicit-function-declaration] 80 | gets_s(kiroku); | ^~~~~~ main.c:92:25: error: implicit declaration of function 'initwall' [-Wimplicit-function-declaration] 92 | initwall(myhouse); | ^~~~~~~~ main.c:95:17: error: 'else' without a previous 'if' 95 | else if(type == 2){ // ?????\??? | ^~~~ main.c:100:41: error: request for member 'catid' in something not a structure or union 100 | if(curpt->catid == -1){ | ^~ main.c:101:49: error: request for member 'nextcat' in something not a structure or union 101 | if(curpt->nextcat != NULL){ | ^~ main.c:102:71: error: request for member 'nextcat' in something not a structure or union 102 | if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti))){ | ^~ main.c:102:94: error: request for member 'iti' in something not a structure or union 102 | if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti))){ | ^~ main.c:103:62: error: request for member 'catid' in something not a structure or union 103 | curpt->catid = cmcatid; | ^~ main.c:104:62: error: request for member 'catleng' in something not a structure or union 104 | curpt->catleng = cmcatleng; | ^~ main.c:105:76: error: request for member 'iti' in something not a structure or union 105 | printf("%d\n",curpt->iti); | ^~ main.c:109:70: error: request for member 'nextcat' in something not a structure or union 109 | curpt = curpt->nextcat; | ^~ main.c:113:81: error: request for member 'iti' in something not a structure or union 113 | if(cmcatleng <= (wallend - curpt->iti)){ // ???????????? | ^~ main.c:114:62: error: request for member 'catid' in something not a structure or union 114 | curpt->catid = cmcatid; | ^~ main.c:115:62: error: request for member 'catleng' in something not a structure or union 115 | curpt->catleng = cmcatleng; | ^~ main.c:116:76: error: request for member 'iti' in something not a structure or union 116 | printf("%d\n",curpt->iti); | ^~ main.c:122:49: error: request for member 'nextcat' in something not a structure or union 122 | if(curpt->nextcat == NULL){ // ??????????????????????????£??? | ^~ main.c:123:82: error: request for member 'iti' in something not a structure or union 123 | if(cmcatleng <= (wallend - (curpt->iti + curpt->catleng))){ // ?¬?????????? | ^~ main.c:123:95: error: request for member 'catleng' in something not a structure or union 123 | if(cmcatleng <= (wallend - (curpt->iti + curpt->catleng))){ // ?¬?????????? | ^~ main.c:125:69: error: request for member 'catleng' in something not a structure or union 125 | curpt+=curpt->catleng; | ^~ main.c:126:61: error: request for member 'nextcat' in something not a structure or union 126 | bfpt->nextcat = curpt; | ^~ main.c:127:62: error: request for member 'catid' in something not a structure or union 127 | curpt->catid = cmcatid; | ^~ main.c:128:62: error: request for member 'catleng' in something not a structure or union 128 | curpt->catleng = cmcatleng; | ^~ main.c:129:76: error: request for member 'iti' in something not a structure or union 129 | printf("%d\n",curpt->iti); | ^~ main.c:139:71: error: request for member 'nextcat' in something not a structure or union 139 | if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti+curpt->catleng))){ | ^~ main.c:139:94: error: request for member 'iti' in something not a structure or union 139 | if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti+curpt->catleng))){ | ^~ main.c:139:105: error: request for member 'catleng' in something not a structure or union 139 | if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti+curpt->catleng))){ | ^~ main.c:141:69: error: request for member 'nextcat' in something not a structure or union 141 | nxpt = curpt->nextcat; | ^~ main.c:142:69: error: request for member 'catleng' in something not a structure or union 142 | curpt+=curpt->catleng; | ^~ main.c:143:61: error: request for member 'nextcat' in something not a structure or union 143 | bfpt->nextcat = curpt; | ^~ main.c:144:62: error: request for member 'catid' in something not a structure or union 144 | curpt->catid = cmcatid; | ^~ main.c:145:62: error: request for member 'catleng' in something not a structure or union 145 | curpt->catleng = cmcatleng; | ^~ main.c:146:62: error: request for member 'nextcat' in something not a structure or union 146 | curpt->nextcat = nxpt; | ^~ main.c:147:76: error: request for member 'iti' in something not a structure or union 147 | printf("%d\n",curpt->iti); | ^~ main.c:151:70: error: request for member 'nextcat' in something not a structure or union 15
s242394592
p00621
C
#include <stdio.h> #include <string.h> #include <stdlib.h> #define wall_max 100 #define pos(a) typedef struct wall{ int iti; int catid; int catleng; struct wall* nextcat; }; int typechk(char record[], int* num1, int* num2){ char *wkptr = NULL; char wkchar[256]; int wknum = 0; int slen = 0; if(strncmp(record,"0",1) == 0){ return 1; }else if(strncmp(record,"s",1) == 0){ wkptr = strrchr(record, ' '); if(wkptr!=NULL){ (*num2) = atoi(wkptr+1); (*wkptr) = NULL; } wkptr = strrchr(record, ' '); if(wkptr!=NULL){ (*num1) = atoi(wkptr+1); (*wkptr) = NULL; } return 2; }else if(strncmp(record,"w",1) == 0){ wkptr = strrchr(record, ' '); if(wkptr!=NULL){ (*num1) = atoi(wkptr+1); (*wkptr) = NULL; } return 3; }else{ wkptr = strrchr(record, ' '); if(wkptr!=NULL){ (*num2) = atoi(wkptr+1); (*wkptr) = NULL; } (*num1) = atoi(record); return 4; } } void initwall(wall* rewall){ int i=0; for(i=0;i<wall_max;i++){ rewall[i].iti= i; rewall[i].catid = -1; rewall[i].catleng = 0; rewall[i].nextcat = NULL; } return; } int main(){ int num1, num2; int i=0; int type=0; char kiroku[256]; int dataset = 0; wall myhouse[wall_max]; int wallend; wall *bfpt = NULL; wall *nxpt = NULL; wall *curpt = NULL; int cmcatid; int cmcatleng; int tindex; int flg=0; while(1){ // ?¨???????????????? gets_s(kiroku); type = typechk(kiroku, &num1, &num2); if(type == 1){ // ??????????????? printf("END\n"); break; } else if(type == 4){ // ??\?????\ if(flg!=0){ printf("END\n"); }else{ flg = 1; } initwall(myhouse); wallend = num1; } else if(type == 2){ // ?????\??? cmcatid = num1; cmcatleng = num2; curpt = myhouse; while(1){ if(curpt->catid == -1){ if(curpt->nextcat != NULL){ if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti))){ curpt->catid = cmcatid; curpt->catleng = cmcatleng; printf("%d\n",curpt->iti); break; } else{ curpt = curpt->nextcat; } } else{ if(cmcatleng <= (wallend - curpt->iti)){ // ???????????? curpt->catid = cmcatid; curpt->catleng = cmcatleng; printf("%d\n",curpt->iti); break; } } } else{ if(curpt->nextcat == NULL){ // ??????????????????????????£??? if(cmcatleng <= (wallend - (curpt->iti + curpt->catleng))){ // ?¬?????????? bfpt = curpt; curpt+=curpt->catleng; bfpt->nextcat = curpt; curpt->catid = cmcatid; curpt->catleng = cmcatleng; printf("%d\n",curpt->iti); break; } else{ printf("impossible\n"); // ????????°??? break; } } else{ // ?¬??????? // ?????????????????? if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti+curpt->catleng))){ bfpt = curpt; nxpt = curpt->nextcat; curpt+=curpt->catleng; bfpt->nextcat = curpt; curpt->catid = cmcatid; curpt->catleng = cmcatleng; curpt->nextcat = nxpt; printf("%d\n",curpt->iti); break; } else{ curpt = curpt->nextcat; } } } } } else if(type == 3){ // ?????°??£??? cmcatid = num1; bfpt = NULL; curpt = myhouse; while(1){ if(curpt->catid == cmcatid){ if(bfpt!=NULL){ bfpt->nextcat = curpt->nextcat; } curpt->catid = -1; curpt->catleng = 0; if( curpt->iti != 0){ curpt->nextcat = NULL; } break; } else{ bfpt = curpt; if(curpt->nextcat!=NULL){ curpt = curpt->nextcat; } else{ break; // ????????????????????? } } } } } return 0; }
main.c:11:1: warning: useless storage class specifier in empty declaration 11 | }; | ^ main.c: In function 'typechk': main.c:25:34: error: assignment to 'char' from 'void *' makes integer from pointer without a cast [-Wint-conversion] 25 | (*wkptr) = NULL; | ^ main.c:30:34: error: assignment to 'char' from 'void *' makes integer from pointer without a cast [-Wint-conversion] 30 | (*wkptr) = NULL; | ^ main.c:37:34: error: assignment to 'char' from 'void *' makes integer from pointer without a cast [-Wint-conversion] 37 | (*wkptr) = NULL; | ^ main.c:44:34: error: assignment to 'char' from 'void *' makes integer from pointer without a cast [-Wint-conversion] 44 | (*wkptr) = NULL; | ^ main.c: At top level: main.c:51:15: error: unknown type name 'wall' 51 | void initwall(wall* rewall){ | ^~~~ main.c: In function 'main': main.c:68:9: error: unknown type name 'wall'; use 'struct' keyword to refer to the type 68 | wall myhouse[wall_max]; | ^~~~ | struct main.c:70:9: error: unknown type name 'wall'; use 'struct' keyword to refer to the type 70 | wall *bfpt = NULL; | ^~~~ | struct main.c:71:9: error: unknown type name 'wall'; use 'struct' keyword to refer to the type 71 | wall *nxpt = NULL; | ^~~~ | struct main.c:72:9: error: unknown type name 'wall'; use 'struct' keyword to refer to the type 72 | wall *curpt = NULL; | ^~~~ | struct main.c:80:17: error: implicit declaration of function 'gets_s' [-Wimplicit-function-declaration] 80 | gets_s(kiroku); | ^~~~~~ main.c:92:25: error: implicit declaration of function 'initwall' [-Wimplicit-function-declaration] 92 | initwall(myhouse); | ^~~~~~~~ main.c:95:17: error: 'else' without a previous 'if' 95 | else if(type == 2){ // ?????\??? | ^~~~ main.c:100:41: error: request for member 'catid' in something not a structure or union 100 | if(curpt->catid == -1){ | ^~ main.c:101:49: error: request for member 'nextcat' in something not a structure or union 101 | if(curpt->nextcat != NULL){ | ^~ main.c:102:71: error: request for member 'nextcat' in something not a structure or union 102 | if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti))){ | ^~ main.c:102:94: error: request for member 'iti' in something not a structure or union 102 | if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti))){ | ^~ main.c:103:62: error: request for member 'catid' in something not a structure or union 103 | curpt->catid = cmcatid; | ^~ main.c:104:62: error: request for member 'catleng' in something not a structure or union 104 | curpt->catleng = cmcatleng; | ^~ main.c:105:76: error: request for member 'iti' in something not a structure or union 105 | printf("%d\n",curpt->iti); | ^~ main.c:109:70: error: request for member 'nextcat' in something not a structure or union 109 | curpt = curpt->nextcat; | ^~ main.c:113:81: error: request for member 'iti' in something not a structure or union 113 | if(cmcatleng <= (wallend - curpt->iti)){ // ???????????? | ^~ main.c:114:62: error: request for member 'catid' in something not a structure or union 114 | curpt->catid = cmcatid; | ^~ main.c:115:62: error: request for member 'catleng' in something not a structure or union 115 | curpt->catleng = cmcatleng; | ^~ main.c:116:76: error: request for member 'iti' in something not a structure or union 116 | printf("%d\n",curpt->iti); | ^~ main.c:122:49: error: request for member 'nextcat' in something not a structure or union 122 | if(curpt->nextcat == NULL){ // ??????????????????????????£??? | ^~ main.c:123:82: error: request for member 'iti' in something not a structure or union 123 | if(cmcatleng <= (wallend - (curpt->iti + curpt->catleng))){ // ?¬?????????? | ^~ main.c:123:95: error: request for member 'catleng' in something not a structure or union 123 | if(cmcatleng <= (wallend - (curpt->iti + curpt->catleng))){ // ?¬?????????? | ^~ main.c:125:69: error: request for member 'catleng' in something not a structure or union 125 | curpt+=curpt->catleng; | ^~ main.c:126:61: error: request for member 'nextcat' in something not a structure or union 126 | bfpt->nextcat = curpt; | ^~ main.c:127:62: error: request for member 'catid' in something not a structure or union 127 | curpt->catid = cmcatid; | ^~ main.c:128:62: error: request for member 'catleng' in something not a structure or union 128 | curpt->catleng = cmcatleng; | ^~ main.c:129:76: error: request for member 'iti' in something not a structure or union 129 | printf("%d\n",curpt->iti); | ^~ main.c:139:71: error: request for member 'nextcat' in something not a structure or union 139 | if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti+curpt->catleng))){ | ^~ main.c:139:94: error: request for member 'iti' in something not a structure or union 139 | if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti+curpt->catleng))){ | ^~ main.c:139:105: error: request for member 'catleng' in something not a structure or union 139 | if(cmcatleng <= (curpt->nextcat->iti - (curpt->iti+curpt->catleng))){ | ^~ main.c:141:69: error: request for member 'nextcat' in something not a structure or union 141 | nxpt = curpt->nextcat; | ^~ main.c:142:69: error: request for member 'catleng' in something not a structure or union 142 | curpt+=curpt->catleng; | ^~ main.c:143:61: error: request for member 'nextcat' in something not a structure or union 143 | bfpt->nextcat = curpt; | ^~ main.c:144:62: error: request for member 'catid' in something not a structure or union 144 | curpt->catid = cmcatid; | ^~ main.c:145:62: error: request for member 'catleng' in something not a structure or union 145 | curpt->catleng = cmcatleng; | ^~ main.c:146:62: error: request for member 'nextcat' in something not a structure or union 146 | curpt->nextcat = nxpt; | ^~ main.c:147:76: error: request for member 'iti' in something not a structure or union 147 | printf("%d\n",curpt->iti); |
s131990149
p00621
C++
#include <iostream> using namespace std; #define REP(i,a,b) for(int i=a;i<(int)b;i++) #define rep(i,n) REP(i,0,n) int main() { int W, Q; while(cin >> W >> Q && (W|Q)) { int line[W]; memset(line, -1, sizeof line); rep(_, Q) { char ch; cin >> ch; if(ch == 's') { int id, w; cin >> id >> w; bool good = 0; rep(i, W-w+1) { if(line[i] == -1) { bool ok = 1; rep(j, w) if(line[i+j] != -1) { ok = 0; break; } if(ok) { rep(j, w) line[i+j] = id; cout << i << endl; good = 1; break; } } } if(!good) { cout << "impossible\n"; } } else { int id; cin >> id; rep(i, W) { for(int j=0; i+j<W && line[i+j] == id; j++) line[i+j] = -1; } } } cout << "END\n"; } return 0; }
a.cc: In function 'int main()': a.cc:13:5: error: 'memset' was not declared in this scope 13 | memset(line, -1, sizeof line); | ^~~~~~ 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 |
s696615117
p00621
C++
#include<stdio.h> #include<iostream> #include<string> #include<algorithm> using namespace std; int main(){ int W,Q;int x,w; string str; while(1){ int N[101]={}; for(int i=0;i<101;i++) N[i]=999; cin>>W>>Q;if(W==0&&Q==0)break; for(int i=0;i<Q;i++){ cin>>str; if(str=="s"){ cin>>x>>w;bool f=false; for(int I=0;I<W;I++){int L=0;if(f==true)break; for(int J=I;J<W;J++) if(N[J]==999){L++;if(L==w){f=true;cout<<I<<endl; for(int j=I;j<I+w;j++) N[j]=x; L=0;break; } } else{L=0;break;} } if(f==false)cout<<"impossible"<<endl; } else{ cin>>x; for(int I=0;I<101;I++) if(N[I]==x)N[I]=999; } //for(int I=0;I<W;I++) //cout<<N[I]<<endl; } cout<<END<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:45:15: error: 'END' was not declared in this scope 45 | cout<<END<<endl; | ^~~
s045951222
p00621
C++
// SleepingCats.cpp : ??????????????? ??¢????????±????????§????????¨????????? ????????????????????????????????? // #include "stdafx.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #ifdef _MSC_VER #include <intrin.h> #endif typedef struct _cat_inf{ char cat_id; char length; char pos; char dummy; } CAT_INF; typedef struct _wall_inf { CAT_INF cat_inf[100]; unsigned int wall_map[4]; } WALL_INF; #define DATFILE "input.txt" #define MAXBUF 4096 #define MAXBITCNT 32 #define SHIFTBITCNT 5 #define BITMASK (0xFFFFFFFF) static int count_bits(unsigned); static int local_ntz(unsigned); static int local_nlz(unsigned); static int ffstr(unsigned, int); static int judge_sleep(int, int, int, int, WALL_INF *); int _tmain(int argc, _TCHAR* argv[]) { FILE *fp = NULL; char Buf[MAXBUF]; char *tok = NULL; char *next_tok = NULL; int ic; int w_width, cat_width, lines, cat_id; char *err_str; int stat = 0; WALL_INF wall_inf; fopen_s(&fp,(char *)DATFILE, (char *)"r"); while (fgets(Buf, MAXBUF, fp) != NULL){ tok = strtok_s(Buf, " , ", &next_tok); w_width = strtol(tok, &err_str, 10); tok = strtok_s(NULL, " , ", &next_tok); lines = strtol(tok, &err_str, 10); if (w_width == 0 && lines == 0){ break; } memset(wall_inf.wall_map, 0xFF, sizeof(wall_inf.wall_map)); // ????????¢ memset(wall_inf.cat_inf, 0xFF, sizeof(wall_inf.cat_inf)); // ????????¢ for (ic = 0; ic < lines; ic++){ (void)fgets(Buf, MAXBUF, fp); tok = strtok_s(Buf, " , ", &next_tok); switch (*tok){ case 'S': case 's': tok = strtok_s(NULL, " , ", &next_tok); cat_id = strtol(tok, &err_str, 10); tok = strtok_s(NULL, " , ", &next_tok); cat_width = strtol(tok, &err_str, 10); stat = judge_sleep(0, cat_id, cat_width, w_width, &wall_inf); if (stat == -1){ fprintf(stdout, "impossible!\n"); } else{ fprintf(stdout, "%d\n", stat); } break; case 'W': case 'w': tok = strtok_s(NULL, " , ", &next_tok); cat_id = strtol(tok, &err_str, 10); stat = judge_sleep(1, cat_id, -1, w_width, &wall_inf); if (stat != 0){ // error! goto pgend; } break; } } fprintf(stdout, "END\n"); } pgend: if (fp != NULL){ fclose(fp); } return 0; } int judge_sleep(int opr,int cat_id,int cat_width, int w_width, WALL_INF *wall_infP) { unsigned int umask; unsigned int rsb, lsb, rmsk, lmsk; int ic,jc; int first_ary, last_ary,r; int set_bits; int ret = -1; first_ary = last_ary = r = -1; lsb = rsb = lmsk = rmsk = 0; switch (opr){ case 0: set_bits = cat_width; if (wall_infP->cat_inf[cat_id].cat_id != -1){ goto pgend; } for (ic = 0; ic < sizeof(wall_infP->wall_map) / sizeof(unsigned int); ic++){ if (set_bits < MAXBITCNT){ r = ffstr(wall_infP->wall_map[ic],set_bits); if (r < MAXBITCNT){ umask = (BITMASK) >> (MAXBITCNT - set_bits); umask = umask << (MAXBITCNT - set_bits - r); if (cat_width + ((ic*MAXBITCNT) + r) <= w_width){ wall_infP->wall_map[ic] ^= (umask); wall_infP->cat_inf[cat_id].cat_id = cat_id; wall_infP->cat_inf[cat_id].length = cat_width; wall_infP->cat_inf[cat_id].pos = (ic*MAXBITCNT) + r; break; } else{ goto pgend; } } else{ rsb = local_ntz(~(wall_infP->wall_map[ic])); if (rsb == 0){ /* ?????????????????\??????????????? */ continue; } lsb = local_nlz(~(wall_infP->wall_map[ic+1])); if ((rsb + lsb) >= set_bits){ lsb = set_bits - rsb; lmsk = BITMASK >> (MAXBITCNT - rsb); rmsk = BITMASK << (MAXBITCNT - lsb); if (cat_width + ((ic*MAXBITCNT) + (MAXBITCNT - rsb)) <= w_width){ wall_infP->wall_map[ic] ^= lmsk; wall_infP->wall_map[ic + 1] ^= rmsk; wall_infP->cat_inf[cat_id].cat_id = cat_id; wall_infP->cat_inf[cat_id].length = cat_width; wall_infP->cat_inf[cat_id].pos = (ic*MAXBITCNT) + (MAXBITCNT - rsb); break; } else{ goto pgend; } } } } else{ rsb = local_ntz(~(wall_infP->wall_map[ic])); lsb = local_nlz(~(wall_infP->wall_map[ic + 1])); if (first_ary == -1){ lmsk = (BITMASK >> (MAXBITCNT - rsb)); first_ary = ic; } if (rsb + lsb >= set_bits){ lsb = set_bits - rsb; last_ary = ic + 1; rmsk = BITMASK << (MAXBITCNT - lsb); if (cat_width + ((first_ary*MAXBITCNT) + (MAXBITCNT - rsb)) <= w_width){ wall_infP->wall_map[first_ary] ^= lmsk; wall_infP->wall_map[last_ary] ^= rmsk; for (jc = first_ary + 1; jc < last_ary; jc++){ wall_infP->wall_map[jc] = 0; } wall_infP->cat_inf[cat_id].cat_id = cat_id; wall_infP->cat_inf[cat_id].length = cat_width; wall_infP->cat_inf[cat_id].pos = (first_ary*MAXBITCNT) + (MAXBITCNT - rsb); break; } else{ goto pgend; } } if (lsb != MAXBITCNT || rsb == 0){ /* ???????????????????????\??????????????? */ set_bits = w_width; first_ary = -1; } else{ set_bits -= rsb; } } } if (wall_infP->cat_inf[cat_id].cat_id == -1){ // ???????????§?????? ret = -1; } else{ ret = wall_infP->cat_inf[cat_id].pos; } break; case 1: // ??????????±???¨?????????????±???? first_ary = wall_infP->cat_inf[cat_id].pos >> SHIFTBITCNT; lsb = wall_infP->cat_inf[cat_id].pos - (first_ary << SHIFTBITCNT); last_ary = (wall_infP->cat_inf[cat_id].pos + (wall_infP->cat_inf[cat_id].length - 1)) >> SHIFTBITCNT; if (first_ary == last_ary){ rsb = (BITMASK << (MAXBITCNT - wall_infP->cat_inf[cat_id].length)); wall_infP->wall_map[first_ary] |= (rsb >> lsb); } else{ rsb = (wall_infP->cat_inf[cat_id].pos + (wall_infP->cat_inf[cat_id].length - 1)) - (last_ary << SHIFTBITCNT); lmsk = BITMASK >> lsb; rmsk = BITMASK >> (rsb + 1); if (lmsk == 0){ lmsk = BITMASK; } if (rmsk == BITMASK){ rmsk = 0; } wall_infP->wall_map[first_ary] |= lmsk; wall_infP->wall_map[last_ary] |= ~rmsk;; for (ic = first_ary + 1; ic<last_ary; ic++){ wall_infP->wall_map[ic] = BITMASK; } } wall_infP->cat_inf[cat_id].cat_id = -1; wall_infP->cat_inf[cat_id].pos = -1; wall_infP->cat_inf[cat_id].length = 0; ret = 0; break; } pgend: return ret; } static int count_bits(unsigned bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff); } #define u 99 static int local_nlz(unsigned x) { static char table[64] = { 32, 31, u, 16, u, 30, 3, u, 15, u, u, u, 29, 10, 2, u, u, u, 12, 14, 21, u, 19, u, u, 28, u, 25, u, 9, 1, u, 17, u, 4, u, u, u, 11, u, 13, 22, 20, u, 26, u, u, 18, 5, u, u, 23, u, 27, u, 6, u, 24, 7, u, 8, u, 0, u }; x = x | (x >> 1); // Propagate leftmost x = x | (x >> 2); // 1-bit to the right. x = x | (x >> 4); x = x | (x >> 8); x = x | (x >> 16); x = x * 0x06EB14F9; // Multiplier is 7*255**3. return table[x >> 26]; } static int local_ntz(unsigned x) { if (x == 0) { return MAXBITCNT; } return(count_bits((~x)&(x - 1))); } static int ffstr(unsigned x, int n) { int s; while (n > 1) { s = n >> 1; x = x & (x << s); n = n - s; } return local_nlz(x); }
a.cc:4:10: fatal error: stdafx.h: No such file or directory 4 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s122299145
p00621
C++
// SleepingCats.cpp : ??????????????? ??¢????????±????????§????????¨????????? ????????????????????????????????? // #include "stdafx.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #ifdef _MSC_VER #include <intrin.h> #endif typedef struct _cat_inf{ char cat_id; char length; char pos; char dummy; } CAT_INF; typedef struct _wall_inf { CAT_INF cat_inf[100]; unsigned int wall_map[4]; } WALL_INF; #define DATFILE "input.txt" #define MAXBUF 4096 #define MAXBITCNT 32 #define SHIFTBITCNT 5 #define BITMASK (0xFFFFFFFF) static int count_bits(unsigned); static int local_ntz(unsigned); static int local_nlz(unsigned); static int ffstr(unsigned, int); static int judge_sleep(int, int, int, int, WALL_INF *); int _tmain(int argc, _TCHAR* argv[]) { FILE *fp = NULL; char Buf[MAXBUF]; char *tok = NULL; char *next_tok = NULL; int ic; int w_width, cat_width, lines, cat_id; char *err_str; int stat = 0; WALL_INF wall_inf; fopen_s(&fp,(char *)DATFILE, (char *)"r"); while (fgets(Buf, MAXBUF, fp) != NULL){ tok = strtok_s(Buf, " , ", &next_tok); w_width = strtol(tok, &err_str, 10); tok = strtok_s(NULL, " , ", &next_tok); lines = strtol(tok, &err_str, 10); if (w_width == 0 && lines == 0){ break; } memset(wall_inf.wall_map, 0xFF, sizeof(wall_inf.wall_map)); // ????????¢ memset(wall_inf.cat_inf, 0xFF, sizeof(wall_inf.cat_inf)); // ????????¢ for (ic = 0; ic < lines; ic++){ (void)fgets(Buf, MAXBUF, fp); tok = strtok_s(Buf, " , ", &next_tok); switch (*tok){ case 'S': case 's': tok = strtok_s(NULL, " , ", &next_tok); cat_id = strtol(tok, &err_str, 10); tok = strtok_s(NULL, " , ", &next_tok); cat_width = strtol(tok, &err_str, 10); stat = judge_sleep(0, cat_id, cat_width, w_width, &wall_inf); if (stat == -1){ fprintf(stdout, "impossible!\n"); } else{ fprintf(stdout, "%d\n", stat); } break; case 'W': case 'w': tok = strtok_s(NULL, " , ", &next_tok); cat_id = strtol(tok, &err_str, 10); stat = judge_sleep(1, cat_id, -1, w_width, &wall_inf); if (stat != 0){ // error! goto pgend; } break; } } fprintf(stdout, "END\n"); } pgend: if (fp != NULL){ fclose(fp); } return 0; } int judge_sleep(int opr,int cat_id,int cat_width, int w_width, WALL_INF *wall_infP) { unsigned int umask; unsigned int rsb, lsb, rmsk, lmsk; int ic,jc; int first_ary, last_ary,r; int set_bits; int ret = -1; first_ary = last_ary = r = -1; lsb = rsb = lmsk = rmsk = 0; switch (opr){ case 0: set_bits = cat_width; if (wall_infP->cat_inf[cat_id].cat_id != -1){ goto pgend; } for (ic = 0; ic < sizeof(wall_infP->wall_map) / sizeof(unsigned int); ic++){ if (set_bits < MAXBITCNT){ r = ffstr(wall_infP->wall_map[ic],set_bits); if (r < MAXBITCNT){ umask = (BITMASK) >> (MAXBITCNT - set_bits); umask = umask << (MAXBITCNT - set_bits - r); if (cat_width + ((ic*MAXBITCNT) + r) <= w_width){ wall_infP->wall_map[ic] ^= (umask); wall_infP->cat_inf[cat_id].cat_id = cat_id; wall_infP->cat_inf[cat_id].length = cat_width; wall_infP->cat_inf[cat_id].pos = (ic*MAXBITCNT) + r; break; } else{ goto pgend; } } else{ rsb = local_ntz(~(wall_infP->wall_map[ic])); if (rsb == 0){ /* ?????????????????\??????????????? */ continue; } lsb = local_nlz(~(wall_infP->wall_map[ic+1])); if ((rsb + lsb) >= set_bits){ lsb = set_bits - rsb; lmsk = BITMASK >> (MAXBITCNT - rsb); rmsk = BITMASK << (MAXBITCNT - lsb); if (cat_width + ((ic*MAXBITCNT) + (MAXBITCNT - rsb)) <= w_width){ wall_infP->wall_map[ic] ^= lmsk; wall_infP->wall_map[ic + 1] ^= rmsk; wall_infP->cat_inf[cat_id].cat_id = cat_id; wall_infP->cat_inf[cat_id].length = cat_width; wall_infP->cat_inf[cat_id].pos = (ic*MAXBITCNT) + (MAXBITCNT - rsb); break; } else{ goto pgend; } } } } else{ rsb = local_ntz(~(wall_infP->wall_map[ic])); lsb = local_nlz(~(wall_infP->wall_map[ic + 1])); if (first_ary == -1){ lmsk = (BITMASK >> (MAXBITCNT - rsb)); first_ary = ic; } if (rsb + lsb >= set_bits){ lsb = set_bits - rsb; last_ary = ic + 1; rmsk = BITMASK << (MAXBITCNT - lsb); if (cat_width + ((first_ary*MAXBITCNT) + (MAXBITCNT - rsb)) <= w_width){ wall_infP->wall_map[first_ary] ^= lmsk; wall_infP->wall_map[last_ary] ^= rmsk; for (jc = first_ary + 1; jc < last_ary; jc++){ wall_infP->wall_map[jc] = 0; } wall_infP->cat_inf[cat_id].cat_id = cat_id; wall_infP->cat_inf[cat_id].length = cat_width; wall_infP->cat_inf[cat_id].pos = (first_ary*MAXBITCNT) + (MAXBITCNT - rsb); break; } else{ goto pgend; } } if (lsb != MAXBITCNT || rsb == 0){ /* ???????????????????????\??????????????? */ set_bits = w_width; first_ary = -1; } else{ set_bits -= rsb; } } } if (wall_infP->cat_inf[cat_id].cat_id == -1){ // ???????????§?????? ret = -1; } else{ ret = wall_infP->cat_inf[cat_id].pos; } break; case 1: // ??????????±???¨?????????????±???? first_ary = wall_infP->cat_inf[cat_id].pos >> SHIFTBITCNT; lsb = wall_infP->cat_inf[cat_id].pos - (first_ary << SHIFTBITCNT); last_ary = (wall_infP->cat_inf[cat_id].pos + (wall_infP->cat_inf[cat_id].length - 1)) >> SHIFTBITCNT; if (first_ary == last_ary){ rsb = (BITMASK << (MAXBITCNT - wall_infP->cat_inf[cat_id].length)); wall_infP->wall_map[first_ary] |= (rsb >> lsb); } else{ rsb = (wall_infP->cat_inf[cat_id].pos + (wall_infP->cat_inf[cat_id].length - 1)) - (last_ary << SHIFTBITCNT); lmsk = BITMASK >> lsb; rmsk = BITMASK >> (rsb + 1); if (lmsk == 0){ lmsk = BITMASK; } if (rmsk == BITMASK){ rmsk = 0; } wall_infP->wall_map[first_ary] |= lmsk; wall_infP->wall_map[last_ary] |= ~rmsk;; for (ic = first_ary + 1; ic<last_ary; ic++){ wall_infP->wall_map[ic] = BITMASK; } } wall_infP->cat_inf[cat_id].cat_id = -1; wall_infP->cat_inf[cat_id].pos = -1; wall_infP->cat_inf[cat_id].length = 0; ret = 0; break; } pgend: return ret; } static int count_bits(unsigned bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff); } #define u 99 static int local_nlz(unsigned x) { static char table[64] = { 32, 31, u, 16, u, 30, 3, u, 15, u, u, u, 29, 10, 2, u, u, u, 12, 14, 21, u, 19, u, u, 28, u, 25, u, 9, 1, u, 17, u, 4, u, u, u, 11, u, 13, 22, 20, u, 26, u, u, 18, 5, u, u, 23, u, 27, u, 6, u, 24, 7, u, 8, u, 0, u }; x = x | (x >> 1); // Propagate leftmost x = x | (x >> 2); // 1-bit to the right. x = x | (x >> 4); x = x | (x >> 8); x = x | (x >> 16); x = x * 0x06EB14F9; // Multiplier is 7*255**3. return table[x >> 26]; } static int local_ntz(unsigned x) { if (x == 0) { return MAXBITCNT; } return(count_bits((~x)&(x - 1))); } static int ffstr(unsigned x, int n) { int s; while (n > 1) { s = n >> 1; x = x & (x << s); n = n - s; } return local_nlz(x); }
a.cc:4:10: fatal error: stdafx.h: No such file or directory 4 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s660557234
p00621
C++
// SleepingCats.cpp : コンソール アプリケーションのエントリ ポイントを定義します。 // #include "stdafx.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #ifdef _MSC_VER #include <intrin.h> #endif typedef struct _cat_inf{ char cat_id; char length; char pos; char dummy; } CAT_INF; typedef struct _wall_inf { CAT_INF cat_inf[100]; unsigned int wall_map[4]; } WALL_INF; #define DATFILE "input.txt" #define MAXBUF 4096 #define MAXBITCNT 32 #define SHIFTBITCNT 5 #define BITMASK (0xFFFFFFFF) static int count_bits(unsigned); static int local_ntz(unsigned); static int local_nlz(unsigned); static int ffstr(unsigned, int); static int judge_sleep(int, int, int, int, WALL_INF *); int _tmain(int argc, _TCHAR* argv[]) { FILE *fp = NULL; char Buf[MAXBUF]; char *tok = NULL; char *next_tok = NULL; int ic; int w_width, cat_width, lines, cat_id; char *err_str; int stat = 0; WALL_INF wall_inf; fopen_s(&fp,(char *)DATFILE, (char *)"r"); while (fgets(Buf, MAXBUF, fp) != NULL){ tok = strtok_s(Buf, " , ", &next_tok); w_width = strtol(tok, &err_str, 10); tok = strtok_s(NULL, " , ", &next_tok); lines = strtol(tok, &err_str, 10); if (w_width == 0 && lines == 0){ break; } memset(wall_inf.wall_map, 0xFF, sizeof(wall_inf.wall_map)); // クリア memset(wall_inf.cat_inf, 0xFF, sizeof(wall_inf.cat_inf)); // クリア for (ic = 0; ic < lines; ic++){ (void)fgets(Buf, MAXBUF, fp); tok = strtok_s(Buf, " , ", &next_tok); switch (*tok){ case 'S': case 's': tok = strtok_s(NULL, " , ", &next_tok); cat_id = strtol(tok, &err_str, 10); tok = strtok_s(NULL, " , ", &next_tok); cat_width = strtol(tok, &err_str, 10); stat = judge_sleep(0, cat_id, cat_width, w_width, &wall_inf); if (stat == -1){ fprintf(stdout, "impossible!\n"); } else{ fprintf(stdout, "%d\n", stat); } break; case 'W': case 'w': tok = strtok_s(NULL, " , ", &next_tok); cat_id = strtol(tok, &err_str, 10); stat = judge_sleep(1, cat_id, -1, w_width, &wall_inf); if (stat != 0){ // error! goto pgend; } break; } } fprintf(stdout, "END\n"); } pgend: if (fp != NULL){ fclose(fp); } return 0; } int judge_sleep(int opr,int cat_id,int cat_width, int w_width, WALL_INF *wall_infP) { unsigned int umask; unsigned int rsb, lsb, rmsk, lmsk; int ic,jc; int first_ary, last_ary,r; int set_bits; int ret = -1; first_ary = last_ary = r = -1; lsb = rsb = lmsk = rmsk = 0; switch (opr){ case 0: set_bits = cat_width; if (wall_infP->cat_inf[cat_id].cat_id != -1){ goto pgend; } for (ic = 0; ic < sizeof(wall_infP->wall_map) / sizeof(unsigned int); ic++){ if (set_bits < MAXBITCNT){ r = ffstr(wall_infP->wall_map[ic],set_bits); if (r < MAXBITCNT){ umask = (BITMASK) >> (MAXBITCNT - set_bits); umask = umask << (MAXBITCNT - set_bits - r); if (cat_width + ((ic*MAXBITCNT) + r) <= w_width){ wall_infP->wall_map[ic] ^= (umask); wall_infP->cat_inf[cat_id].cat_id = cat_id; wall_infP->cat_inf[cat_id].length = cat_width; wall_infP->cat_inf[cat_id].pos = (ic*MAXBITCNT) + r; break; } else{ goto pgend; } } else{ rsb = local_ntz(~(wall_infP->wall_map[ic])); if (rsb == 0){ /* ここからは入れられない */ continue; } lsb = local_nlz(~(wall_infP->wall_map[ic+1])); if ((rsb + lsb) >= set_bits){ lsb = set_bits - rsb; lmsk = BITMASK >> (MAXBITCNT - rsb); rmsk = BITMASK << (MAXBITCNT - lsb); if (cat_width + ((ic*MAXBITCNT) + (MAXBITCNT - rsb)) <= w_width){ wall_infP->wall_map[ic] ^= lmsk; wall_infP->wall_map[ic + 1] ^= rmsk; wall_infP->cat_inf[cat_id].cat_id = cat_id; wall_infP->cat_inf[cat_id].length = cat_width; wall_infP->cat_inf[cat_id].pos = (ic*MAXBITCNT) + (MAXBITCNT - rsb); break; } else{ goto pgend; } } } } else{ rsb = local_ntz(~(wall_infP->wall_map[ic])); lsb = local_nlz(~(wall_infP->wall_map[ic + 1])); if (first_ary == -1){ lmsk = (BITMASK >> (MAXBITCNT - rsb)); first_ary = ic; } if (rsb + lsb >= set_bits){ lsb = set_bits - rsb; last_ary = ic + 1; rmsk = BITMASK << (MAXBITCNT - lsb); if (cat_width + ((first_ary*MAXBITCNT) + (MAXBITCNT - rsb)) <= w_width){ wall_infP->wall_map[first_ary] ^= lmsk; wall_infP->wall_map[last_ary] ^= rmsk; for (jc = first_ary + 1; jc < last_ary; jc++){ wall_infP->wall_map[jc] = 0; } wall_infP->cat_inf[cat_id].cat_id = cat_id; wall_infP->cat_inf[cat_id].length = cat_width; wall_infP->cat_inf[cat_id].pos = (first_ary*MAXBITCNT) + (MAXBITCNT - rsb); break; } else{ goto pgend; } } if (lsb != MAXBITCNT || rsb == 0){ /* この位置からは入れられない */ set_bits = w_width; first_ary = -1; } else{ set_bits -= rsb; } } } if (wall_infP->cat_inf[cat_id].cat_id == -1){ // セットできず ret = -1; } else{ ret = wall_infP->cat_inf[cat_id].pos; } break; case 1: // 削除対象エントリを決定 first_ary = wall_infP->cat_inf[cat_id].pos >> SHIFTBITCNT; lsb = wall_infP->cat_inf[cat_id].pos - (first_ary << SHIFTBITCNT); last_ary = (wall_infP->cat_inf[cat_id].pos + (wall_infP->cat_inf[cat_id].length - 1)) >> SHIFTBITCNT; if (first_ary == last_ary){ rsb = (BITMASK << (MAXBITCNT - wall_infP->cat_inf[cat_id].length)); wall_infP->wall_map[first_ary] |= (rsb >> lsb); } else{ rsb = (wall_infP->cat_inf[cat_id].pos + (wall_infP->cat_inf[cat_id].length - 1)) - (last_ary << SHIFTBITCNT); lmsk = BITMASK >> lsb; rmsk = BITMASK >> (rsb + 1); if (lmsk == 0){ lmsk = BITMASK; } if (rmsk == BITMASK){ rmsk = 0; } wall_infP->wall_map[first_ary] |= lmsk; wall_infP->wall_map[last_ary] |= ~rmsk;; for (ic = first_ary + 1; ic<last_ary; ic++){ wall_infP->wall_map[ic] = BITMASK; } } wall_infP->cat_inf[cat_id].cat_id = -1; wall_infP->cat_inf[cat_id].pos = -1; wall_infP->cat_inf[cat_id].length = 0; ret = 0; break; } pgend: return ret; } static int count_bits(unsigned bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff); } #define u 99 static int local_nlz(unsigned x) { static char table[64] = { 32, 31, u, 16, u, 30, 3, u, 15, u, u, u, 29, 10, 2, u, u, u, 12, 14, 21, u, 19, u, u, 28, u, 25, u, 9, 1, u, 17, u, 4, u, u, u, 11, u, 13, 22, 20, u, 26, u, u, 18, 5, u, u, 23, u, 27, u, 6, u, 24, 7, u, 8, u, 0, u }; x = x | (x >> 1); // Propagate leftmost x = x | (x >> 2); // 1-bit to the right. x = x | (x >> 4); x = x | (x >> 8); x = x | (x >> 16); x = x * 0x06EB14F9; // Multiplier is 7*255**3. return table[x >> 26]; } static int local_ntz(unsigned x) { if (x == 0) { return MAXBITCNT; } return(count_bits((~x)&(x - 1))); } static int ffstr(unsigned x, int n) { int s; while (n > 1) { s = n >> 1; x = x & (x << s); n = n - s; } return local_nlz(x); }
a.cc:4:10: fatal error: stdafx.h: No such file or directory 4 | #include "stdafx.h" | ^~~~~~~~~~ compilation terminated.
s952950221
p00621
C++
// SleepingCats.cpp : ??????????????? ??¢????????±????????§????????¨????????? ????????????????????????????????? // #include <stdio.h> #include <stdlib.h> #include <string.h> #ifdef _MSC_VER #include <intrin.h> #endif typedef struct _cat_inf{ char cat_id; char length; char pos; char dummy; } CAT_INF; typedef struct _wall_inf { CAT_INF cat_inf[100]; unsigned int wall_map[4]; } WALL_INF; #define DATFILE "input.txt" #define MAXBUF 4096 #define MAXBITCNT 32 #define SHIFTBITCNT 5 #define BITMASK (0xFFFFFFFF) static int count_bits(unsigned); static int local_ntz(unsigned); static int local_nlz(unsigned); static int ffstr(unsigned, int); static int judge_sleep(int, int, int, int, WALL_INF *); int _tmain(int argc, _TCHAR* argv[]) { FILE *fp = NULL; char Buf[MAXBUF]; char *tok = NULL; char *next_tok = NULL; int ic; int w_width, cat_width, lines, cat_id; char *err_str; int stat = 0; WALL_INF wall_inf; fopen_s(&fp,(char *)DATFILE, (char *)"r"); while (fgets(Buf, MAXBUF, fp) != NULL){ tok = strtok_s(Buf, " , ", &next_tok); w_width = strtol(tok, &err_str, 10); tok = strtok_s(NULL, " , ", &next_tok); lines = strtol(tok, &err_str, 10); if (w_width == 0 && lines == 0){ break; } memset(wall_inf.wall_map, 0xFF, sizeof(wall_inf.wall_map)); // ????????¢ memset(wall_inf.cat_inf, 0xFF, sizeof(wall_inf.cat_inf)); // ????????¢ for (ic = 0; ic < lines; ic++){ (void)fgets(Buf, MAXBUF, fp); tok = strtok_s(Buf, " , ", &next_tok); switch (*tok){ case 'S': case 's': tok = strtok_s(NULL, " , ", &next_tok); cat_id = strtol(tok, &err_str, 10); tok = strtok_s(NULL, " , ", &next_tok); cat_width = strtol(tok, &err_str, 10); stat = judge_sleep(0, cat_id, cat_width, w_width, &wall_inf); if (stat == -1){ fprintf(stdout, "impossible!\n"); } else{ fprintf(stdout, "%d\n", stat); } break; case 'W': case 'w': tok = strtok_s(NULL, " , ", &next_tok); cat_id = strtol(tok, &err_str, 10); stat = judge_sleep(1, cat_id, -1, w_width, &wall_inf); if (stat != 0){ // error! goto pgend; } break; } } fprintf(stdout, "END\n"); } pgend: if (fp != NULL){ fclose(fp); } return 0; } int judge_sleep(int opr,int cat_id,int cat_width, int w_width, WALL_INF *wall_infP) { unsigned int umask; unsigned int rsb, lsb, rmsk, lmsk; int ic,jc; int first_ary, last_ary,r; int set_bits; int ret = -1; first_ary = last_ary = r = -1; lsb = rsb = lmsk = rmsk = 0; switch (opr){ case 0: set_bits = cat_width; if (wall_infP->cat_inf[cat_id].cat_id != -1){ goto pgend; } for (ic = 0; ic < sizeof(wall_infP->wall_map) / sizeof(unsigned int); ic++){ if (set_bits < MAXBITCNT){ r = ffstr(wall_infP->wall_map[ic],set_bits); if (r < MAXBITCNT){ umask = (BITMASK) >> (MAXBITCNT - set_bits); umask = umask << (MAXBITCNT - set_bits - r); if (cat_width + ((ic*MAXBITCNT) + r) <= w_width){ wall_infP->wall_map[ic] ^= (umask); wall_infP->cat_inf[cat_id].cat_id = cat_id; wall_infP->cat_inf[cat_id].length = cat_width; wall_infP->cat_inf[cat_id].pos = (ic*MAXBITCNT) + r; break; } else{ goto pgend; } } else{ rsb = local_ntz(~(wall_infP->wall_map[ic])); if (rsb == 0){ /* ?????????????????\??????????????? */ continue; } lsb = local_nlz(~(wall_infP->wall_map[ic+1])); if ((rsb + lsb) >= set_bits){ lsb = set_bits - rsb; lmsk = BITMASK >> (MAXBITCNT - rsb); rmsk = BITMASK << (MAXBITCNT - lsb); if (cat_width + ((ic*MAXBITCNT) + (MAXBITCNT - rsb)) <= w_width){ wall_infP->wall_map[ic] ^= lmsk; wall_infP->wall_map[ic + 1] ^= rmsk; wall_infP->cat_inf[cat_id].cat_id = cat_id; wall_infP->cat_inf[cat_id].length = cat_width; wall_infP->cat_inf[cat_id].pos = (ic*MAXBITCNT) + (MAXBITCNT - rsb); break; } else{ goto pgend; } } } } else{ rsb = local_ntz(~(wall_infP->wall_map[ic])); lsb = local_nlz(~(wall_infP->wall_map[ic + 1])); if (first_ary == -1){ lmsk = (BITMASK >> (MAXBITCNT - rsb)); first_ary = ic; } if (rsb + lsb >= set_bits){ lsb = set_bits - rsb; last_ary = ic + 1; rmsk = BITMASK << (MAXBITCNT - lsb); if (cat_width + ((first_ary*MAXBITCNT) + (MAXBITCNT - rsb)) <= w_width){ wall_infP->wall_map[first_ary] ^= lmsk; wall_infP->wall_map[last_ary] ^= rmsk; for (jc = first_ary + 1; jc < last_ary; jc++){ wall_infP->wall_map[jc] = 0; } wall_infP->cat_inf[cat_id].cat_id = cat_id; wall_infP->cat_inf[cat_id].length = cat_width; wall_infP->cat_inf[cat_id].pos = (first_ary*MAXBITCNT) + (MAXBITCNT - rsb); break; } else{ goto pgend; } } if (lsb != MAXBITCNT || rsb == 0){ /* ???????????????????????\??????????????? */ set_bits = w_width; first_ary = -1; } else{ set_bits -= rsb; } } } if (wall_infP->cat_inf[cat_id].cat_id == -1){ // ???????????§?????? ret = -1; } else{ ret = wall_infP->cat_inf[cat_id].pos; } break; case 1: // ??????????±???¨?????????????±???? first_ary = wall_infP->cat_inf[cat_id].pos >> SHIFTBITCNT; lsb = wall_infP->cat_inf[cat_id].pos - (first_ary << SHIFTBITCNT); last_ary = (wall_infP->cat_inf[cat_id].pos + (wall_infP->cat_inf[cat_id].length - 1)) >> SHIFTBITCNT; if (first_ary == last_ary){ rsb = (BITMASK << (MAXBITCNT - wall_infP->cat_inf[cat_id].length)); wall_infP->wall_map[first_ary] |= (rsb >> lsb); } else{ rsb = (wall_infP->cat_inf[cat_id].pos + (wall_infP->cat_inf[cat_id].length - 1)) - (last_ary << SHIFTBITCNT); lmsk = BITMASK >> lsb; rmsk = BITMASK >> (rsb + 1); if (lmsk == 0){ lmsk = BITMASK; } if (rmsk == BITMASK){ rmsk = 0; } wall_infP->wall_map[first_ary] |= lmsk; wall_infP->wall_map[last_ary] |= ~rmsk;; for (ic = first_ary + 1; ic<last_ary; ic++){ wall_infP->wall_map[ic] = BITMASK; } } wall_infP->cat_inf[cat_id].cat_id = -1; wall_infP->cat_inf[cat_id].pos = -1; wall_infP->cat_inf[cat_id].length = 0; ret = 0; break; } pgend: return ret; } static int count_bits(unsigned bits) { bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555); bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333); bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f); bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff); return (bits & 0x0000ffff) + (bits >> 16 & 0x0000ffff); } #define u 99 static int local_nlz(unsigned x) { static char table[64] = { 32, 31, u, 16, u, 30, 3, u, 15, u, u, u, 29, 10, 2, u, u, u, 12, 14, 21, u, 19, u, u, 28, u, 25, u, 9, 1, u, 17, u, 4, u, u, u, 11, u, 13, 22, 20, u, 26, u, u, 18, 5, u, u, 23, u, 27, u, 6, u, 24, 7, u, 8, u, 0, u }; x = x | (x >> 1); // Propagate leftmost x = x | (x >> 2); // 1-bit to the right. x = x | (x >> 4); x = x | (x >> 8); x = x | (x >> 16); x = x * 0x06EB14F9; // Multiplier is 7*255**3. return table[x >> 26]; } static int local_ntz(unsigned x) { if (x == 0) { return MAXBITCNT; } return(count_bits((~x)&(x - 1))); } static int ffstr(unsigned x, int n) { int s; while (n > 1) { s = n >> 1; x = x & (x << s); n = n - s; } return local_nlz(x); }
a.cc:33:22: error: '_TCHAR' has not been declared 33 | int _tmain(int argc, _TCHAR* argv[]) | ^~~~~~ a.cc: In function 'int _tmain(int, int**)': a.cc:46:9: error: 'fopen_s' was not declared in this scope; did you mean 'fopen64'? 46 | fopen_s(&fp,(char *)DATFILE, (char *)"r"); | ^~~~~~~ | fopen64 a.cc:49:23: error: 'strtok_s' was not declared in this scope; did you mean 'strtok_r'? 49 | tok = strtok_s(Buf, " , ", &next_tok); | ^~~~~~~~ | strtok_r
s757436883
p00621
C++
#include<iostream> using namespace std; int x[1000],n,q,a,b; int y[1000][2]; char c; int main(){ while(true){ for(int i=0;i<1000;i++){x[i]=0;y[i][0]=0;y[i][1]=0;} cin>>n>>q; if(n==0 && q==0){break;} for(int i=0;i<q;i++){ cin>>c>>a>>b; if(c=='s'){ for(int j=0;j<=a-b;j++){ int t=b; for(int k=j;k<j+b;k++){ if(x[k]==0){ t--; } } if(t==0){ cout<<j<<endl; for(int k=j;k<j+b;k++){ x[k]=1; } y[a][0]=j;x[a][1]=j+b; goto E; } } cout<<"impossible"<<endl; E:; } if(c=='w'){ for(int j=y[a][0];j<y[a][1];j++){ x[j]=0; } y[a][0]=0;y[a][1]=0; } } cout<<"END"<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:28:63: error: invalid types 'int[int]' for array subscript 28 | y[a][0]=j;x[a][1]=j+b; | ^
s353285361
p00621
C++
#include<iostream> #include<string> #include<cstdio> #define P pair<int,string> using namespace std; int main() { int a, b; while (cin >> b>>a, a | b) { int c[100]{}; for (int d = 0; d < a; d++) { char e; cin >> e; if (e == 's') { int f, g; cin >> f >> g; f++; int s = 0; for (int i = 0; i < b; i++) { if (c[i] == 0) { s++; if (s >= g) { cout << i - s + 1 << endl; for (int o = i-s+1; o <= i; o++)c[o] = f; break; } } else s = 0; if (b - 1 == i)puts("impossible"); } } else { int f; cin >> f; f++; for (int i = 0; i < b; i++) { if (c[i] == f)c[i] = 0; } } } puts("END"); }
a.cc: In function 'int main()': a.cc:38:2: error: expected '}' at end of input 38 | } | ^ a.cc:8:1: note: to match this '{' 8 | { | ^
s192612624
p00621
C++
#include<bits/stdc++.h> #define P pair<int,string> using namespace std; int main() { int a, b; while (cin >> b>>a, a | b) { int c[100]{}; for (int d = 0; d < a; d++) { char e; cin >> e; if (e == 's') { int f, g; cin >> f >> g; f++; int s = 0; for (int i = 0; i < b; i++) { if (c[i] == 0) { s++; if (s >= g) { cout << i - s + 1 << endl; for (int o = i-s+1; o <= i; o++)c[o] = f; break; } } else s = 0; if (b - 1 == i)puts("impossible"); } } else { int f; cin >> f; f++; for (int i = 0; i < b; i++) { if (c[i] == f)c[i] = 0; } } } puts("END"); }
a.cc: In function 'int main()': a.cc:36:2: error: expected '}' at end of input 36 | } | ^ a.cc:6:1: note: to match this '{' 6 | { | ^
s889247892
p00621
C++
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s174478091
p00621
C++
#include<iostream> #include<cstdlib> using namespace std; int main(){ int w,n,s[100],sp,x,y; char c; while(cin>>w>>n,w||n){ memset(s,-1,sizeof(s)); for(int i=0;i<n;i++){ cin>>c; if(c=='w'){ cin>>x; for(int j=0;j<w;j++){ if(s[j]==x) s[j]=-1; } }else{ int j,k; cin>>x>>y; for(j=0;j<w;j++){ if(s[j]==-1){ for(k=j;k<w;k++){ if(-1!=s[k]){ break; } } sp=k-j; if(sp>=y){ cout<<j<<endl; for(int h=j;h<y+j;h++) s[h]=x; break; } } } if(j==w) cout<<"impossible"<<endl; } } cout<<"END"<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:8:17: error: 'memset' was not declared in this scope 8 | memset(s,-1,sizeof(s)); | ^~~~~~ a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 2 | #include<cstdlib> +++ |+#include <cstring> 3 | using namespace std;
s737443575
p00621
C++
#include <cstdio> #include <vector> #define R second.second using namespace std; typedef vector<pair<int,pair<int,int> > >vpp; int main(){ int W,Q,d,w; char s[2]; for(;scanf("%d%d",&W,&Q),W;){ //some case Q==0. vpp v; v.push_back(make_pair(-2,make_pair(0,0))); v.push_back(make_pair(-1,make_pair(W,0))); for(;Q;Q--){ scanf("%s",s); if(*s=='w'){ scanf("%d",&d); for(int i=0;i<v.size();i++)if(v[i].first==d){v.erase(v.begin()+i);break;} }else{ scanf("%d%d",&d,&w); for(int i=0;~v[i].first;i++){ if(v[i+1].second.first-v[i].R>=w){ v.insert(v.begin()+i+1,make_pair(d,make_pair(v[i].R,v[i].R+w))); printf("%d\n",v[i].R);break; } } if(v[i].first==-1)puts("impossible"); } } puts("END"); } }
a.cc: In function 'int main()': a.cc:27:38: error: 'i' was not declared in this scope 27 | if(v[i].first==-1)puts("impossible"); | ^
s577443091
p00621
C++
#include <cstdio> #include <vector> #define R second.second #define Z(i,a,b,c)v.insert(v.begin()+i,make_pair(a,make_pair(b,c))) using namespace std; main(){ int W,Q,d,w,i;char s[2]; for(;scanf("%d%d",&W,&Q),W;puts("END"))//some case Q==0 for(vector<pair<int,pair<int,int> > >v,Z(0,-2,0,0),Z(1,-1,W,0);Q;Q--) if(scanf("%s",s),*s-'w'){ for(scanf("%d%d",&d,&w),i=0;~v[i].first;i++)if(v[i+1].second.first-v[i].R>=w){Z(i+1,d,v[i].R,v[i].R+w);printf("%d\n",v[i].R);break;} if(v[i].first==-1)puts("impossible"); }else for(scanf("%d",&d),i=0;i<v.size();i++)if(v[i].first==d){v.erase(v.begin()+i);break;} }
a.cc:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:4:20: error: expected ';' before '.' token 4 | #define Z(i,a,b,c)v.insert(v.begin()+i,make_pair(a,make_pair(b,c))) | ^ a.cc:9:56: note: in expansion of macro 'Z' 9 | for(vector<pair<int,pair<int,int> > >v,Z(0,-2,0,0),Z(1,-1,W,0);Q;Q--) | ^ a.cc:4:20: error: expected primary-expression before '.' token 4 | #define Z(i,a,b,c)v.insert(v.begin()+i,make_pair(a,make_pair(b,c))) | ^ a.cc:9:56: note: in expansion of macro 'Z' 9 | for(vector<pair<int,pair<int,int> > >v,Z(0,-2,0,0),Z(1,-1,W,0);Q;Q--) | ^ a.cc:9:81: error: expected ')' before ';' token 9 | for(vector<pair<int,pair<int,int> > >v,Z(0,-2,0,0),Z(1,-1,W,0);Q;Q--) | ~ ^ | ) a.cc:9:85: error: expected ';' before ')' token 9 | for(vector<pair<int,pair<int,int> > >v,Z(0,-2,0,0),Z(1,-1,W,0);Q;Q--) | ^ | ; a.cc:13:26: error: 'else' without a previous 'if' 13 | }else for(scanf("%d",&d),i=0;i<v.size();i++)if(v[i].first==d){v.erase(v.begin()+i);break;} | ^~~~ a.cc:13:56: error: 'v' was not declared in this scope 13 | }else for(scanf("%d",&d),i=0;i<v.size();i++)if(v[i].first==d){v.erase(v.begin()+i);break;} | ^
s531329633
p00622
C
char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);)if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}exit(0);}
main.c:1:24: error: return type defaults to 'int' [-Wimplicit-int] 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);)if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}exit(0);} | ^~~~ main.c: In function 'main': main.c:1:24: error: type of 'c' defaults to 'int' [-Wimplicit-int] main.c:1:24: error: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:1:24: error: type of 'j' defaults to 'int' [-Wimplicit-int] main.c:1:24: error: type of 'k' defaults to 'int' [-Wimplicit-int] main.c:1:43: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);)if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}exit(0);} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);)if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}exit(0);} main.c:1:43: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);)if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}exit(0);} | ^~~~~ main.c:1:43: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:67: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration] 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);)if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}exit(0);} | ^~~~ main.c:1:67: note: include '<stdio.h>' or provide a declaration of 'puts' main.c:1:102: error: implicit declaration of function 'strlen' [-Wimplicit-function-declaration] 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);)if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}exit(0);} | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'strlen' +++ |+#include <string.h> 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);)if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}exit(0);} main.c:1:102: warning: incompatible implicit declaration of built-in function 'strlen' [-Wbuiltin-declaration-mismatch] 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);)if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}exit(0);} | ^~~~~~ main.c:1:102: note: include '<string.h>' or provide a declaration of 'strlen' main.c:1:152: error: implicit declaration of function 'putchar' [-Wimplicit-function-declaration] 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);)if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}exit(0);} | ^~~~~~~ main.c:1:152: note: include '<stdio.h>' or provide a declaration of 'putchar' main.c: At top level: main.c:1:178: error: expected declaration specifiers or '...' before numeric constant 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);)if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}exit(0);} | ^ main.c:1:181: error: expected identifier or '(' before '}' token 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);)if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}exit(0);} | ^
s832916796
p00622
C
char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);){if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}}exit(0);}
main.c:1:24: error: return type defaults to 'int' [-Wimplicit-int] 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);){if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}}exit(0);} | ^~~~ main.c: In function 'main': main.c:1:24: error: type of 'c' defaults to 'int' [-Wimplicit-int] main.c:1:24: error: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:1:24: error: type of 'j' defaults to 'int' [-Wimplicit-int] main.c:1:24: error: type of 'k' defaults to 'int' [-Wimplicit-int] main.c:1:43: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);){if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}}exit(0);} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);){if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}}exit(0);} main.c:1:43: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);){if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}}exit(0);} | ^~~~~ main.c:1:43: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:67: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration] 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);){if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}}exit(0);} | ^~~~ main.c:1:67: note: include '<stdio.h>' or provide a declaration of 'puts' main.c:1:102: error: implicit declaration of function 'strlen' [-Wimplicit-function-declaration] 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);){if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}}exit(0);} | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'strlen' +++ |+#include <string.h> 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);){if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}}exit(0);} main.c:1:102: warning: incompatible implicit declaration of built-in function 'strlen' [-Wbuiltin-declaration-mismatch] 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);){if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}}exit(0);} | ^~~~~~ main.c:1:102: note: include '<string.h>' or provide a declaration of 'strlen' main.c:1:153: error: implicit declaration of function 'putchar' [-Wimplicit-function-declaration] 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);){if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}}exit(0);} | ^~~~~~~ main.c:1:153: note: include '<stdio.h>' or provide a declaration of 'putchar' main.c: At top level: main.c:1:180: error: expected declaration specifiers or '...' before numeric constant 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);){if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}}exit(0);} | ^ main.c:1:183: error: expected identifier or '(' before '}' token 1 | char r[99],g[99],d[99];main(c,i,j,k){for(;scanf("%s%s%s",r,g,d)>2;puts(""))for(i=j=k=0,c=g[j++];i+j<=strlen(r)+strlen(g);){if(c==d[k])k++,c=r[i++];else putchar(c),c=g[j++];}}exit(0);} | ^
s240384036
p00622
C
char r[99],g[99],*G,d[99];main(c,i,k){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,c=*(G=g)++;*(G-1);)c=c==d[k]?k++,r[i++]:(putchar(c),*G++);exit(0);}
main.c:1:27: error: return type defaults to 'int' [-Wimplicit-int] 1 | char r[99],g[99],*G,d[99];main(c,i,k){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,c=*(G=g)++;*(G-1);)c=c==d[k]?k++,r[i++]:(putchar(c),*G++);exit(0);} | ^~~~ main.c: In function 'main': main.c:1:27: error: type of 'c' defaults to 'int' [-Wimplicit-int] main.c:1:27: error: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:1:27: error: type of 'k' defaults to 'int' [-Wimplicit-int] main.c:1:44: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | char r[99],g[99],*G,d[99];main(c,i,k){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,c=*(G=g)++;*(G-1);)c=c==d[k]?k++,r[i++]:(putchar(c),*G++);exit(0);} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | char r[99],g[99],*G,d[99];main(c,i,k){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,c=*(G=g)++;*(G-1);)c=c==d[k]?k++,r[i++]:(putchar(c),*G++);exit(0);} main.c:1:44: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | char r[99],g[99],*G,d[99];main(c,i,k){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,c=*(G=g)++;*(G-1);)c=c==d[k]?k++,r[i++]:(putchar(c),*G++);exit(0);} | ^~~~~ main.c:1:44: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:68: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration] 1 | char r[99],g[99],*G,d[99];main(c,i,k){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,c=*(G=g)++;*(G-1);)c=c==d[k]?k++,r[i++]:(putchar(c),*G++);exit(0);} | ^~~~ main.c:1:68: note: include '<stdio.h>' or provide a declaration of 'puts' main.c:1:94: error: lvalue required as increment operand 1 | char r[99],g[99],*G,d[99];main(c,i,k){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,c=*(G=g)++;*(G-1);)c=c==d[k]?k++,r[i++]:(putchar(c),*G++);exit(0);} | ^~ main.c:1:127: error: implicit declaration of function 'putchar' [-Wimplicit-function-declaration] 1 | char r[99],g[99],*G,d[99];main(c,i,k){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,c=*(G=g)++;*(G-1);)c=c==d[k]?k++,r[i++]:(putchar(c),*G++);exit(0);} | ^~~~~~~ main.c:1:127: note: include '<stdio.h>' or provide a declaration of 'putchar' main.c:1:144: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration] 1 | char r[99],g[99],*G,d[99];main(c,i,k){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,c=*(G=g)++;*(G-1);)c=c==d[k]?k++,r[i++]:(putchar(c),*G++);exit(0);} | ^~~~ main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit' +++ |+#include <stdlib.h> 1 | char r[99],g[99],*G,d[99];main(c,i,k){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,c=*(G=g)++;*(G-1);)c=c==d[k]?k++,r[i++]:(putchar(c),*G++);exit(0);} main.c:1:144: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch] 1 | char r[99],g[99],*G,d[99];main(c,i,k){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,c=*(G=g)++;*(G-1);)c=c==d[k]?k++,r[i++]:(putchar(c),*G++);exit(0);} | ^~~~ main.c:1:144: note: include '<stdlib.h>' or provide a declaration of 'exit'
s973168742
p00622
C
char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,G=g,c=*G++;*(G-1);)c=c==d[i]?r[i++]:(putchar(c),*G++);exit(0);}
main.c:1:27: error: return type defaults to 'int' [-Wimplicit-int] 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,G=g,c=*G++;*(G-1);)c=c==d[i]?r[i++]:(putchar(c),*G++);exit(0);} | ^~~~ main.c: In function 'main': main.c:1:27: error: type of 'c' defaults to 'int' [-Wimplicit-int] main.c:1:27: error: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:1:42: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,G=g,c=*G++;*(G-1);)c=c==d[i]?r[i++]:(putchar(c),*G++);exit(0);} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,G=g,c=*G++;*(G-1);)c=c==d[i]?r[i++]:(putchar(c),*G++);exit(0);} main.c:1:42: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,G=g,c=*G++;*(G-1);)c=c==d[i]?r[i++]:(putchar(c),*G++);exit(0);} | ^~~~~ main.c:1:42: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:66: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration] 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,G=g,c=*G++;*(G-1);)c=c==d[i]?r[i++]:(putchar(c),*G++);exit(0);} | ^~~~ main.c:1:66: note: include '<stdio.h>' or provide a declaration of 'puts' main.c:1:80: error: 'k' undeclared (first use in this function) 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,G=g,c=*G++;*(G-1);)c=c==d[i]?r[i++]:(putchar(c),*G++);exit(0);} | ^ main.c:1:80: note: each undeclared identifier is reported only once for each function it appears in main.c:1:121: error: implicit declaration of function 'putchar' [-Wimplicit-function-declaration] 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,G=g,c=*G++;*(G-1);)c=c==d[i]?r[i++]:(putchar(c),*G++);exit(0);} | ^~~~~~~ main.c:1:121: note: include '<stdio.h>' or provide a declaration of 'putchar' main.c:1:138: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration] 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,G=g,c=*G++;*(G-1);)c=c==d[i]?r[i++]:(putchar(c),*G++);exit(0);} | ^~~~ main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit' +++ |+#include <stdlib.h> 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,G=g,c=*G++;*(G-1);)c=c==d[i]?r[i++]:(putchar(c),*G++);exit(0);} main.c:1:138: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch] 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=k=0,G=g,c=*G++;*(G-1);)c=c==d[i]?r[i++]:(putchar(c),*G++);exit(0);} | ^~~~ main.c:1:138: note: include '<stdlib.h>' or provide a declaration of 'exit'
s554353214
p00622
C
char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=0,G=g,c=*G++;*(G-1);)c=c!=d[i]?putchar(c),*G++;r[i++];exit(0);}
main.c:1:27: error: return type defaults to 'int' [-Wimplicit-int] 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=0,G=g,c=*G++;*(G-1);)c=c!=d[i]?putchar(c),*G++;r[i++];exit(0);} | ^~~~ main.c: In function 'main': main.c:1:27: error: type of 'c' defaults to 'int' [-Wimplicit-int] main.c:1:27: error: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:1:42: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=0,G=g,c=*G++;*(G-1);)c=c!=d[i]?putchar(c),*G++;r[i++];exit(0);} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=0,G=g,c=*G++;*(G-1);)c=c!=d[i]?putchar(c),*G++;r[i++];exit(0);} main.c:1:42: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=0,G=g,c=*G++;*(G-1);)c=c!=d[i]?putchar(c),*G++;r[i++];exit(0);} | ^~~~~ main.c:1:42: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:66: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration] 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=0,G=g,c=*G++;*(G-1);)c=c!=d[i]?putchar(c),*G++;r[i++];exit(0);} | ^~~~ main.c:1:66: note: include '<stdio.h>' or provide a declaration of 'puts' main.c:1:111: error: implicit declaration of function 'putchar' [-Wimplicit-function-declaration] 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=0,G=g,c=*G++;*(G-1);)c=c!=d[i]?putchar(c),*G++;r[i++];exit(0);} | ^~~~~~~ main.c:1:111: note: include '<stdio.h>' or provide a declaration of 'putchar' main.c:1:126: error: expected ':' before ';' token 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=0,G=g,c=*G++;*(G-1);)c=c!=d[i]?putchar(c),*G++;r[i++];exit(0);} | ^ | : main.c:1:134: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration] 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=0,G=g,c=*G++;*(G-1);)c=c!=d[i]?putchar(c),*G++;r[i++];exit(0);} | ^~~~ main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit' +++ |+#include <stdlib.h> 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=0,G=g,c=*G++;*(G-1);)c=c!=d[i]?putchar(c),*G++;r[i++];exit(0);} main.c:1:134: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch] 1 | char r[99],g[99],*G,d[99];main(c,i){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(i=0,G=g,c=*G++;*(G-1);)c=c!=d[i]?putchar(c),*G++;r[i++];exit(0);} | ^~~~ main.c:1:134: note: include '<stdlib.h>' or provide a declaration of 'exit'
s642960129
p00622
C
char r[99],g[99],*G,d[99];main(c){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(G=g,c=*G++,*g=0;*(G-1);)c=c-d[*g]?putchar(c),*G++:r[*g++];exit(0);}
main.c:1:27: error: return type defaults to 'int' [-Wimplicit-int] 1 | char r[99],g[99],*G,d[99];main(c){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(G=g,c=*G++,*g=0;*(G-1);)c=c-d[*g]?putchar(c),*G++:r[*g++];exit(0);} | ^~~~ main.c: In function 'main': main.c:1:27: error: type of 'c' defaults to 'int' [-Wimplicit-int] main.c:1:40: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 1 | char r[99],g[99],*G,d[99];main(c){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(G=g,c=*G++,*g=0;*(G-1);)c=c-d[*g]?putchar(c),*G++:r[*g++];exit(0);} | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | char r[99],g[99],*G,d[99];main(c){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(G=g,c=*G++,*g=0;*(G-1);)c=c-d[*g]?putchar(c),*G++:r[*g++];exit(0);} main.c:1:40: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 1 | char r[99],g[99],*G,d[99];main(c){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(G=g,c=*G++,*g=0;*(G-1);)c=c-d[*g]?putchar(c),*G++:r[*g++];exit(0);} | ^~~~~ main.c:1:40: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:1:64: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration] 1 | char r[99],g[99],*G,d[99];main(c){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(G=g,c=*G++,*g=0;*(G-1);)c=c-d[*g]?putchar(c),*G++:r[*g++];exit(0);} | ^~~~ main.c:1:64: note: include '<stdio.h>' or provide a declaration of 'puts' main.c:1:110: error: implicit declaration of function 'putchar' [-Wimplicit-function-declaration] 1 | char r[99],g[99],*G,d[99];main(c){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(G=g,c=*G++,*g=0;*(G-1);)c=c-d[*g]?putchar(c),*G++:r[*g++];exit(0);} | ^~~~~~~ main.c:1:110: note: include '<stdio.h>' or provide a declaration of 'putchar' main.c:1:130: error: lvalue required as increment operand 1 | char r[99],g[99],*G,d[99];main(c){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(G=g,c=*G++,*g=0;*(G-1);)c=c-d[*g]?putchar(c),*G++:r[*g++];exit(0);} | ^~ main.c:1:134: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration] 1 | char r[99],g[99],*G,d[99];main(c){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(G=g,c=*G++,*g=0;*(G-1);)c=c-d[*g]?putchar(c),*G++:r[*g++];exit(0);} | ^~~~ main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit' +++ |+#include <stdlib.h> 1 | char r[99],g[99],*G,d[99];main(c){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(G=g,c=*G++,*g=0;*(G-1);)c=c-d[*g]?putchar(c),*G++:r[*g++];exit(0);} main.c:1:134: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch] 1 | char r[99],g[99],*G,d[99];main(c){for(;scanf("%s%s%s",r,g,d)>1;puts(G))for(G=g,c=*G++,*g=0;*(G-1);)c=c-d[*g]?putchar(c),*G++:r[*g++];exit(0);} | ^~~~ main.c:1:134: note: include '<stdlib.h>' or provide a declaration of 'exit'
s567152751
p00622
C++
#include<iostream> #include<string> using namespace std; string S, T, U; int main() { while (true) { cin >> T; if (T == "-")break; cin >> S >> U; string V = ""; int c = 0; reverse(S.begin(), S.end()); reverse(T.begin(), T.end()); T += S[S.size() - 1]; while (S.size() + T.size() >= 1) { cout << S << ' ' << T << endl; if (c < U.size() && U[c] == S[S.size() - 1]) { T = T.substr(0, T.size() - 1); if (T.size() >= 1)S[S.size() - 1] = T[T.size() - 1]; if (T.size() == 0)S = ""; c++; } else { V += S[S.size() - 1]; S = S.substr(0, S.size() - 1); if (S.size() >= 1)T[T.size() - 1] = S[S.size() - 1]; if (S.size() == 0)T = ""; } } cout << V << endl; } return 0; }
a.cc: In function 'int main()': a.cc:8:17: error: 'reverse' was not declared in this scope 8 | reverse(S.begin(), S.end()); reverse(T.begin(), T.end()); T += S[S.size() - 1]; | ^~~~~~~
s719025037
p00622
C++
#include<iostream> #include<string> using namespace std; string S, T, U; int main() { while (true) { cin >> T; if (T == "-")break; cin >> S >> U; string V = ""; int c = 0; reverse(S.begin(), S.end()); reverse(T.begin(), T.end()); T += S[S.size() - 1]; while (S.size() + T.size() >= 1) { cout << S << ' ' << T << endl; if (c < U.size() && U[c] == S[S.size() - 1]) { T = T.substr(0, T.size() - 1); if (T.size() >= 1)S[S.size() - 1] = T[T.size() - 1]; if (T.size() == 0)S = ""; c++; } else { V += S[S.size() - 1]; S = S.substr(0, S.size() - 1); if (S.size() >= 1)T[T.size() - 1] = S[S.size() - 1]; if (S.size() == 0)T = ""; } } cout << V << endl; } return 0; }
a.cc: In function 'int main()': a.cc:8:17: error: 'reverse' was not declared in this scope 8 | reverse(S.begin(), S.end()); reverse(T.begin(), T.end()); T += S[S.size() - 1]; | ^~~~~~~
s276221373
p00622
C++
#include <string> #include <iostream> using namespace std; string a, b, c; int main() { while (cin >> a, a != "-") { cin >> b >> c; reverse(a.begin(), a.end()); reverse(b.begin(), b.end()); char r = b.back(); b.pop_back(); string ret; while (true) { if (c.find(r) != string::npos) { if (a.size() == 0) break; r = a.back(); a.pop_back(); } else { ret += r; if (b.size() == 0) break; r = b.back(); b.pop_back(); } } cout << ret << endl; } return 0; }
a.cc: In function 'int main()': a.cc:8:17: error: 'reverse' was not declared in this scope 8 | reverse(a.begin(), a.end()); | ^~~~~~~
s146840317
p00622
C++
#include <iostream> #include <vector> #include <queue> using namespace std; int main(){ while(true){ string Red,Green,Out; // cin>>Red; getline(cin,Red); if(Red[0]=='-') return 0; // cin>>Green>>Out; getline(cin,Green); getline(cin,Out); if(!Out.size()){ cout<<Green<<endl; continue; } // cout<<Red<<' '<<Green<<' '<<Out<<endl; queue<char> R,G,O; for(auto c:Red) R.push(c); for(auto c:Green) G.push(c); for(auto c:Out) O.push(c); char centre = G.front(); G.pop(); int cnt = Green.size(); while(true){ // cout<<'?'<<centre<<' '<<O.front()<<endl; if(!O.empty()&?¢re==O.front()){ centre=R.front(); R.pop(); O.pop(); }else{ cout<<centre; cnt--; if(!cnt){ cout<<endl; break; } centre=G.front(); G.pop(); } } } return 0; }
a.cc:29:28: error: extended character ¢ is not valid in an identifier 29 | if(!O.empty()&?¢re==O.front()){ | ^ a.cc: In function 'int main()': a.cc:29:27: error: expected primary-expression before '?' token 29 | if(!O.empty()&?¢re==O.front()){ | ^ a.cc:29:28: error: '\U000000a2re' was not declared in this scope 29 | if(!O.empty()&?¢re==O.front()){ | ^~~ a.cc:29:42: error: expected ':' before ')' token 29 | if(!O.empty()&?¢re==O.front()){ | ^ | : a.cc:29:42: error: expected primary-expression before ')' token
s144292911
p00622
C++
while(!Q.empty()){ u = Q.front(); Q.pop(); if(u.n1 == str.size() && u.n2 == str2.size()){ ans = u.right; break; } if(u.n1 < str.size()){ v = u; v.down += v.c; v.c = str[v.n1++]; for(i=0;i<v.down.size();i++){ if(v.down[i] != str3[i]) break; } if(i == v.down.size()) Q.push(v); } if(u.n2 < str2.size()){ v = u; v.right += v.c; v.c = str2[v.n2++]; Q.push(v); } }
a.cc:1:5: error: expected unqualified-id before 'while' 1 | while(!Q.empty()){ | ^~~~~
s143683540
p00623
Java
import java.util.Scanner; public class Main { Scanner sc = new Scanner(System.in); // Tree := (Tree Tree) | Leaf String t; int idx; int nidx; int ls[]; int n; int ps[]; Tree T; Tree tree() { if (t.charAt(idx) >= '0' && t.charAt(idx) <= '9') { int v = t.charAt(idx) - '0'; idx++; return new Tree(v); } if (t.charAt(idx) == '(') idx++; Tree l = tree(); idx++; Tree r = tree(); if (t.charAt(idx) == ')') idx++; return new Tree(l, r); } void run() { while (true) { t = sc.nextLine(); if (t.equals("END")) break; idx = 0; n = sc.nextInt(); ls = new int[n]; for (int i = 0; i < n; i++) { int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); int d = sc.nextInt(); ls[i] = (a << 3) + (b << 2) + (c << 1) + d; } sc.nextLine(); ps = new int[n - 1]; T = tree(); System.out.println(solve(0)); } } int solve(int k) { int res = 0; if (k == n - 1) { nidx = 0; int set = check(T); if (set == 15) return 1; else return 0; } for (int i = 0; i < 3; i++) { ps[k] = i; res += solve(k + 1); } return res; } int check(Tree tr) throws Exception { if (tr.v > 0) { return ls[tr.v - 1]; } Tree l = tr.l; Tree r = tr.r; int res = 0; if (n == 1) { throw new Exception("tr.v: " + tr.v); } switch (ps[nidx++]) { case 0: res = check(l) & check(r); break; case 1: res = check(l) | check(r); break; case 2: res = check(l) ^ check(r); break; } return res; } public static void main(String[] args) { new Main().run(); } } class Tree { Tree l; Tree r; int v; Tree(Tree l, Tree r) { this.l = l; this.r = r; v = -1; } Tree(int v) { this.v = v; } public String toString() { if (v < 0) { return "(" + l.toString() + " " + r.toString() + ")"; } return v + ""; } }
Main.java:57: error: unreported exception Exception; must be caught or declared to be thrown int set = check(T); ^ 1 error
s328503767
p00623
C++
#include <iostream> #include <vector> using namespace std; int curPos = 0; string str; int info[128] = {}; vector< vector<int> > g; int number[128] = {}; int mx = 0; void parse(int pos){ //cout << curPos << " " << str[curPos] << endl; mx = max(pos,mx); if( str[curPos] >= '0' && str[curPos] <= '9'){ number[pos] = info[ str[curPos] - '0' - 1]; curPos++; return; } assert(str[curPos] == '('); curPos++; g[pos].push_back(pos*2+1); parse(pos*2+1); assert(str[curPos] == ' '); curPos++; // space g[pos].push_back(pos*2+2); parse(pos*2+2); assert(str[curPos] == ')'); curPos++; return; } int calc(int a,int b,int t){ if( t == 0 ) return a & b; if( t == 1 ) return a | b; return a^b; } int tmp[30] = {}; vector<int> all(int pos){ if( number[pos] >= 0 ){ vector<int> c(16); c[number[pos]] = 1; //cout << pos << " : "; //for(int i = 0 ; i < 16 ; i++) cout << c[i] << " "; cout << endl; return c; }else{ vector<int> a,b,c(16); a = all(pos*2+1); b = all(pos*2+2); for(int k = 0 ; k < 3 ; k++){ for(int i = 0 ; i < 16 ; i++){ for(int j = 0 ; j < 16 ; j++){ c[calc(i,j,k)] += a[i] * b[j]; } } } //cout << pos << " : "; //for(int i = 0 ; i < 16 ; i++) cout << c[i] << " "; cout << endl; return c; } } int main(){ int n; while(1){ while( getline(cin,str) && (str == "" || str == "END") ){ if(str == "END") return 0; } for(int i = 0 ; i < 128 ; i++) number[i] = -1; cin >> n; g.clear(); g.resize(128); for(int i = 0 ; i < n ; i++){ int inf = 0 , a; for(int j = 0 ; j < 4 ; j++){ cin >> a; inf |= (a<<j); } info[i] = inf; } str += "~"; curPos = 0; mx = 0; parse(0); assert(str[curPos] == '~'); /*for(int i = 0 ; i <= mx ; i++){ cout << i << "(" << number[i] << ")" << " : "; for(int j =0 ; j < g[i].size() ; j++) cout << g[i][j] << " "; cout << endl; }*/ vector<int> answer = all(0); cout << answer[15] << endl; } }
a.cc: In function 'void parse(int)': a.cc:20:9: error: 'assert' was not declared in this scope 20 | assert(str[curPos] == '('); | ^~~~~~ a.cc:3:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 2 | #include <vector> +++ |+#include <cassert> 3 | using namespace std; a.cc: In function 'int main()': a.cc:88:17: error: 'assert' was not declared in this scope 88 | assert(str[curPos] == '~'); | ^~~~~~ a.cc:88:17: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>'
s520839906
p00624
C++
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <climits> #include <cfloat> #include <ctime> #include <cassert> #include <map> #include <utility> #include <set> #include <iostream> #include <memory> #include <string> #include <vector> #include <algorithm> #include <functional> #include <sstream> #include <complex> #include <stack> #include <queue> #include <numeric> #include <list> using namespace std; #ifdef _MSC_VER #define __typeof__ decltype template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; } #endif #define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it) #define all(c) (c).begin(), (c).end() #define rall(c) (c).rbegin(), (c).rend() #define CLEAR(arr, val) memset(arr, val, sizeof(arr)) #define rep(i, n) for (int i = 0; i < n; ++i) template <class T> void max_swap(T& a, const T& b) { a = max(a, b); } template <class T> void min_swap(T& a, const T& b) { a = min(a, b); } typedef long long ll; typedef pair<int, int> pint; const double EPS = 1e-8; const double PI = acos(-1.0); const int dx[] = { 0, 1, 0, -1 }; const int dy[] = { 1, 0, -1, 0 }; #ifdef _MSC_VER #include <unordered_map> #else #include <tr1/unorderd_map> using namespace tr1; #endif int pos_enc(int x, int y) { return (x & 0xf) | ((y & 0xf) << 4); } void pos_dec(ll enc, int& x, int& y) { x = enc & 0xf; y = (enc >> 4) & 0xf; } ll encode(int x, int y, int* con_x, int* con_y, int pane) { ll res = pos_enc(x, y); for (int i = 0; i < 3; ++i) res = (res << 8) | 0xff & pos_enc(con_x[i], con_y[i]); res = (res << 3) | 0x7 & pane; return res; } void decode(ll enc, int& x, int& y, int* con_x, int* con_y, int& pane) { pane = enc & 0x7; enc >>= 3; for (int i = 2; i >= 0; --i) { pos_dec(enc & 0xff, con_x[i], con_y[i]); enc >>= 8; } pos_dec(enc, x, y); } int main() { ios::sync_with_stdio(false); int h, w; while (cin >> h >> w, h) { char s[16][16]; for (int i = 0; i < h; ++i) cin >> s[i]; int sx, sy, gx, gy; int cx[3], cy[3]; CLEAR(cx, 0); CLEAR(cy, 0); for (int y = 0, c = 0, p = 0; y < h; ++y) { for (int x = 0; x < w; ++x) { if (s[y][x] == '@') { sx = x, sy = y; s[y][x] = '.'; } else if (s[y][x] == 'E') { gx = x, gy = y; s[y][x] = '.'; } else if (s[y][x] == 'w') s[y][x] = '0' + p++; else if (s[y][x] == 'c') { cx[c] = x; cy[c] = y; ++c; s[y][x] = '.'; } } } ll enc = encode(sx, sy, cx, cy, 0x7); typedef pair<int, ll> P; priority_queue<P, vector<P>, greater<P> > q; unordered_map<ll, int> dis; dis[enc] = 0; q.push(P(0, enc)); int res = -1; while (!q.empty()) { P t = q.top(); q.pop(); if (t.first > dis[t.second]) continue; int cc = t.first; int nc = cc + 1; int x, y, cx[3], cy[3], pane; decode(t.second, x, y, cx, cy, pane); if (x == gx && y == gy) { res = cc; break; } for (int i = 0; i < 4; ++i) { int tx = x + dx[i], ty = y + dy[i]; bool cont = false; for (int j = 0; j < 3; ++j) { if (tx == cx[j] && ty == cy[j]) { cont = true; int wx = tx, wy = ty; int ccx[3], ccy[3]; copy(cx, cx + 3, ccx); copy(cy, cy + 3, ccy); ll e; for (e = -1; e == -1; ) { wx += dx[i], wy += dy[i]; bool other_cont = false; for (int k = 0; k < 3; ++k) if (k != j && wx == cx[k] && wy == cy[k]) other_cont = true; if (s[wy][wx] == '#' || other_cont) { wx -= dx[i], wy -= dy[i]; ccx[j] = wx, ccy[j] = wy; e = encode(x, y, ccx, ccy, pane); } else if (isdigit(s[wy][wx]) && (pane >> (s[wy][wx] - '0') & 1)) { ccx[j] = 0, ccy[j] = 0; e = encode(x, y, ccx, ccy, pane ^ (1 << (s[wy][wx] - '0'))); } } if (!dis.count(e) || cc < dis[e]) { dis[e] = cc; q.push(P(cc, e)); break; } } } if (cont) continue; if (s[ty][tx] == '.' || (isdigit(s[ty][tx]) && !(pane >> (s[ty][tx] - '0') & 1))) { ll e = encode(tx, ty, cx, cy, pane); if (!dis.count(e) || nc < dis[e]) { dis[e] = nc; q.push(P(nc, e)); } } } } cout << res << endl; } }
a.cc:55:10: fatal error: tr1/unorderd_map: No such file or directory 55 | #include <tr1/unorderd_map> | ^~~~~~~~~~~~~~~~~~ compilation terminated.
s083390873
p00624
C++
#include<queue> #include<set> #include<vector> #include<cstdio> #include<cstring> using namespace std; struct S{ char p,x,y; vector<pair<char,char> > w,c; S(char p=0,char x=0,char y=0):p(p),x(x),y(y){ } }; int main(){ int i,j,k,l; int h,w; while(scanf("%d%d",&h,&w),h||w){ int a[10][10]={},x,y; S s; for(i=0;i<h;++i){ getchar(); for(j=0;j<w;++j){ char p=getchar(); if(false){ }else if(p=='#'){ a[j][i]=-1; }else if(p=='@'){ s.x=j; s.y=i; }else if(p=='w'){ s.w.push_back(make_pair(j,i)); }else if(p=='c'){ s.c.push_back(make_pair(j,i)); }else if(p=='E'){ x=j; y=i; } } } set<S> e; e.insert(s); queue<S> b; b.push(s); int dx[]={1,0,-1,0},dy[]={0,1,0,-1},mn=0x7fff; while(!b.empty()){ S s=b.front(); b.pop(); for(i=0;i<(int)s.w.size();++i) a[s.w[i].first][s.w[i].second]=-2; for(i=0;i<(int)s.c.size();++i) a[s.c[i].first][s.c[i].second]=-1; int c[10][10]; memset(c,-1,sizeof(c)); c[s.x][s.y]=s.p; queue<S> d; d.push(S(s.p,s.x,s.y)); while(!d.empty()){ S t=d.front(); d.pop(); for(i=0;i<4;++i){ if(a[t.x+dx[i]][t.y+dy[i]]||c[t.x+dx[i]][t.y+dy[i]]>=0) continue; c[t.x+dx[i]][t.y+dy[i]]=t.p+1; d.push(S(t.p+1,t.x+dx[i],t.y+dy[i])); } } if(c[x][y]>=0&&mn>c[x][y]) mn=c[x][y]; for(i=0;i<(int)s.c.size();++i){ for(j=0;j<4;++j){ if(c[s.c[i].first+dx[(j+2)%4]][s.c[i].second+dy[(j+2)%4]]<0||a[s.c[i].first+dx[j]][s.c[i].second+dy[j]]==-1) continue; for(k=1;!a[s.c[i].first+dx[j]*k][s.c[i].second+dy[j]*k];++k); S t(c[s.c[i].first+dx[(j+2)%4]][s.c[i].second+dy[(j+2)%4]]+1,s.c[i].first,s.c[i].second); t.w=s.w; t.c=s.c; if(a[s.c[i].first+dx[j]*k][s.c[i].second+dy[j]*k]==-1){ t.c[i]=make_pair(s.c[i].first+dx[j]*(k-1),s.c[i].second+dy[j]*(k-1)); }else{ for(l=0;s.w[l].first!=s.c[i].first+dx[j]*k||s.w[l].second!=s.c[i].second+dy[j]*k;++l); t.w.erase(t.w.begin()+l); t.c.erase(t.c.begin()+i); } S u=t; u.p=0; if(e.count(u)) continue; e.insert(u); b.push(t); } } for(i=0;i<(int)s.w.size();++i) a[s.w[i].first][s.w[i].second]=0; for(i=0;i<(int)s.c.size();++i) a[s.c[i].first][s.c[i].second]=0; } printf("%d\n",mn==0x7fff?-1:mn); } return 0; }
In file included from /usr/include/c++/14/bits/refwrap.h:39, from /usr/include/c++/14/deque:67, from /usr/include/c++/14/queue:62, from a.cc:1: /usr/include/c++/14/bits/stl_function.h: In instantiation of 'constexpr bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = S]': /usr/include/c++/14/bits/stl_tree.h:2545:33: required from 'std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::const_iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::find(const _Key&) const [with _Key = S; _Val = S; _KeyOfValue = std::_Identity<S>; _Compare = std::less<S>; _Alloc = std::allocator<S>; const_iterator = std::_Rb_tree<S, S, std::_Identity<S>, std::less<S>, std::allocator<S> >::const_iterator]' 2545 | || _M_impl._M_key_compare(__k, | ~~~~~~~~~~~~~~~~~~~~~~^~~~~ 2546 | _S_key(__j._M_node))) ? end() : __j; | ~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/stl_set.h:751:25: required from 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::count(const key_type&) const [with _Key = S; _Compare = std::less<S>; _Alloc = std::allocator<S>; size_type = long unsigned int; key_type = S]' 751 | { return _M_t.find(__x) == _M_t.end() ? 0 : 1; } | ~~~~~~~~~^~~~~ a.cc:85:16: required from here 85 | if(e.count(u)) | ~~~~~~~^~~ /usr/include/c++/14/bits/stl_function.h:405:20: error: no match for 'operator<' (operand types are 'const S' and 'const S') 405 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/deque:62: /usr/include/c++/14/bits/stl_pair.h:1045:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator<(const pair<_T1, _T2>&, const pair<_T1, _T2>&)' 1045 | operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_pair.h:1045:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const S' is not derived from 'const std::pair<_T1, _T2>' 405 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:67: /usr/include/c++/14/bits/stl_iterator.h:448:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)' 448 | operator<(const reverse_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:448:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const S' is not derived from 'const std::reverse_iterator<_Iterator>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 493 | operator<(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:493:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const S' is not derived from 'const std::reverse_iterator<_Iterator>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1694 | operator<(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1694:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const S' is not derived from 'const std::move_iterator<_IteratorL>' 405 | { return __x < __y; } | ~~~~^~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator<(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)' 1760 | operator<(const move_iterator<_Iterator>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1760:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const S' is not derived from 'const std::move_iterator<_IteratorL>' 405 | { return __x < __y; } | ~~~~^~~~~ In file included from /usr/include/c++/14/deque:66: /usr/include/c++/14/bits/stl_deque.h:2334:5: note: candidate: 'template<class _Tp, class _Alloc> bool std::operator<(const deque<_Tp, _Alloc>&, const deque<_Tp, _Alloc>&)' 2334 | operator<(const deque<_Tp, _Alloc>& __x, const deque<_Tp, _Alloc>& __y) | ^~~~~~~~ /usr/include/c++/14/bits/stl_deque.h:2334:5: note: template argument deduction/substitution failed: /usr/include/c++/14/bits/stl_function.h:405:20: note: 'const S' is not derived from 'const std::deque<_Tp, _Alloc>' 405 | { return __x < __y; } | ~~~~^~~~~
s457767138
p00625
C++
#include <iostream> #include <algorithm> #include <complex> #include <vector> #include <cmath> using namespace std; typedef complex<double> P; const int MAXN = 11; const double eps = 1e-7; const double inf = 1e100; int N, M; vector<P> Ds; vector<double> V; int num[MAXN]; bool equals(double a, double b) { return abs(a-b) < eps; } double getT(P p, P v, P d, double sp) { double a = v.real()*v.real() + v.imag()*v.imag() - sp*sp; double b = v.real()*(p.real()-d.real()) + v.imag()*(p.imag()-d.imag()); double c = (p.real()-d.real())*(p.real()-d.real()) + (p.imag()-d.imag())*(p.imag()-d.imag()); double D = b*b - a*c; vector<double> t; if(equals(D, 0.0)) { assert(a != 0.0); t.push_back(-b/a); } else if(D > 0.0) { assert(a != 0.0); t.push_back((-b+sqrt(D))/a); t.push_back((-b-sqrt(D))/a); } double res = inf; for(int i = 0; i < t.size(); ++i) { if(t[i] < 0) continue; res = min(res, t[i]); } return res;; } void fly(P p, P v) { int getD = -1; double minT = inf; double t[MAXN]; for(int i = 0; i < N; ++i) { t[i] = getT(p, v, Ds[i], V[i]); if(t[i] < minT) { getD = i; minT = t[i]; } } ++num[getD]; for(int i = 0; i < N; ++i) { if(t[i] == inf) continue; P endp = p + v*t[i]; P base = endp - Ds[i]; Ds[i] += base/abs(base)*V[i]*minT; } } int main() { while(cin >> N >> M && (N|M)) { Ds.resize(N); V.resize(N); for(int i = 0; i < N; ++i) { cin >> Ds[i].real() >> Ds[i].imag() >> V[i]; } fill(num, num+MAXN, 0); while(M--) { P p, v; cin >> p.real() >> p.imag() >> v.real() >> v.imag(); fly(p, v); } for(int i = 0; i < N; ++i) { if(i) cout << " "; cout << num[i]; } cout << endl; } return 0; }
a.cc: In function 'double getT(P, P, P, double)': a.cc:29:5: error: 'assert' was not declared in this scope 29 | assert(a != 0.0); | ^~~~~~ a.cc:6:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 5 | #include <cmath> +++ |+#include <cassert> 6 | using namespace std; a.cc:32:5: error: 'assert' was not declared in this scope 32 | assert(a != 0.0); | ^~~~~~ a.cc:32:5: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' a.cc: In function 'int main()': a.cc:69:11: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'double') 69 | cin >> Ds[i].real() >> Ds[i].imag() >> V[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:69:24: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double' 69 | cin >> Ds[i].real() >> Ds[i].imag() >> V[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:69:24: error: cannot bind non-const lvalue reference of type 'short int&' to a value of type 'double' 69 | cin >> Ds[i].real() >> Ds[i].imag() >> V[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:69:24: error: cannot bind non-const lvalue reference of type 'short unsigned int&' to a value of type 'double' 69 | cin >> Ds[i].real() >> Ds[i].imag() >> V[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:69:24: error: cannot bind non-const lvalue reference of type 'int&' to a value of type 'double' 69 | cin >> Ds[i].real() >> Ds[i].imag() >> V[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:69:24: error: cannot bind non-const lvalue reference of type 'unsigned int&' to a value of type 'double' 69 | cin >> Ds[i].real() >> Ds[i].imag() >> V[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:69:24: error: cannot bind non-const lvalue reference of type 'long int&' to a value of type 'double' 69 | cin >> Ds[i].real() >> Ds[i].imag() >> V[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:69:24: error: cannot bind non-const lvalue reference of type 'long unsigned int&' to a value of type 'double' 69 | cin >> Ds[i].real() >> Ds[i].imag() >> V[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:69:24: error: cannot bind non-const lvalue reference of type 'long long int&' to a value of type 'double' 69 | cin >> Ds[i].real() >> Ds[i].imag() >> V[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:69:24: error: cannot bind non-const lvalue reference of type 'long long unsigned int&' to a value of type 'double' 69 | cin >> Ds[i].real() >> Ds[i].imag() >> V[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:69:24: error: cannot bind non-const lvalue reference of type 'float&' to a value of type 'double' 69 | cin >> Ds[i].real() >> Ds[i].imag() >> V[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:69:24: error: cannot bind non-const lvalue reference of type 'double&' to an rvalue of type 'double' 69 | cin >> Ds[i].real() >> Ds[i].imag() >> V[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:69:24: error: cannot bind non-const lvalue reference of type 'long double&' to a value of type 'double' 69 | cin >> Ds[i].real() >> Ds[i].imag() >> V[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:
s894499411
p00626
C++
// Description: ??£?????°??????????????????????°??????\??????????????¨ // TimeComplexity: $ \mathcal{O}(V^3+ V^2 2^T + V3^T)$ T????????????????????° // Verifyed: AOJ GRL_2_C todo auto Dreyfus_wagner(const G &graph,const auto &term){ using W=int; W inf=1<<28; const int n=graph.size(),t=term.size(); if(t<=1) return 0; auto dist=graph; vector<vector<W>> opt(1<<t,vector<W>(n,inf)); rep(k,n)rep(i,n)rep(j,n) chmin(dist[i][j],dist[i][k]+dist[k][j]); rep(i,t){ rep(j,n) opt[1<<i][j]=dist[term[i]][j]; rep(j,t) opt[(1<<i)|(1<<j)][term[j]]=dist[term[i]][term[j]]; } auto next_combination=[&](int s){ int x=s&-s,y=s+x; return ((s&~y)/x>>1)|y; }; rep(k,2,t){ for(int s=(1<<k)-1;s<(1<<t);s=next_combination(s)){ rep(x,n){ int ns=s,cur=-1; rep(i,t) if(term[i]==x) cur=i; if(cur!=-1) ns|=(1<<cur); if(cur!=-1 and s==ns) continue; for(int u=(s-1)&s;u!=0;u=(u-1)&s){ int c=s&(~u); chmin(opt[ns][x],opt[u][x]+opt[c][x]); } } int x=s&-s,y=s+x; s=((s&~y)/x>>1)|y; } for(int s=(1<<k)-1;s<bit(1<<t);s=next_combination(s)){ rep(x,n){ int ns=s,nxt=-1; rep(i,t) if(term[i]==x) nxt=i; if(nxt!=-1) ns|=(1<<nxt); if(nxt!=-1 && s==ns) continue; rep(y,n) chmin(opt[ns][x],opt[s][y]+dist[y][x]); } } } const int mask=(1<<t)-1; W ans=opt[mask][0]; rep(i,n) chmin(ans,p[mask][i]); return ans; } int main(void){ int h,w; while(cin >> h >> w){ if(h==0) break; rep(i,vmax)rep(j,vmax) d[i][j]=(i==j)?0:inf; V=h*w,T=0; rep(i,h*w){ int in; cin >> in; if(in) t[T++]=i; } rep(i,h)rep(j,w){ int cur=w*i+j; if(i+1<h) d[cur][cur+w]=d[cur+w][cur]=1; if(j+1<w) d[cur][cur+1]=d[cur+1][cur]=1; } int res=minimum_steiner_tree(); cout << V-1-res << endl; } return 0; } // q[s|c][x]=min(q[s|c],p[s][x]+p[c][x]); // p[s][x]=min(p[s][x],p[s][y]+d[y][x]) y???s // p[s][x]=min(p[s][x],q[s][y]+d[y][x]) y???v/s
a.cc:5:27: error: 'G' does not name a type 5 | auto Dreyfus_wagner(const G &graph,const auto &term){ | ^ a.cc:5:42: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts' 5 | auto Dreyfus_wagner(const G &graph,const auto &term){ | ^~~~ a.cc: In function 'auto Dreyfus_wagner(const int&, const auto:1&)': a.cc:7:27: error: request for member 'size' in 'graph', which is of non-class type 'const int' 7 | const int n=graph.size(),t=term.size(); | ^~~~ a.cc:8:12: error: 't' was not declared in this scope 8 | if(t<=1) return 0; | ^ a.cc:10:9: error: 'vector' was not declared in this scope 10 | vector<vector<W>> opt(1<<t,vector<W>(n,inf)); | ^~~~~~ a.cc:10:24: error: expected primary-expression before '>>' token 10 | vector<vector<W>> opt(1<<t,vector<W>(n,inf)); | ^~ a.cc:10:34: error: 't' was not declared in this scope 10 | vector<vector<W>> opt(1<<t,vector<W>(n,inf)); | ^ a.cc:10:44: error: expected primary-expression before '>' token 10 | vector<vector<W>> opt(1<<t,vector<W>(n,inf)); | ^ a.cc:10:27: error: there are no arguments to 'opt' that depend on a template parameter, so a declaration of 'opt' must be available [-fpermissive] 10 | vector<vector<W>> opt(1<<t,vector<W>(n,inf)); | ^~~ a.cc:10:27: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated) a.cc:12:13: error: 'k' was not declared in this scope 12 | rep(k,n)rep(i,n)rep(j,n) chmin(dist[i][j],dist[i][k]+dist[k][j]); | ^ a.cc:12:9: error: there are no arguments to 'rep' that depend on a template parameter, so a declaration of 'rep' must be available [-fpermissive] 12 | rep(k,n)rep(i,n)rep(j,n) chmin(dist[i][j],dist[i][k]+dist[k][j]); | ^~~ a.cc:12:17: error: expected ';' before 'rep' 12 | rep(k,n)rep(i,n)rep(j,n) chmin(dist[i][j],dist[i][k]+dist[k][j]); | ^~~ | ; a.cc:14:13: error: 'i' was not declared in this scope 14 | rep(i,t){ | ^ a.cc:14:9: error: there are no arguments to 'rep' that depend on a template parameter, so a declaration of 'rep' must be available [-fpermissive] 14 | rep(i,t){ | ^~~ a.cc:14:17: error: expected ';' before '{' token 14 | rep(i,t){ | ^ | ; a.cc:24:9: error: there are no arguments to 'rep' that depend on a template parameter, so a declaration of 'rep' must be available [-fpermissive] 24 | rep(k,2,t){ | ^~~ a.cc:24:19: error: expected ';' before '{' token 24 | rep(k,2,t){ | ^ | ; a.cc:51:15: error: 'opt' was not declared in this scope 51 | W ans=opt[mask][0]; | ^~~ a.cc:52:9: error: there are no arguments to 'rep' that depend on a template parameter, so a declaration of 'rep' must be available [-fpermissive] 52 | rep(i,n) chmin(ans,p[mask][i]); | ^~~ a.cc:52:17: error: expected ';' before 'chmin' 52 | rep(i,n) chmin(ans,p[mask][i]); | ^~~~~~ | ; a.cc: In function 'int main()': a.cc:58:15: error: 'cin' was not declared in this scope 58 | while(cin >> h >> w){ | ^~~ a.cc:61:21: error: 'i' was not declared in this scope 61 | rep(i,vmax)rep(j,vmax) d[i][j]=(i==j)?0:inf; | ^ a.cc:61:23: error: 'vmax' was not declared in this scope 61 | rep(i,vmax)rep(j,vmax) d[i][j]=(i==j)?0:inf; | ^~~~ a.cc:61:17: error: 'rep' was not declared in this scope 61 | rep(i,vmax)rep(j,vmax) d[i][j]=(i==j)?0:inf; | ^~~ a.cc:62:17: error: 'V' was not declared in this scope 62 | V=h*w,T=0; | ^ a.cc:62:23: error: 'T' was not declared in this scope 62 | V=h*w,T=0; | ^ a.cc:74:25: error: 'minimum_steiner_tree' was not declared in this scope 74 | int res=minimum_steiner_tree(); | ^~~~~~~~~~~~~~~~~~~~ a.cc:75:17: error: 'cout' was not declared in this scope 75 | cout << V-1-res << endl; | ^~~~ a.cc:75:36: error: 'endl' was not declared in this scope 75 | cout << V-1-res << endl; | ^~~~
s568629129
p00626
C++
// Description: ??£?????°??????????????????????°??????\??????????????¨ // TimeComplexity: $ \mathcal{O}(V^3+ V^2 2^T + V3^T)$ T????????????????????° // Verifyed: AOJ GRL_2_C todo auto Dreyfus_wagner(const G &graph,const auto &term){ using W=int; W inf=1<<28; const int n=graph.size(),t=term.size(); if(t<=1) return 0; auto dist=graph; vector<vector<W>> opt(1<<t,vector<W>(n,inf)); rep(k,n)rep(i,n)rep(j,n) chmin(dist[i][j],dist[i][k]+dist[k][j]); rep(i,t){ rep(j,n) opt[1<<i][j]=dist[term[i]][j]; rep(j,t) opt[(1<<i)|(1<<j)][term[j]]=dist[term[i]][term[j]]; } auto next_combination=[&](int s){ int x=s&-s,y=s+x; return ((s&~y)/x>>1)|y; }; rep(k,2,t){ for(int s=(1<<k)-1;s<(1<<t);s=next_combination(s)){ rep(x,n){ int ns=s,cur=-1; rep(i,t) if(term[i]==x) cur=i; if(cur!=-1) ns|=(1<<cur); if(cur!=-1 and s==ns) continue; for(int u=(s-1)&s;u!=0;u=(u-1)&s){ int c=s&(~u); chmin(opt[ns][x],opt[u][x]+opt[c][x]); } } int x=s&-s,y=s+x; s=((s&~y)/x>>1)|y; } for(int s=(1<<k)-1;s<bit(1<<t);s=next_combination(s)){ rep(x,n){ int ns=s,nxt=-1; rep(i,t) if(term[i]==x) nxt=i; if(nxt!=-1) ns|=(1<<nxt); if(nxt!=-1 && s==ns) continue; rep(y,n) chmin(opt[ns][x],opt[s][y]+dist[y][x]); } } } const int mask=(1<<t)-1; W ans=opt[mask][0]; rep(i,n) chmin(ans,p[mask][i]); return ans; } int main(void){ int h,w; while(cin >> h >> w){ if(h==0) break; rep(i,vmax)rep(j,vmax) d[i][j]=(i==j)?0:inf; V=h*w,T=0; rep(i,h*w){ int in; cin >> in; if(in) t[T++]=i; } rep(i,h)rep(j,w){ int cur=w*i+j; if(i+1<h) d[cur][cur+w]=d[cur+w][cur]=1; if(j+1<w) d[cur][cur+1]=d[cur+1][cur]=1; } int res=minimum_steiner_tree(); cout << V-1-res << endl; } return 0; } // q[s|c][x]=min(q[s|c],p[s][x]+p[c][x]); // p[s][x]=min(p[s][x],p[s][y]+d[y][x]) y???s // p[s][x]=min(p[s][x],q[s][y]+d[y][x]) y???v/s
a.cc:5:27: error: 'G' does not name a type 5 | auto Dreyfus_wagner(const G &graph,const auto &term){ | ^ a.cc:5:42: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts' 5 | auto Dreyfus_wagner(const G &graph,const auto &term){ | ^~~~ a.cc: In function 'auto Dreyfus_wagner(const int&, const auto:1&)': a.cc:7:27: error: request for member 'size' in 'graph', which is of non-class type 'const int' 7 | const int n=graph.size(),t=term.size(); | ^~~~ a.cc:8:12: error: 't' was not declared in this scope 8 | if(t<=1) return 0; | ^ a.cc:10:9: error: 'vector' was not declared in this scope 10 | vector<vector<W>> opt(1<<t,vector<W>(n,inf)); | ^~~~~~ a.cc:10:24: error: expected primary-expression before '>>' token 10 | vector<vector<W>> opt(1<<t,vector<W>(n,inf)); | ^~ a.cc:10:34: error: 't' was not declared in this scope 10 | vector<vector<W>> opt(1<<t,vector<W>(n,inf)); | ^ a.cc:10:44: error: expected primary-expression before '>' token 10 | vector<vector<W>> opt(1<<t,vector<W>(n,inf)); | ^ a.cc:10:27: error: there are no arguments to 'opt' that depend on a template parameter, so a declaration of 'opt' must be available [-fpermissive] 10 | vector<vector<W>> opt(1<<t,vector<W>(n,inf)); | ^~~ a.cc:10:27: note: (if you use '-fpermissive', G++ will accept your code, but allowing the use of an undeclared name is deprecated) a.cc:12:13: error: 'k' was not declared in this scope 12 | rep(k,n)rep(i,n)rep(j,n) chmin(dist[i][j],dist[i][k]+dist[k][j]); | ^ a.cc:12:9: error: there are no arguments to 'rep' that depend on a template parameter, so a declaration of 'rep' must be available [-fpermissive] 12 | rep(k,n)rep(i,n)rep(j,n) chmin(dist[i][j],dist[i][k]+dist[k][j]); | ^~~ a.cc:12:17: error: expected ';' before 'rep' 12 | rep(k,n)rep(i,n)rep(j,n) chmin(dist[i][j],dist[i][k]+dist[k][j]); | ^~~ | ; a.cc:14:13: error: 'i' was not declared in this scope 14 | rep(i,t){ | ^ a.cc:14:9: error: there are no arguments to 'rep' that depend on a template parameter, so a declaration of 'rep' must be available [-fpermissive] 14 | rep(i,t){ | ^~~ a.cc:14:17: error: expected ';' before '{' token 14 | rep(i,t){ | ^ | ; a.cc:24:9: error: there are no arguments to 'rep' that depend on a template parameter, so a declaration of 'rep' must be available [-fpermissive] 24 | rep(k,2,t){ | ^~~ a.cc:24:19: error: expected ';' before '{' token 24 | rep(k,2,t){ | ^ | ; a.cc:51:15: error: 'opt' was not declared in this scope 51 | W ans=opt[mask][0]; | ^~~ a.cc:52:9: error: there are no arguments to 'rep' that depend on a template parameter, so a declaration of 'rep' must be available [-fpermissive] 52 | rep(i,n) chmin(ans,p[mask][i]); | ^~~ a.cc:52:17: error: expected ';' before 'chmin' 52 | rep(i,n) chmin(ans,p[mask][i]); | ^~~~~~ | ; a.cc: In function 'int main()': a.cc:58:15: error: 'cin' was not declared in this scope 58 | while(cin >> h >> w){ | ^~~ a.cc:61:21: error: 'i' was not declared in this scope 61 | rep(i,vmax)rep(j,vmax) d[i][j]=(i==j)?0:inf; | ^ a.cc:61:23: error: 'vmax' was not declared in this scope 61 | rep(i,vmax)rep(j,vmax) d[i][j]=(i==j)?0:inf; | ^~~~ a.cc:61:17: error: 'rep' was not declared in this scope 61 | rep(i,vmax)rep(j,vmax) d[i][j]=(i==j)?0:inf; | ^~~ a.cc:62:17: error: 'V' was not declared in this scope 62 | V=h*w,T=0; | ^ a.cc:62:23: error: 'T' was not declared in this scope 62 | V=h*w,T=0; | ^ a.cc:74:25: error: 'minimum_steiner_tree' was not declared in this scope 74 | int res=minimum_steiner_tree(); | ^~~~~~~~~~~~~~~~~~~~ a.cc:75:17: error: 'cout' was not declared in this scope 75 | cout << V-1-res << endl; | ^~~~ a.cc:75:36: error: 'endl' was not declared in this scope 75 | cout << V-1-res << endl; | ^~~~
s806581918
p00626
C++
#include <bits/stdc++.h> #define _overload(_1,_2,_3,name,...) name #define _rep(i,n) _range(i,0,n) #define _range(i,a,b) for(int i=int(a);i<int(b);++i) #define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__) #define _rrep(i,n) _rrange(i,n,0) #define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i) #define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__) #define _all(arg) begin(arg),end(arg) #define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg)) #define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary) #define clr(a,b) memset((a),(b),sizeof(a)) #define bit(n) (1LL<<(n)) #define popcount(n) (__builtin_popcountll(n)) using namespace std; template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;} template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;} using ll=long long; using R=long double; const R EPS=1e-9; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7 inline int sgn(const R& r){return(r > EPS)-(r < -EPS);} inline R sq(R x){return sqrt(max<R>(x,0.0));} const int dx[8]={1,0,-1,0,1,-1,-1,1}; const int dy[8]={0,1,0,-1,1,1,-1,-1}; // Problem Specific Parameter: using G=vector<vector<int>>; auto Dreyfus_wagner(const G &graph,const auto &term){ using W=int; W inf=1<<28; const int n=graph.size(),t=term.size(); if(t<=1) return 0; auto dist=graph; vector<vector<W>> opt(1<<t,vector<W>(n,inf)); rep(k,n)rep(i,n)rep(j,n) chmin(dist[i][j],dist[i][k]+dist[k][j]); map<int,int> dict; rep(i,t){ dict[term[i]]=1<<i; rep(j,n) opt[1<<i][j]=dist[term[i]][j]; rep(j,t) opt[(1<<i)|(1<<j)][term[j]]=dist[term[i]][term[j]]; } auto rep(k,2,t){ for(int s=(1<<k)-1;s<(1<<t);){ rep(i,n){ int ns=s|dict[i]; if(dict[i] and s==ns) continue; for(int u=(s-1)&s;u!=0;u=(u-1)&s){ int c=s&(~u); chmin(opt[ns][i],opt[u][i]+opt[c][i]); } } int x=s&-s,y=s+x; s=((s&~y)/x>>1)|y } for(int s=(1<<k)-1;s<(1<<t);){ rep(i,n){ int ns=s|dict[i]; if(dict[i] and s==ns) continue; rep(j,n) chmin(opt[ns][i],opt[s][j]+dist[j][i]); } int x=s&-s,y=s+x; s=((s&~y)/x>>1)|y; } } const int mask=(1<<t)-1; W ans=opt[mask][0]; rep(i,n) chmin(ans,opt[mask][i]); return ans; } int main(void){ int h,w; while(cin >> h >> w){ if(h==0) break; const int inf=1<<28; G graph(h*w,vector<int>(h*w,inf)); rep(i,h*w) graph[i][i]=0; vector<int> term; rep(i,h*w){ int in; cin >> in; if(in) term.push_back(i); } rep(i,h)rep(j,w){ const int cur=w*i+j; if(i+1<h) graph[cur][cur+w]=graph[cur+w][cur]=1; if(j+1<w) graph[cur][cur+1]=graph[cur+1][cur]=1; } int res=Dreyfus_wagner(graph,term); cout << h*w-1-res << endl; } return 0; }
a.cc:37:42: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts' 37 | auto Dreyfus_wagner(const G &graph,const auto &term){ | ^~~~ a.cc: In function 'auto Dreyfus_wagner(const G&, const auto:28&)': a.cc:5:23: error: expected unqualified-id before 'for' 5 | #define _range(i,a,b) for(int i=int(a);i<int(b);++i) | ^~~ a.cc:3:38: note: in expansion of macro '_range' 3 | #define _overload(_1,_2,_3,name,...) name | ^~~~ a.cc:6:18: note: in expansion of macro '_overload' 6 | #define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__) | ^~~~~~~~~ a.cc:55:9: note: in expansion of macro 'rep' 55 | rep(k,2,t){ | ^~~ a.cc:55:13: error: 'k' was not declared in this scope 55 | rep(k,2,t){ | ^ a.cc:5:40: note: in definition of macro '_range' 5 | #define _range(i,a,b) for(int i=int(a);i<int(b);++i) | ^ a.cc:55:9: note: in expansion of macro 'rep' 55 | rep(k,2,t){ | ^~~
s340378368
p00626
C++
#include<iostream> using namespace std; #define REP(i,b,n) for(int i=b;i<n;i++) #define rep(i,n) REP(i,0,n) const int W = 12,H = 12; int visited[H][W]; bool visnode[6]; int in[H][W]; int inx[7],iny[7]; int dx[]={0,0,1,-1}; int dy[]={1,-1,0,0}; bool dfs(int n,int now,int cnt,int limit,int y,int x,int r,int c){ //cout << y << " " << x << " " << now << " " << cnt << " " << limit << endl; if (now == n)return true; if (visnode[now]){ if (dfs(n,now+1,cnt,limit,iny[now+1],inx[now+1],r,c))return true; return false; } if (cnt >limit)return false; if (visited[y][x] != -1){ if (now == 0){ if (in[y][x] != 0){ visnode[in[y][x]]=true; if (dfs(n,now+1,cnt,limit,iny[in[y][x]],inx[in[y][x]],r,c))return true; visnode[in[y][x]]=false; return false; }else if (visited[y][x] == 0){ if (cnt == 1); else return false; }else assert(false); }else { if (in[y][x] == now); else if (visited[y][x] == now)return false; else if (visited[y][x] < now){ if (dfs(n,now+1,cnt,limit,iny[now+1],inx[now+1],r,c))return true; else return false; } } } visited[y][x]=now; rep(i,4){ int nex = x+dx[i],ney = y+dy[i]; if (nex<0||c-1 < nex || r-1 < ney || ney < 0)continue; if (dfs(n,now,cnt+1,limit,ney,nex,r,c))return true; } visited[y][x]=-1; return false; } main(){ int r,c; while(cin>>r>>c && r){ int index = 0; rep(i,r){ rep(j,c){ cin>>in[i][j]; if (in[i][j] == 0)in[i][j]=-1; else inx[index]=j,iny[index]=i,visnode[index]=false,in[i][j]=index++; } } if (index == 1){ cout << r*c-1 << endl; continue; } rep(k,r*c+1){ rep(i,r)rep(j,c){ visited[i][j]=in[i][j]; } if (dfs(index,0,1,k,iny[0],inx[0],r,c)){ cout << r*c-k << endl; break; } } //puts("iterative deeping end"); } }
a.cc: In function 'bool dfs(int, int, int, int, int, int, int, int)': a.cc:37:13: error: 'assert' was not declared in this scope 37 | }else assert(false); | ^~~~~~ a.cc:2:1: note: 'assert' is defined in header '<cassert>'; this is probably fixable by adding '#include <cassert>' 1 | #include<iostream> +++ |+#include <cassert> 2 | using namespace std; a.cc: At global scope: a.cc:63:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 63 | main(){ | ^~~~
s900078983
p00626
C++
1 1 1 1 2 1 1 3 3 1 0 0 0 0 0 1 0 0 3 3 1 0 0 1 0 0 1 0 0 3 3 1 1 1 0 0 0 0 0 0 4 4 1 0 0 0 0 0 1 0 0 1 0 0 1 0 0 1 1 1 1 2 3 1 0 0 0 0 1 12 12 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1
a.cc:1:1: error: expected unqualified-id before numeric constant 1 | 1 1 | ^
s394668862
p00626
C++
#include <cstdio> #include <iostream> #include <sstream> #include <fstream> #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; const int INF = INT_MAX / 2; int dy[] = {1, -1, 0, 0}; int dx[] = {0, 0, -1, 1}; int h, w; int n; vector<int> hy, hx; int solve(bitset<6> used, vector<bitset<12> >& s) { if(used.count() == n){ int ret = 0; for(int y=0; y<h; ++y){ for(int x=0; x<w; ++x){ if(!s[y][x]) ++ ret; } } if(ret > 7) return 0; return ret; } int ret = 0; for(int i=0; i<n; ++i){ if(used[i]) continue; for(int j=0; j<n; ++j){ if(i == j || (!used[j] && j < i)) continue; bitset<6> used2 = used; used2[i] = used2[j] = true; vector<bitset<12> > t = s; for(int y=min(hy[i],hy[j]); y<=max(hy[i],hy[j]); ++y) t[y][hx[i]] = true; for(int x=min(hx[i],hx[j]); x<=max(hx[i],hx[j]); ++x) t[hy[j]][x] = true; ret = max(ret, solve(used2, t)); t = s; for(int y=min(hy[i],hy[j]); y<=max(hy[i],hy[j]); ++y) t[y][hx[j]] = true; for(int x=min(hx[i],hx[j]); x<=max(hx[i],hx[j]); ++x) t[hy[i]][x] = true; ret = max(ret, solve(used2, t)); } for(int j=0; j<4; ++j){ int y = hy[i]; int x = hx[i]; while(0 <= y && y < h && 0 <= x && x < w && !s[y][x]){ y += dy[j]; x += dx[j]; } if(0 <= y && y < h && 0 <= x && x < w){ vector<bitset<12> > t = s; y = hy[i]; x = hx[i]; while(!t[y][x]){ t[y][x] = true; y += dy[j]; x += dx[j]; } bitset<6> used2 = used; used2[i] = true; ret = max(ret, solve(used2, t)); } } } return ret; } int main() { for(;;){ cin >> h >> w; if(h == 0) return 0; n = 0; hy.clear(); hx.clear(); for(int i=0; i<h; ++i){ for(int j=0; j<w; ++j){ int a; cin >> a; if(a == 1){ ++ n; hy.push_back(i); hx.push_back(j); } } } cout << solve(0, vector<bitset<12> >(h)) << endl; } }
a.cc: In function 'int main()': a.cc:119:26: error: cannot bind non-const lvalue reference of type 'std::vector<std::bitset<12> >&' to an rvalue of type 'std::vector<std::bitset<12> >' 119 | cout << solve(0, vector<bitset<12> >(h)) << endl; | ^~~~~~~~~~~~~~~~~~~~~~ a.cc:29:48: note: initializing argument 2 of 'int solve(std::bitset<6>, std::vector<std::bitset<12> >&)' 29 | int solve(bitset<6> used, vector<bitset<12> >& s) | ~~~~~~~~~~~~~~~~~~~~~^
s645960744
p00627
Java
while True: n=input() if n==0:break print sum(input() for i in range(n/4))
Main.java:1: error: class, interface, enum, or record expected while True: ^ 1 error
s145670353
p00627
Java
while True: n=input() if n==0:break print sum(input() for i in range(n/4))
Main.java:1: error: class, interface, enum, or record expected while True: ^ 1 error
s228066979
p00627
Java
while True: n=input() if n==0: break print sum(input() for i in range(n/4))
Main.java:1: error: class, interface, enum, or record expected while True: ^ 1 error
s561257649
p00627
C
#include <stdio.h> int main(void) { int n; while (scnaf("%d", &n) * n != 0){ int sum = 0; n /= 4; while (n-- > 0){ int t; scanf("%d", &t); sum += t; } printf("%d\n", sum); } return 0; }
main.c: In function 'main': main.c:7:16: error: implicit declaration of function 'scnaf'; did you mean 'scanf'? [-Wimplicit-function-declaration] 7 | while (scnaf("%d", &n) * n != 0){ | ^~~~~ | scanf
s524779766
p00627
C
#include<stdio.h> int main() { int n,t[100000],k,s; while(1){ scanf("%d",&n); if(n==0)break; s=0; for(k=0;k<(n/4);k++){ scanf("%d",&t[k]); s=s+t[k]; } printf("%d\n",s); }
main.c: In function 'main': main.c:14:3: error: expected declaration or statement at end of input 14 | } | ^
s888487831
p00627
C
#include <stdio.h> int main(void) { int n; int sum=0,a; while(scanf("%d",&n)&&n!=0){ for(i=0;i<n/4;i++){ scanf("%d",&a); sum+=a; } printf("%d\n",sum); sum=0; } return 0 ; }
main.c: In function 'main': main.c:9:21: error: 'i' undeclared (first use in this function) 9 | for(i=0;i<n/4;i++){ | ^ main.c:9:21: note: each undeclared identifier is reported only once for each function it appears in
s501329936
p00627
C
main(l.h.a){for(;scanf("%d",&l),l;printf("%d",h))for(h=0;l>1;l=l-4,h+=a)scanf("%d",a);}
main.c:1:7: error: expected ')' before '.' token 1 | main(l.h.a){for(;scanf("%d",&l),l;printf("%d",h))for(h=0;l>1;l=l-4,h+=a)scanf("%d",a);} | ^ | )
s890896779
p00627
C++
#include<stdio.h> int main(){ int n; int x,s=0; while(1){ scanf("%d",&n); for(int i=0;i<n/4;i++) {scanf("%d",&x); sum+=x;} printf("%d\n",s); s=0; } return 0; }
a.cc: In function 'int main()': a.cc:13:1: error: 'sum' was not declared in this scope 13 | sum+=x;} | ^~~
s835841588
p00627
C++
import java.util.Scanner; import java.util.ArrayList; import java.util.Stack; class Main{ public static void main(String[] args){ Solve s = new Solve(); s.solve(); } } class Solve{ Solve(){} void solve(){ Scanner in = new Scanner(System.in); while(in.hasNext()) { int n = in.nextInt() / 4; if (n == 0) return; int sum = 0; for(int i = 0; i < n; i++){ int t = in.nextInt(); sum += t; } System.out.println(sum); } } }
a.cc:2:1: error: 'import' does not name a type 2 | import java.util.Scanner; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:3:1: error: 'import' does not name a type 3 | import java.util.ArrayList; | ^~~~~~ a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: 'import' does not name a type 4 | import java.util.Stack; | ^~~~~~ a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:8:15: error: expected ':' before 'static' 8 | public static void main(String[] args){ | ^~~~~~~ | : a.cc:8:33: error: 'String' has not been declared 8 | public static void main(String[] args){ | ^~~~~~ a.cc:8:42: error: expected ',' or '...' before 'args' 8 | public static void main(String[] args){ | ^~~~ a.cc:12:2: error: expected ';' after class definition 12 | } | ^ | ; a.cc: In static member function 'static void Main::main(int*)': a.cc:9:17: error: 'Solve' was not declared in this scope 9 | Solve s = new Solve(); | ^~~~~ a.cc:10:17: error: 's' was not declared in this scope 10 | s.solve(); | ^ a.cc: At global scope: a.cc:33:2: error: expected ';' after class definition 33 | } | ^ | ; a.cc: In member function 'void Solve::solve()': a.cc:19:17: error: 'Scanner' was not declared in this scope 19 | Scanner in = new Scanner(System.in); | ^~~~~~~ a.cc:21:23: error: 'in' was not declared in this scope; did you mean 'int'? 21 | while(in.hasNext()) { | ^~ | int a.cc:29:25: error: 'System' was not declared in this scope 29 | System.out.println(sum); | ^~~~~~
s087441002
p00627
C++
import java.io.BufferedReader; import java.io.InputStreamReader; public class Main { public static void main(String[] args) { try { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int num; while ((num = Integer.parseInt(br.readLine())) != 0) { int total = 0; for (int i = 0; i < num; i = i + 4) { int hit = Integer.parseInt(br.readLine()); total += hit; } System.out.println(total); } } catch (Exception e) { System.out.println(e); } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.BufferedReader; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: 'import' does not name a type 2 | import java.io.InputStreamReader; | ^~~~~~ a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:4:1: error: expected unqualified-id before 'public' 4 | public class Main { | ^~~~~~
s054564704
p00627
C++
#include<bits/stdc++.h> using namespace std; int main(){ int n; while(cin>>n,n){ int sum=0; int temp; for(int i=0;i<n/4;++i){ cin>>temp>>endl; sum+=temp; } cout<<sum<<endl; } }
a.cc: In function 'int main()': a.cc:13:20: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and '<unresolved overloaded function type>') 13 | cin>>temp>>endl; | ~~~~~~~~~^~~~~~ In file included from /usr/include/c++/14/sstream:40, from /usr/include/c++/14/complex:45, from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127, 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>]' 170 | operator>>(bool& __n) | ^~~~~~~~ /usr/include/c++/14/istream:170:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'bool&' 170 | operator>>(bool& __n) | ~~~~~~^~~ /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>]' 174 | operator>>(short& __n); | ^~~~~~~~ /usr/include/c++/14/istream:174:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short int&' 174 | operator>>(short& __n); | ~~~~~~~^~~ /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>]' 177 | operator>>(unsigned short& __n) | ^~~~~~~~ /usr/include/c++/14/istream:177:34: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'short unsigned int&' 177 | operator>>(unsigned short& __n) | ~~~~~~~~~~~~~~~~^~~ /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>]' 181 | operator>>(int& __n); | ^~~~~~~~ /usr/include/c++/14/istream:181:23: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'int&' 181 | operator>>(int& __n); | ~~~~~^~~ /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>]' 184 | operator>>(unsigned int& __n) | ^~~~~~~~ /usr/include/c++/14/istream:184:32: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'unsigned int&' 184 | operator>>(unsigned int& __n) | ~~~~~~~~~~~~~~^~~ /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>]' 188 | operator>>(long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:188:24: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long int&' 188 | operator>>(long& __n) | ~~~~~~^~~ /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>]' 192 | operator>>(unsigned long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:192:33: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long unsigned int&' 192 | operator>>(unsigned long& __n) | ~~~~~~~~~~~~~~~^~~ /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>]' 199 | operator>>(long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:199:29: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long int&' 199 | operator>>(long long& __n) | ~~~~~~~~~~~^~~ /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>]' 203 | operator>>(unsigned long long& __n) | ^~~~~~~~ /usr/include/c++/14/istream:203:38: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long long unsigned int&' 203 | operator>>(unsigned long long& __n) | ~~~~~~~~~~~~~~~~~~~~^~~ /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>]' 219 | operator>>(float& __f) | ^~~~~~~~ /usr/include/c++/14/istream:219:25: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'float&' 219 | operator>>(float& __f) | ~~~~~~~^~~ /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>]' 223 | operator>>(double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:223:26: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'double&' 223 | operator>>(double& __f) | ~~~~~~~~^~~ /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>]' 227 | operator>>(long double& __f) | ^~~~~~~~ /usr/include/c++/14/istream:227:31: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'long double&' 227 | operator>>(long double& __f) | ~~~~~~~~~~~~~^~~ /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 '<unresolved overloaded function type>' 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 '<unresolved overloaded function type>' 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 '<unresolved overloaded function type>' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'} 126 | operator>>(__ios_type& (*__pf)(__ios_type&)) | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:133:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(std::ios_base& (*)(std::ios_base&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 133 | operator>>(ios_base& (*__pf)(ios_base&)) | ^~~~~~~~ /usr/include/c++/14/istream:133:30: note: no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::ios_base& (*)(std::ios_base&)' 133 | operator>>(ios_base& (*__pf)(ios_base&)) | ~~~~~~~~~~~~^~~~~~~~~~~~~~~~ /usr/include/c++/14/istream:352:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(__streambuf_type*) [with _CharT = char; _Traits = std::char_traits<char>; __streambuf_type = std::basic_streambuf<char>]' 352 | operator>>(__streambuf_type* __sb); | ^~~~~~~~ /usr/include/c++/14/istream:352:36: note: no known conversion for argument 1 from '<
s251712446
p00627
C++
#include<stdio.h> main(n,k,s){for(;scanf("%d",&n),s=0,n;){for(;n>0;n-=4)scanf("%d",&k),s+=k;printf("%d\n",s);}}
a.cc:2:5: error: expected constructor, destructor, or type conversion before '(' token 2 | main(n,k,s){for(;scanf("%d",&n),s=0,n;){for(;n>0;n-=4)scanf("%d",&k),s+=k;printf("%d\n",s);}} | ^
s882966815
p00627
C++
#include <iostream> using namespace std; int main(){ int i,n,utu,ans=0; while(cin >> n,n){ for(i=0;i<n/4;i++){ cin >> utu; ans += utu } cout << ans << endl; } return 0; }
a.cc: In function 'int main()': a.cc:12:35: error: expected ';' before '}' token 12 | ans += utu | ^ | ; 13 | } | ~
s283245050
p00627
C++
i,a;main(n){for(;scanf("%d",&n),n;a=!printf("%d\n",a))for(;scanf("%d",&i),a+=i,n-=4;);}
a.cc:1:1: error: 'i' does not name a type 1 | i,a;main(n){for(;scanf("%d",&n),n;a=!printf("%d\n",a))for(;scanf("%d",&i),a+=i,n-=4;);} | ^ a.cc:1:9: error: expected constructor, destructor, or type conversion before '(' token 1 | i,a;main(n){for(;scanf("%d",&n),n;a=!printf("%d\n",a))for(;scanf("%d",&i),a+=i,n-=4;);} | ^
s328328631
p00627
C++
while True: n = int(raw_input()) if n == 0: break print sum(int(raw_input()) for i in xrange(n / 4))
a.cc:1:1: error: expected unqualified-id before 'while' 1 | while True: | ^~~~~
s739788605
p00627
C++
#include<iostream> using namespace std; int main() { int n; for(cin>>n,n) { int sum=0; for(;;n=n/5) { int tmp; cin>>tmp; sum+=tmp; } cout<<sum<<endl; } }
a.cc: In function 'int main()': a.cc:6:14: error: expected ';' before ')' token 6 | for(cin>>n,n) | ^ | ; a.cc:18:1: error: expected primary-expression before '}' token 18 | } | ^ a.cc:16:2: error: expected ';' before '}' token 16 | } | ^ | ; 17 | 18 | } | ~ a.cc:18:1: error: expected primary-expression before '}' token 18 | } | ^ a.cc:16:2: error: expected ')' before '}' token 16 | } | ^ | ) 17 | 18 | } | ~ a.cc:6:5: note: to match this '(' 6 | for(cin>>n,n) | ^ a.cc:18:1: error: expected primary-expression before '}' token 18 | } | ^
s003679770
p00628
Java
import java.io.PrintWriter; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); while (true) { String str = sc.nextLine(); if (str.equals("END OF INPUT")) break; String[] strs = str.split(" "); for (int i = 0; i < strs.length; i++) { out.print(strs[i].length()); } out.println(); } out.flush(); sc.close(); }
Main.java:20: error: reached end of file while parsing } ^ 1 error
s755663506
p00628
Java
import java.util.Scanner; public class p1042{ public p1042(){ Scanner sc = new Scanner(System.in); while(true){ String str = sc.nextLine(); if(str.equals("END OF INPUT")){ break; } String[] s = str.split(" "); for(String st: s){ System.out.print(st.length()); } System.out.println(); } } public static void main(String[] args){ p1042 test = new p1042(); } }
Main.java:3: error: class p1042 is public, should be declared in a file named p1042.java public class p1042{ ^ 1 error
s869411690
p00628
Java
import java.util.Scanner; public class p1042{ public p1042(){ Scanner sc = new Scanner(System.in); while(true){ String str = sc.nextLine(); if(str.equals("END OF INPUT")){ break; } str.replaceAll(" ", " sasami "); System.out.println(str); String[] s = str.split(" "); for(String st: s){ if(st.equals("sasami")){ System.out.print("0"); } else { System.out.print(st.length()); } } System.out.println(); } } public static void main(String[] args){ p1042 test = new p1042(); } }
Main.java:3: error: class p1042 is public, should be declared in a file named p1042.java public class p1042{ ^ 1 error
s036135453
p00628
Java
import java.util.*; import java.util.regex.*; public class AOJ1042 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); sc.useDelimiter("\n"); while (true) { String s = sc.next(); if (s.equals("END OF INPUT")) { break; } Matcher m = Pattern.compile("\\w+").matcher(s); while (m.find()) { System.out.print(m.group().length()); } System.out.println(""); } } }
Main.java:5: error: class AOJ1042 is public, should be declared in a file named AOJ1042.java public class AOJ1042 { ^ 1 error
s206149814
p00628
C
char *p,s[999]; main(i){ for(;gets(s),strcmp(p=s,"END OF INPUT");puts("")) for(strcat(s," ");*p;printf("%d",i)) for(i=0;*p++!=' ';i++); }
main.c:2:1: error: return type defaults to 'int' [-Wimplicit-int] 2 | main(i){ | ^~~~ main.c: In function 'main': main.c:2:1: error: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:3:8: error: implicit declaration of function 'gets' [-Wimplicit-function-declaration] 3 | for(;gets(s),strcmp(p=s,"END OF INPUT");puts("")) | ^~~~ main.c:3:16: error: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration] 3 | for(;gets(s),strcmp(p=s,"END OF INPUT");puts("")) | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'strcmp' +++ |+#include <string.h> 1 | char *p,s[999]; main.c:3:43: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration] 3 | for(;gets(s),strcmp(p=s,"END OF INPUT");puts("")) | ^~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'puts' +++ |+#include <stdio.h> 1 | char *p,s[999]; main.c:4:9: error: implicit declaration of function 'strcat' [-Wimplicit-function-declaration] 4 | for(strcat(s," ");*p;printf("%d",i)) | ^~~~~~ main.c:4:9: note: include '<string.h>' or provide a declaration of 'strcat' main.c:4:9: warning: incompatible implicit declaration of built-in function 'strcat' [-Wbuiltin-declaration-mismatch] main.c:4:9: note: include '<string.h>' or provide a declaration of 'strcat' main.c:4:26: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 4 | for(strcat(s," ");*p;printf("%d",i)) | ^~~~~~ main.c:4:26: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:4:26: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:4:26: note: include '<stdio.h>' or provide a declaration of 'printf'
s602431145
p00628
C
#include<stdio.h> #include<string.h> int main(){ int h,i,pre; char s[2000]; while(1){ gets(s); if(strcmp("END OF INPUT",s)==0) break; pre=0; h=strlen(s); for(i=0;i<h+1;i++){ if(s[i]==' '){ printf("%d",i-pre); pre=i+1; if(s[i+1]==' '){ printf("0"); i++; pre++; } } else if(s[i]=='\0'){ printf("%d",i-pre); break; } } printf("\n"); } return 0; }
main.c: In function 'main': main.c:7:17: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration] 7 | gets(s); | ^~~~ | fgets
s039364128
p00628
C
c; int main(i) { char s[999]; for(;;printf("%d\n",c-1)) { fgets(s,999,stdin); if(!strcmp(s,"END OF INPUT")) exit(0); for(c=i=0;s[i]!='\0';c++) if(s[i++]==' ') printf("%d",c),c=-1; } }
main.c:1:1: warning: data definition has no type or storage class 1 | c; | ^ main.c:1:1: error: type defaults to 'int' in declaration of 'c' [-Wimplicit-int] main.c: In function 'main': main.c:2:5: error: type of 'i' defaults to 'int' [-Wimplicit-int] 2 | int main(i) | ^~~~ main.c:5:9: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 5 | for(;;printf("%d\n",c-1)) | ^~~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'printf' +++ |+#include <stdio.h> 1 | c; main.c:5:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] 5 | for(;;printf("%d\n",c-1)) | ^~~~~~ main.c:5:9: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:7:7: error: implicit declaration of function 'fgets' [-Wimplicit-function-declaration] 7 | fgets(s,999,stdin); | ^~~~~ main.c:7:19: error: 'stdin' undeclared (first use in this function) 7 | fgets(s,999,stdin); | ^~~~~ main.c:7:19: note: 'stdin' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>' main.c:7:19: note: each undeclared identifier is reported only once for each function it appears in main.c:8:11: error: implicit declaration of function 'strcmp' [-Wimplicit-function-declaration] 8 | if(!strcmp(s,"END OF INPUT")) | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'strcmp' +++ |+#include <string.h> 1 | c; main.c:9:9: error: implicit declaration of function 'exit' [-Wimplicit-function-declaration] 9 | exit(0); | ^~~~ main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit' +++ |+#include <stdlib.h> 1 | c; main.c:9:9: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch] 9 | exit(0); | ^~~~ main.c:9:9: note: include '<stdlib.h>' or provide a declaration of 'exit'
s847130849
p00628
C
c; main(i) { char s[99]; for(;fgets(s,99,stdin),c=i=!strstr(s,"END OF INPUT");printf("%d\n",c-1)) for(;s[i]!=0;) c=s[i++]-32?c+1:!printf("%d",c); }
main.c:2:1: warning: data definition has no type or storage class 2 | c; | ^ main.c:2:1: error: type defaults to 'int' in declaration of 'c' [-Wimplicit-int] main.c:3:1: error: return type defaults to 'int' [-Wimplicit-int] 3 | main(i) | ^~~~ main.c: In function 'main': main.c:3:1: error: type of 'i' defaults to 'int' [-Wimplicit-int] main.c:6:8: error: implicit declaration of function 'fgets' [-Wimplicit-function-declaration] 6 | for(;fgets(s,99,stdin),c=i=!strstr(s,"END OF INPUT");printf("%d\n",c-1)) | ^~~~~ main.c:6:19: error: 'stdin' undeclared (first use in this function) 6 | for(;fgets(s,99,stdin),c=i=!strstr(s,"END OF INPUT");printf("%d\n",c-1)) | ^~~~~ main.c:1:1: note: 'stdin' is defined in header '<stdio.h>'; this is probably fixable by adding '#include <stdio.h>' +++ |+#include <stdio.h> 1 | main.c:6:19: note: each undeclared identifier is reported only once for each function it appears in 6 | for(;fgets(s,99,stdin),c=i=!strstr(s,"END OF INPUT");printf("%d\n",c-1)) | ^~~~~ main.c:6:31: error: implicit declaration of function 'strstr' [-Wimplicit-function-declaration] 6 | for(;fgets(s,99,stdin),c=i=!strstr(s,"END OF INPUT");printf("%d\n",c-1)) | ^~~~~~ main.c:1:1: note: include '<string.h>' or provide a declaration of 'strstr' +++ |+#include <string.h> 1 | main.c:6:31: warning: incompatible implicit declaration of built-in function 'strstr' [-Wbuiltin-declaration-mismatch] 6 | for(;fgets(s,99,stdin),c=i=!strstr(s,"END OF INPUT");printf("%d\n",c-1)) | ^~~~~~ main.c:6:31: note: include '<string.h>' or provide a declaration of 'strstr' main.c:6:56: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 6 | for(;fgets(s,99,stdin),c=i=!strstr(s,"END OF INPUT");printf("%d\n",c-1)) | ^~~~~~ main.c:6:56: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:6:56: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:6:56: note: include '<stdio.h>' or provide a declaration of 'printf'
s980818823
p00628
C
#include <stdio.h>c;main(i){char s[99];for(;fgets(s,99,stdin),c=i=!strstr(s,"END OF INPUT");printf("%d\n",c-1))for(;s[i];)c=s[i++]-32?c+1:!printf("%d",c);}
main.c:1:19: warning: extra tokens at end of #include directive 1 | #include <stdio.h>c;main(i){char s[99];for(;fgets(s,99,stdin),c=i=!strstr(s,"END OF INPUT");printf("%d\n",c-1))for(;s[i];)c=s[i++]-32?c+1:!printf("%d",c);} | ^ /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s347937096
p00628
C
#include <stdio.h> #include <string.h> #include <time.h> char s[16]; int main(void){ clock_t c1 = clock(); int cnt = 0; for(; scanf("%s", s) != EOF ){ if( strcmp(s, "END") == 0 ) ++cnt; } clock_t c2 = c1 + CLOCKS_PER_SEC * 0.02 * cnt; while( c2 > clock() ); return 0; }
main.c: In function 'main': main.c:10:37: error: expected ';' before ')' token 10 | for(; scanf("%s", s) != EOF ){ | ^
s112418721
p00628
C
#include<stdio.h> #include<string.h> char str[1000000],buf[10]; int t,i; int main() { for(;gets(str),!strstr(str,"END OF INPUT");) { for(i=t=0;str[i];i++) { for(;str[i]&&str[i]!=' ';i++); if(t!=i) printf("%d",i-t); t=i; for(;str[i]&&str[i]==' ';i++); if(i-t>1) for(int j=0;j<i-t;j++) putchar('0'); t=i; } memset(str,0,sizeof(str)); puts(""); } return 0; }
main.c: In function 'main': main.c:7:14: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration] 7 | for(;gets(str),!strstr(str,"END OF INPUT");) | ^~~~ | fgets
s337749511
p00628
C
#include<stdio.h> #include<string.h> char str[1000000],buf[10]; int t,i,j; int main() { for(;gets(str),!strstr(str,"END OF INPUT");) { for(i=t=0;str[i];i++) { for(;str[i]&&str[i]!=' ';i++); if(t!=i) printf("%d",i-t); t=i; for(;str[i]&&str[i]==' ';i++); if(i-t>1) for(int j=0;j<i-t;j++) putchar('0'); t=i; } memset(str,0,sizeof(str)); puts(""); } return 0; }
main.c: In function 'main': main.c:7:14: error: implicit declaration of function 'gets'; did you mean 'fgets'? [-Wimplicit-function-declaration] 7 | for(;gets(str),!strstr(str,"END OF INPUT");) | ^~~~ | fgets
s811784881
p00628
C++
#include <iostream> using namespace std; int main(){ string a; while (getline(cin,a)&&a!="END OF INPUT"){ int num=0; for(int i=0;i<a.length();++i){ if(a[i]==" ") cout << num,num=0; else num++; } cout << endl; } }
a.cc: In function 'int main()': a.cc:10:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 10 | if(a[i]==" ") cout << num,num=0;
s778918513
p00628
C++
#include <iostream> using namespace std; int main(){ string a; while (getline(cin,a)&&a!="END OF INPUT"){ int num=0; for(int i=0;i<a.length();++i){ if(a[i]==" ") { cout << num; num=0; }else num++; } cout << endl; } }
a.cc: In function 'int main()': a.cc:10:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 10 | if(a[i]==" ") {
s314185637
p00628
C++
#include <iostream> using namespace std; int main(){ string a; while (getline(cin,a)&&a!="END OF INPUT"){ int num=0; for(int i=0;i<a.length();++i){ if(*a[i]==" ") { cout << num; num=0; }else num++; } cout << endl; } }
a.cc: In function 'int main()': a.cc:10:16: error: invalid type argument of unary '*' (have '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'}) 10 | if(*a[i]==" ") {
s224962552
p00628
C++
#include <iostream> using namespace std; int main(){ string a; while (getline(cin,a)&&a!="END OF INPUT"){ int num=0; for(int i=0;i<a.length();++i){ if(a[i]==" ") { cout << num; num=0; }else num++; } cout << cnt << endl; } }
a.cc: In function 'int main()': a.cc:10:20: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 10 | if(a[i]==" ") { a.cc:15:17: error: 'cnt' was not declared in this scope; did you mean 'int'? 15 | cout << cnt << endl; | ^~~ | int
s680039444
p00628
C++
#include <iostream> using namespace std; int main(){ string a; while (getline(cin,a)&&a!="END OF INPUT"){ int num=0; for(int i=0;i<a.length();++i){ if(a[i]==' ') { cout << num; num=0; }else num++; } cout << cnt << endl; } }
a.cc: In function 'int main()': a.cc:15:17: error: 'cnt' was not declared in this scope; did you mean 'int'? 15 | cout << cnt << endl; | ^~~ | int
s902848987
p00628
C++
#include <iostream> #include <algorithm> #include <string> using namespace std; int main() { string s; while (getline(cin, s), s == "END OF INPUT") { for (int i = 0, n = 0; i < s.length; i++) { if (i == s.length -1 || s[i] == ' ') { cout << n; } else { n++; } } cout << endl; } return 0; }
a.cc: In function 'int main()': a.cc:9:46: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::length() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?) 9 | for (int i = 0, n = 0; i < s.length; i++) { | ~~^~~~~~ | () a.cc:10:36: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::length() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?) 10 | if (i == s.length -1 || s[i] == ' ') { | ~~^~~~~~ | ()
s120228285
p00628
C++
#include <iostream> using namespace std; int main(){ string s; int temp; whlie(true){ getline(cin,s); if(s=="END OF INPUT")return 0; temp=0; for(int i=0;i<s.size();i++){ if(s[i]==' '){ printf("%d",temp); temp=0; } else temp++; } printf("%d\n",temp); } }
a.cc: In function 'int main()': a.cc:6:5: error: 'whlie' was not declared in this scope 6 | whlie(true){ | ^~~~~
s303031593
p00628
C++
#include <iostream> #include <stdio.h> using namespace std; int main(){ string s; int temp; whlie(true){ getline(cin,s); if(s=="END OF INPUT")return 0; temp=0; for(int i=0;i<s.size();i++){ if(s[i]==' '){ printf("%d",temp); temp=0; } else temp++; } printf("%d\n",temp); } }
a.cc: In function 'int main()': a.cc:7:5: error: 'whlie' was not declared in this scope 7 | whlie(true){ | ^~~~~
s868484528
p00628
C++
#include<iostream> #include<string> int main(){std::string s;while(1){std::getline(cin,s);if(s=="END OF INPUT")break;int t=0;for(int i=0;i<s.length();i++)if(s.at(i)==' ')std::cout<<t,t=0;else t++;std::cout<<t<<"\n";}}
a.cc: In function 'int main()': a.cc:3:48: error: 'cin' was not declared in this scope; did you mean 'std::cin'? 3 | int main(){std::string s;while(1){std::getline(cin,s);if(s=="END OF INPUT")break;int t=0;for(int i=0;i<s.length();i++)if(s.at(i)==' ')std::cout<<t,t=0;else t++;std::cout<<t<<"\n";}} | ^~~ | std::cin In file included from a.cc:1: /usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here 62 | extern istream cin; ///< Linked to standard input | ^~~
s323641160
p00628
C++
#include<iostream> using namespace std; int main(void){ char w[100],end[12]={"END OF INPUT"}; int i; int cnt; while(1){ cnt=0; cin.getline(w,sizeof(w)); for(i=0;i<12;i++){ if(w[i]!=end[i]) break; else return 0; } for(i=0;w[i]!='\0';i++){ if(w[i]==' '){ cout<<cnt; cnt=0; if(w[i+1]==' '){ cout<<cnt; i+=2; } continue; } cnt++; } cout<<cnt<<endl; } }
a.cc: In function 'int main()': a.cc:4:30: error: initializer-string for 'char [12]' is too long [-fpermissive] 4 | char w[100],end[12]={"END OF INPUT"}; | ^~~~~~~~~~~~~~
s381373299
p00628
C++
#include<cstdio> #include<cstring> using namespace std; int main(){ char s[1000]; int n,i; for(;gets(s),strpbrk(s,"END OF INPUT");) for(n=i=0;i<strlen(s);i++) i==strlen(s)-1?printf("%d\n",n+1):s[i]==' '?printf("%d",n),n=0:n++; }
a.cc: In function 'int main()': a.cc:7:14: error: 'gets' was not declared in this scope; did you mean 'getw'? 7 | for(;gets(s),strpbrk(s,"END OF INPUT");) | ^~~~ | getw
s682409208
p00628
C++
#include <iostream> #include <string> using namespace std; int main(){ string str; while(cin >> str){ if(str == "END_OF_INPUT") break; str += " "; int idx = 0; while(idx < str.size()){ int cnt = 0; while(str[idx++]!=" ") cnt++; cout << cnt; } cout << endl; } }
a.cc: In function 'int main()': a.cc:14:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 14 | while(str[idx++]!=" ") cnt++;
s383656351
p00628
C++
#include <iostream> #include <string> using namespace std; int main(){ string str; while(getline(ciin, str)){ if(str == "END OF INPUT") break; int idx = 0; while(idx < str.size()){ int cnt = 0; while(idx < str.size() && str[idx++]!=' ') cnt++; cout << cnt; } cout << endl; } }
a.cc: In function 'int main()': a.cc:8:17: error: 'ciin' was not declared in this scope 8 | while(getline(ciin, str)){ | ^~~~
s263890940
p00628
C++
import java.io.*; public class aoj1042 { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s; while(true){ s = br.readLine(); if(s.equals("END OF INPUT")) break; String[] ss = s.split(" "); for(int i=0;i<ss.length;i++) System.out.print(ss[i].length()); System.out.println(); } } }
a.cc:1:1: error: 'import' does not name a type 1 | import java.io.*; | ^~~~~~ a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts' a.cc:2:1: error: expected unqualified-id before 'public' 2 | public class aoj1042 { | ^~~~~~
s772323048
p00629
Java
import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); P1043_Selecting_Teams_Advanced_to_Regional p = new P1043_Selecting_Teams_Advanced_to_Regional(); int n; Team t; ArrayList<Team> at; while(true){ n = sc.nextInt(); at = new ArrayList<P1043_Selecting_Teams_Advanced_to_Regional.Team>(); if(n == 0){ break; } for(int i=0;i<n;i++){ t = p.new Team(); t.id = sc.nextInt(); t.school = sc.nextInt(); t.solve = sc.nextInt(); t.wa = sc.nextInt(); at.add(t); } Collections.sort(at, new Comparator<P1043_Selecting_Teams_Advanced_to_Regional.Team>() { public int compare(Team t1, Team t2){ String t1str = String.format("$1%2s$2%6s$3%4s", t1.solve,100000-t1.wa,1000-t1.id); String t2str = String.format("$1%2s$2%6s$3%4s", t2.solve,100000-t2.wa,1000-t2.id); return t2str.compareTo(t1str); } }); HashMap<Integer,Integer> hm = new HashMap<Integer, Integer>(); int count=0; while(!at.isEmpty()){ if(hm.get(at.get(0).school) == null){ hm.put(at.get(0).school,1); System.out.println(at.get(0).id); at.remove(0); count++; }else{ switch(hm.get(at.get(0).school)){ case 1: if(count < 20){ hm.put(at.get(0).school,2); System.out.println(at.get(0).id); at.remove(0); count++; }else{ at.remove(0); } break; case 2: if(count < 10){ hm.put(at.get(0).school,3); System.out.println(at.get(0).id); at.remove(0); count++; }else{ at.remove(0); } break; case 3: at.remove(0); } } if(count == 26){ break; } } } } public class Team{ public int id; public int school; public int solve; public int wa; } }
Main.java:11: error: cannot find symbol P1043_Selecting_Teams_Advanced_to_Regional p = new P1043_Selecting_Teams_Advanced_to_Regional(); ^ symbol: class P1043_Selecting_Teams_Advanced_to_Regional location: class Main Main.java:11: error: cannot find symbol P1043_Selecting_Teams_Advanced_to_Regional p = new P1043_Selecting_Teams_Advanced_to_Regional(); ^ symbol: class P1043_Selecting_Teams_Advanced_to_Regional location: class Main Main.java:19: error: package P1043_Selecting_Teams_Advanced_to_Regional does not exist at = new ArrayList<P1043_Selecting_Teams_Advanced_to_Regional.Team>(); ^ Main.java:34: error: package P1043_Selecting_Teams_Advanced_to_Regional does not exist Collections.sort(at, new Comparator<P1043_Selecting_Teams_Advanced_to_Regional.Team>() { ^ 4 errors
s279879429
p00629
C++
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start': (.text+0x17): undefined reference to `main' collect2: error: ld returned 1 exit status
s349464623
p00629
C++
#include <iostream> #include <vector> #include <cmath> using namespace std; struct Team { int id; int uni; int solved; int penalty; bool selected; bool operator<(const Team& another) const { if(solved != another.solved) { return (solved > another.solved); } if (penalty != another.penalty) { return (penalty < another.penalty); } return id < another.id; } }; int selectedCounts[1001]; int main() { int n; while(true) { cin >> n; if (n == 0) { break; } vector<Team> teams(n); for (int i = 0; i < n; i++) { cin >> teams[i].id >> teams[i].uni >> teams[i].solved >> teams[i].penalty; teams[i].selected = false; } for (int i = 0; i < 1001; i++) { selectedCounts[i] = 0; } sort(teams.begin(), teams.end()); int entireSelectedCount = 0; for (int i = 0; i < n; i++) { if(entireSelectedCount < 10 && selectedCounts[teams[i].uni] < 3 || entireSelectedCount < 20 && selectedCounts[teams[i].uni] < 2 || entireSelectedCount < 26 && selectedCounts[teams[i].uni] < 1) { selectedCounts[teams[i].uni]++; entireSelectedCount++; cout << teams[i].id << endl; } } } return 0; }
a.cc: In function 'int main()': a.cc:44:17: error: 'sort' was not declared in this scope; did you mean 'sqrt'? 44 | sort(teams.begin(), teams.end()); | ^~~~ | sqrt