submission_id
stringlengths
10
10
problem_id
stringlengths
6
6
language
stringclasses
3 values
code
stringlengths
1
522k
compiler_output
stringlengths
43
10.2k
s353077352
p00461
C++
#include<cstdio> main(){int n,m,i,a,c[1000001];for(std::string s;std::cin>>n>>m>>s,n;printf("%d\n",a))for(a=0,i=m;--i;a+=c[i]>=n)c[i]=s.substr(i,3)=="IOI"?c[i+2]+1:0;}
a.cc:2:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 2 | main(){int n,m,i,a,c[1000001];for(std::string s;std::cin>>n>>m>>s,n;printf("%d\n",a))for(a=0,i=m;--i;a+=c[i]>=n)c[i]=s.substr(i,3)=="IOI"?c[i+2]+1:0;} | ^~~~ a.cc: In function 'int main()': a.cc:2:40: error: 'string' is not a member of 'std' 2 | main(){int n,m,i,a,c[1000001];for(std::string s;std::cin>>n>>m>>s,n;printf("%d\n",a))for(a=0,i=m;--i;a+=c[i]>=n)c[i]=s.substr(i,3)=="IOI"?c[i+2]+1:0;} | ^~~~~~ a.cc:2:1: note: 'std::string' is defined in header '<string>'; this is probably fixable by adding '#include <string>' 1 | #include<cstdio> +++ |+#include <string> 2 | main(){int n,m,i,a,c[1000001];for(std::string s;std::cin>>n>>m>>s,n;printf("%d\n",a))for(a=0,i=m;--i;a+=c[i]>=n)c[i]=s.substr(i,3)=="IOI"?c[i+2]+1:0;} a.cc:2:54: error: 'cin' is not a member of 'std' 2 | main(){int n,m,i,a,c[1000001];for(std::string s;std::cin>>n>>m>>s,n;printf("%d\n",a))for(a=0,i=m;--i;a+=c[i]>=n)c[i]=s.substr(i,3)=="IOI"?c[i+2]+1:0;} | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include<cstdio> +++ |+#include <iostream> 2 | main(){int n,m,i,a,c[1000001];for(std::string s;std::cin>>n>>m>>s,n;printf("%d\n",a))for(a=0,i=m;--i;a+=c[i]>=n)c[i]=s.substr(i,3)=="IOI"?c[i+2]+1:0;} a.cc:2:65: error: 's' was not declared in this scope 2 | main(){int n,m,i,a,c[1000001];for(std::string s;std::cin>>n>>m>>s,n;printf("%d\n",a))for(a=0,i=m;--i;a+=c[i]>=n)c[i]=s.substr(i,3)=="IOI"?c[i+2]+1:0;} | ^
s520259838
p00461
C++
#include<iostream> #include<string> using namespace std; int main(){ int n,m,ans; string a,b; char s[1000000]; while(cin>>n){ ans=0; a="I"; for(int i=0;i<n;i++){ a+="OI";} cin>>m; for(int i=0;i<m;i++){ cin>>s[i];} for(int i=0;i<m-2n-1;i++){ b=""; if(s[i]="I"){ for(int j=i;j<2n+i+1;j++){ b+=s[j];}} if(a==b){ans++;} cout<<ans<<endl;}}
a.cc: In function 'int main()': a.cc:17:17: error: unable to find numeric literal operator 'operator""n' 17 | for(int i=0;i<m-2n-1;i++){ | ^~ a.cc:19:9: error: invalid conversion from 'const char*' to 'char' [-fpermissive] 19 | if(s[i]="I"){ | ^~~ | | | const char* a.cc:20:15: error: unable to find numeric literal operator 'operator""n' 20 | for(int j=i;j<2n+i+1;j++){ | ^~ a.cc:23:19: error: expected '}' at end of input 23 | cout<<ans<<endl;}} | ^ a.cc:5:11: note: to match this '{' 5 | int main(){ | ^
s426130370
p00461
C++
#include <string> #include <vector> using namespace std; vector<int> V; int main() { int n,m; while(cin>>n,n) { cin>>m; string str; cin>>str; V.clear(); int i; for(i=0;i<(m-2);i++) { if(str.substr(i,3)=="IOI") { int count=1; for(i+=3;i<(m-1);i+=2) { if(str.substr(i,2)=="OI") count++; else break; } V.push_back(count); i--; } } int sum=0; for(i=0;i<V.size();i++) { if(V[i]>=n) sum+=(V[i]-n+1); } cout<<sum<<endl; } }
a.cc: In function 'int main()': a.cc:7:15: error: 'cin' was not declared in this scope 7 | while(cin>>n,n) { | ^~~ a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 2 | #include <vector> +++ |+#include <iostream> 3 | using namespace std; a.cc:27:17: error: 'cout' was not declared in this scope 27 | cout<<sum<<endl; | ^~~~ a.cc:27:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:27:28: error: 'endl' was not declared in this scope 27 | cout<<sum<<endl; | ^~~~ a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 2 | #include <vector> +++ |+#include <ostream> 3 | using namespace std;
s421473108
p00462
C
#include <stdio.h> #include <stdlib.h> #define D_MAX 1000000000 #define N_MAX 100000 #define M_MAX 10000 #define TRUE 1 #define FALSE 0 int ad[N_MAX+1]; int ak[M_MAX+1]; int awork[N_MAX+1]; /* 配列 x[ ] の left から right の要素のマージソートを行う */ void MergeSort(int x[ ], int left, int right) { int mid, i, j, k; if (left >= right) /* 配列の要素がひとつなら */ return; /* 何もしないで戻る */ /* ここでは分割しているだけ */ mid = (left + right) / 2; /* 中央の値より */ MergeSort(x, left, mid); /* 左を再帰呼び出し */ MergeSort(x, mid + 1, right); /* 右を再帰呼び出し */ /* x[left] から x[mid] を作業領域にコピー */ for (i = left; i <= mid; i++) awork[i] = x[i]; /* x[mid + 1] から x[right] は逆順にコピー */ for (i = mid + 1, j = right; i <= right; i++, j--) awork[i] = x[j]; i = left; /* i とj は作業領域のデーターを */ j = right; /* k は配列の要素を指している */ for (k = left; k <= right; k++) /* 小さい方から配列に戻す */ if (awork[i] <= awork[j]) /* ここでソートされる */ x[k] = awork[i++]; else x[k] = awork[j--]; } void input(void){ int i; scanf("%d",&d); if( d != 0){ scanf("%d",&n); scanf("%d",&m); ad[1] = 0; for( i=2; i<=n; i++){ scanf("%d",&ad[i]); } for( i=1; i<=m; i++){ scanf("%d",&ak[i]); } } } int main(void){ int i; int sumDist = 0; while( 1 ){ input(); if( d == 0 ){ break; } MergeSort( ad, 1, n); for( i=1; i<=m; i++){ sumDist += calcDist(ak[i]); } printf("%d\n",sumDist); sumDist = 0; } }
main.c: In function 'input': main.c:47:21: error: 'd' undeclared (first use in this function) 47 | scanf("%d",&d); | ^ main.c:47:21: note: each undeclared identifier is reported only once for each function it appears in main.c:49:29: error: 'n' undeclared (first use in this function) 49 | scanf("%d",&n); | ^ main.c:50:29: error: 'm' undeclared (first use in this function) 50 | scanf("%d",&m); | ^ main.c: In function 'main': main.c:66:21: error: 'd' undeclared (first use in this function) 66 | if( d == 0 ){ | ^ main.c:69:35: error: 'n' undeclared (first use in this function) 69 | MergeSort( ad, 1, n); | ^ main.c:70:30: error: 'm' undeclared (first use in this function) 70 | for( i=1; i<=m; i++){ | ^ main.c:71:36: error: implicit declaration of function 'calcDist' [-Wimplicit-function-declaration] 71 | sumDist += calcDist(ak[i]); | ^~~~~~~~
s961206147
p00462
C
#include <stdio.h> #include <stdlib.h> #define D_MAX 1000000000 #define N_MAX 100000 #define M_MAX 10000 #define min(x,y) (((x)<(y))?(x):(y)) int d; int n; int m; int ad[N_MAX+1]; int ak[M_MAX+1]; int temp[N_MAX+1]; void MergeSort(int array[],int left,int right){ int awork[N_MAX+1]; int mid; int i; int j; int x; int y; if( left >= right ){ return; } mid = (left + right) / 2; MergeSort( array, left, mid); MergeSort( array, mid+1, right); for( i=left; i<=mid; i++){ awork[i] = array[i]; } j = right; for( i=mid+1; i<=right; i++){ awork[i] = array[j]; j--; } x = left; y = right; for( i=left; i<=right; i++){ if(awork[x] <= awork[y]){ array[i] = awork[x]; x++; }else{ array[i] = awork[y]; y--; } } } int calcDist(int k){ int i; int j = 0; int sum = 0; int diff; int preDiff = 0; int minDist = d; int tmpDist; int halfDist = d >> 1; for( i=1; i<=m; i++){ while(ad[j] > ak[i]){ j++; } minDist = min( abs(ad[j-1]-ak[i]),abs(ad[j]-ak[i]) ); sum += minDist; } return sum; } void input(void){ int i; scanf("%d",&d); if( d != 0){ scanf("%d",&n); scanf("%d",&m); ad[0] = 0; for( i=1; i<=n-1; i++){ scanf("%d",&ad[i]); } ad[n] = d; for( i=1; i<=m; i++){ scanf("%d",&ak[i]); } } } int main(void){ int i; int sumDist = 0; while( 1 ){ input(); if( d == 0 ){ break; } MergeSort( ad, 0, n); MergeSort( ak, 1, m) for( i=1; i<=m; i++){ sumDist += calcDist(ak[i]); } printf("%d\n",sumDist); sumDist = 0; } }
main.c: In function 'main': main.c:104:25: error: expected ';' before 'for' 104 | MergeSort( ak, 1, m) | ^ | ; 105 | for( i=1; i<=m; i++){ | ~~~
s767122503
p00462
C
#include<stdio.h> #include<stdlib.h> #include<string.h> int i,j,k; int d,n,m,a[1000000005],x,ans=0; int main(){ scanf("%d",&d); while(d!=0){ for(i=0;i<=d;i++)a[i]=0; a[0]=1,a[d]=1; scanf("%d",&n); scanf("%d",&m); for(i=0;i<n-1;i++){ scanf("%d",&x); a[x]=1; } for(i=0;i<m;i++){ scanf("%d",&x); j=0; while(a[x-j]==0)j++,ans++; } printf("%d",ans); ans=0; scanf("%d",&d); } return 0; }
/tmp/ccoTc3b4.o: in function `main': main.c:(.text+0xe3): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccoTc3b4.o main.c:(.text+0x100): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccoTc3b4.o main.c:(.text+0x14d): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccoTc3b4.o main.c:(.text+0x185): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccoTc3b4.o main.c:(.text+0x18e): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccoTc3b4.o main.c:(.text+0x194): relocation truncated to fit: R_X86_64_PC32 against symbol `x' defined in .bss section in /tmp/ccoTc3b4.o main.c:(.text+0x1de): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccoTc3b4.o main.c:(.text+0x1fa): relocation truncated to fit: R_X86_64_PC32 against symbol `ans' defined in .bss section in /tmp/ccoTc3b4.o collect2: error: ld returned 1 exit status
s879295000
p00462
C
#include<stdio.h> #include<stdlib.h> #include<string.h> int i,j,k; int d,n,m,a[100005],b[10005],x,ans=0; int Min,Max,Mid; int comp(const void *p,const void *q){ return *(int *)p-*(int *)q; } int main(){ scanf("%d",&d); while(d!=0){ scanf("%d",&n); scanf("%d",&m); for(i=1;i<=n-1;i++)scanf("%d",&a[i]); a[0]=0,a[n]=d; for(i=0;i<m;i++)scanf("%d",&b[i]); qsort(a,n+1,sizeof(int),comp); //for(i=0;i<=n;i++)printf("%d ",a[i]); ans=0; for(i=0;i<m;i++)8{ Min=0;Max=n; while(Max-Min>=1){ Mid=(Min+Max)/2; if(a[Mid]==b[i])break; else if(a[Mid]>b[i])Max=Mid; else Min=Mid+1; } if(b[i]-a[Mid]>a[Mid+1]-b[i])ans+=a[Mid+1]-b[i]; else ans+=b[i]-a[Mid]; //printf("%d ",ans); } printf("%d",ans); ans=0; scanf("%d",&d); } return 0; }
main.c: In function 'main': main.c:23:34: error: expected ';' before '{' token 23 | for(i=0;i<m;i++)8{ | ^ | ;
s869728785
p00462
C
#include<stdio.h> #include<stdlib.h> #include<string.h> int i,j,k; __int64 d,n,m,a[100005],b[10005],x,ans=0; __int64 p,q,r; int comp(const void *p,const void *q){ return *(__int64 *)p-*(__int64 *)q; } int main(){ scanf("%lld",&d); while(d!=0){ scanf("%lld",&n); scanf("%lld",&m); for(i=1;i<=n-1;i++)scanf("%lld",&a[i]); a[0]=0,a[n]=d; for(i=0;i<m;i++)scanf("%lld",&b[i]); qsort(a,n+1,sizeof(__int64),comp); //for(i=0;i<=n;i++)printf("%d ",a[i]); ans=0; for(i=0;i<m;i++){ p=0;q=n; while(q-p>=1){ r=(p+q)/2; if(a[r]==b[i])break; else if(a[r]>b[i])q=r; else p=r+1; } if(b[i]-a[r]>a[r+1]-b[i])ans+=a[r+1]-b[i]; else ans+=b[i]-a[r]; //printf("%d ",ans); } printf("%lld",ans); ans=0; scanf("%lld",&d); } return 0; }
main.c:6:1: error: unknown type name '__int64'; did you mean '__int64_t'? 6 | __int64 d,n,m,a[100005],b[10005],x,ans=0; | ^~~~~~~ | __int64_t main.c:7:1: error: unknown type name '__int64'; did you mean '__int64_t'? 7 | __int64 p,q,r; | ^~~~~~~ | __int64_t main.c: In function 'comp': main.c:9:18: error: '__int64' undeclared (first use in this function); did you mean '__int64_t'? 9 | return *(__int64 *)p-*(__int64 *)q; | ^~~~~~~ | __int64_t main.c:9:18: note: each undeclared identifier is reported only once for each function it appears in main.c:9:27: error: expected expression before ')' token 9 | return *(__int64 *)p-*(__int64 *)q; | ^ main.c: In function 'main': main.c:20:36: error: '__int64' undeclared (first use in this function); did you mean '__int64_t'? 20 | qsort(a,n+1,sizeof(__int64),comp); | ^~~~~~~ | __int64_t
s271581084
p00462
C
#include<stdio.h> #include<algorithm> int*t,p="%d\n",n,m,d,i,s[99999];main(){for(;scanf("%d%d%d",&d,&n,&m),s[i=n]=d;printf(p,i)){for(;--i;)scanf(p,s+i);for(std::sort(s,s+n);m--;i+=std::min(*t-d,d-t[-1]))scanf(p,&d),t=std::upper_bound(s,s+n,d);}}
main.c:2:9: fatal error: algorithm: No such file or directory 2 | #include<algorithm> | ^~~~~~~~~~~ compilation terminated.
s114448640
p00462
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
s359428545
p00462
C++
#include <bits/stdc++.h> using namespace std; typedef long long int ll; typedef pair<ll,ll> pll; #define FOR(i,n,m) for(ll (i)=(m);(i)<(n);++(i)) #define REP(i,n) FOR(i,n,0) #define OF64 std::setprecision(10) const ll MOD = 1000000007; const ll INF = (ll)1e15; ll d[100005]; int main() { while(true) { ll D,N,M; cin>>D if(D==0)break; cin>>N>>M; d[0]=0; REP(i,N-1) { cin>>d[i+1]; } sort(d,d+N); ll sum=0; REP(i,M) { ll k; cin>>k; int ok=0,ng=N; while(abs(ng-ok)>1) { int mid=(ok+ng)/2; if(d[mid]<=k) { ok=mid; } else { ng=mid; } } sum+=min(k-d[ok],abs((D+d[(ok+1)%N])-k)%D); } cout<<sum<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:20:11: error: expected ';' before 'if' 20 | cin>>D | ^ | ; 21 | if(D==0)break; | ~~
s256672049
p00462
C++
#include <map> #include <set> #include <cmath> #include <queue> #include <stack> #include <cctype> #include <cstdio> #include <string> #include <vector> #include <cstdlib> #include <cstring> #include <sstream> #include <iostream> #include <algorithm> #include <functional> #define INF (2 << 28) #define fr first #define sc second using namespace std; typedef long long ll; typedef pair<int, int> iP; int n, d, m, k[100001]; int main(){ whlie(cin >> d >> n >> m, d){ k[0] = 0; for(int i = 1; i < n; i++) cin >> k[i]; int sum = 0; for(int i = 0; i < m; i++){ int q; cin >> q; int ret = INF; for(int j = 0; j < n; j++){ ret = min(ret, min(abs(q - k[j]), k[j] + (d - q))); } sum += ret; // cout << sum << endl; } cout << sum << endl; } }
a.cc: In function 'int main()': a.cc:29:7: error: 'whlie' was not declared in this scope 29 | whlie(cin >> d >> n >> m, d){ | ^~~~~
s584779970
p00462
C++
#include<string.h> #include<vector> #include<queue> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) const int INF=1001001001; int map[10][10000];//0???????????? int main(){ while(1){ int d,n,m;//????????¨?????????????????°?????¨???????????° int N[100002]; scanf("%d",&d); if(d==0)break; scanf("%d %d",&n,&m); N[0]=0; rep(i,n-1){scanf("%d",&N[i+1]);} sort(N,N+n); N[n]=d;//??¬?????????????°?????????? long long int ans=0; rep(i,m){ int t; scanf("%d",&t); int a=lower_bound(N,N+n+1,t)-N; if(a==0)ans+=N[a]-t; else{ if(t-N[a-1]<=N[a]-t)ans+=t-N[a-1]; else ans+=N[a]-t; } } printf("%lld\n",ans); } }
a.cc: In function 'int main()': a.cc:18:17: error: 'scanf' was not declared in this scope 18 | scanf("%d",&d); | ^~~~~ a.cc:24:17: error: 'sort' was not declared in this scope; did you mean 'short'? 24 | sort(N,N+n); | ^~~~ | short a.cc:37:17: error: 'printf' was not declared in this scope 37 | printf("%lld\n",ans); | ^~~~~~ a.cc:4:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>' 3 | #include<queue> +++ |+#include <cstdio> 4 |
s482539800
p00462
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb(a) push_back(a) #define mp(x,y) make_pair(x,y) #define ALL(a) a.begin(),a.end() #define ZERO(a) memset(a,0,sizeof(a)) #define len(a) sizeof(a) #define ll long long #define pii pair<int,int> #define INF 1<<29 #define MAX using namespace std; void solve(){ int D,n,m; for(;;){ cin>>D; if(!D) break; cin>>n; cin>>m; int ans=0; vector<int> d; d.pb(0); d.pb(n); int dd; FOR(i,n-1){ cin>>dd; d.pb(dd); } int k,ind; sort(ALL(d)); FOR(i,m){ cin>>k; int ind=upper_bound(ALL(d),k)-d.begin(); int mi=1000000001; if(ind<d.size()) mi=min(mi,v[ind]-k); ind--; if(ind>=0) mi=min(mi,k-v[ind]); ans+=mi; } cout<<ans<<endl; } } int main(){ solve(); return 0; }
a.cc: In function 'void solve()': a.cc:36:31: error: 'v' was not declared in this scope 36 | if(ind<d.size()) mi=min(mi,v[ind]-k); | ^ a.cc:38:27: error: 'v' was not declared in this scope 38 | if(ind>=0) mi=min(mi,k-v[ind]); | ^
s275993283
p00462
C++
#include <cstdio> #include <vector> #include <algorithm> using namespace std; typedef vector<int> vi; #define PB push_back #define rep(i,x) for(int i=0;i<(x);++i) #define all(a) a.begin(),a.end() template<typename T>T get(){T a;cin>>a;return a;} int main() { int D, N, M; vi d; while (scanf("%d", &D), D) { scanf("%d%d", &N, &M); d.resize(N + 1); d[N - 1] = 0; d[N] = D; rep(i, N - 1) scanf("%d", &d[i]); sort(all(d)); int sum = 0; rep(i, M) { int k; scanf("%d", &k); int pos1 = lower_bound(all(d), k) - d.begin() - 1; int pos2 = lower_bound(all(d), k) - d.begin(); if (pos1 == -1) pos1 = 0; sum += min(abs(k - d[pos1]), abs(k - d[pos2])); } printf("%d\n", sum); } }
a.cc: In function 'T get()': a.cc:13:33: error: 'cin' was not declared in this scope 13 | template<typename T>T get(){T a;cin>>a;return a;} | ^~~ a.cc:4:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 3 | #include <algorithm> +++ |+#include <iostream> 4 |
s554073575
p00462
C++
#include <fstream> #include <algorithm> #include <cmath> #include <cstdint> using namespace std; #define MAX_N 100002 #define MAX_M 10001 uint64_t D,N,M,d[MAX_N],k[MAX_M]; uint64_t gd(uint64_t a,uint64_t b) { return min(abs(a - b),abs(abs(a - b) - 8)); } int main(void) { cin >> D >> N >> M; for(int i = 2;i <= N;i++) { cin >> d[i]; } for(int i = 1;i <= M;i++) { cin >> k[i]; } uint64_t res = 0; for(int i = 1;i <= M;i++) { uint64_t sts = D; for(int ii = 2;ii <= N;ii++) { sts = min(sts,gd(k[i],d[ii])); } res += sts; } cout << res << endl; return 0; }
a.cc: In function 'uint64_t gd(uint64_t, uint64_t)': a.cc:15:23: error: call of overloaded 'abs(uint64_t)' is ambiguous 15 | return min(abs(a - b),abs(abs(a - b) - 8)); | ~~~^~~~~~~ In file included from /usr/include/c++/14/cstdlib:79, from /usr/include/c++/14/ext/string_conversions.h:43, from /usr/include/c++/14/bits/basic_string.h:4154, from /usr/include/c++/14/string:54, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/istream:40, from /usr/include/c++/14/fstream:40, from a.cc:1: /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ In file included from /usr/include/c++/14/cstdlib:81: /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ a.cc:15:38: error: call of overloaded 'abs(uint64_t)' is ambiguous 15 | return min(abs(a - b),abs(abs(a - b) - 8)); | ~~~^~~~~~~ /usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)' 980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur; | ^~~ /usr/include/c++/14/bits/std_abs.h:137:3: note: candidate: 'constexpr __float128 std::abs(__float128)' 137 | abs(__float128 __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:85:3: note: candidate: 'constexpr __int128 std::abs(__int128)' 85 | abs(__GLIBCXX_TYPE_INT_N_0 __x) { return __x >= 0 ? __x : -__x; } | ^~~ /usr/include/c++/14/bits/std_abs.h:79:3: note: candidate: 'constexpr long double std::abs(long double)' 79 | abs(long double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:75:3: note: candidate: 'constexpr float std::abs(float)' 75 | abs(float __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:71:3: note: candidate: 'constexpr double std::abs(double)' 71 | abs(double __x) | ^~~ /usr/include/c++/14/bits/std_abs.h:61:3: note: candidate: 'long long int std::abs(long long int)' 61 | abs(long long __x) { return __builtin_llabs (__x); } | ^~~ /usr/include/c++/14/bits/std_abs.h:56:3: note: candidate: 'long int std::abs(long int)' 56 | abs(long __i) { return __builtin_labs(__i); } | ^~~ a.cc: In function 'int main()': a.cc:20:9: error: 'cin' was not declared in this scope 20 | cin >> D >> N >> M; | ^~~ a.cc:5:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 4 | #include <cstdint> +++ |+#include <iostream> 5 | a.cc:39:9: error: 'cout' was not declared in this scope 39 | cout << res << endl; | ^~~~ a.cc:39:9: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
s507235495
p00462
C++
#include <iostream> #include <vector> using namespace std; int main(int argc, char const *argv[]){ int d, n, m; vector<int> store; store.push_back(0); while (cin>>d, d){ int ans = 0; cin>>n; cin>>m; for (int i = 0; i < m-1; i++){ int s; cin>>s; store.push_back(s); } store.push_back(d); sort(begin(store), end(store)); for (int i = 0; i < n; i++){ int d; cin>>d; auto itl = lower_bound(begin(store), end(store), d); auto itu = itl - 1; ans += min(*itl - d, d - *itu); } cout<<ans<<endl; } return 0; }
a.cc: In function 'int main(int, const char**)': a.cc:22:9: error: 'sort' was not declared in this scope; did you mean 'short'? 22 | sort(begin(store), end(store)); | ^~~~ | short
s347495535
p00462
C++
#include<map> using namespace std; #define SIZE 100002 #define QUERY 10001 int shop[SIZE]; int Bsearch(int n,int target){ int l=0,r=n-1; int mid; while(l < r){ mid = (r+l)/2; if ( shop[mid]> target){ r=mid; }else if ( shop[mid]<target){ l=mid; }else return 0; if ( l+1== r )break; } int ret1 = max(shop[mid],target)-min(shop[mid],target); int ret2 = max(shop[(mid+1)%n],target)-min(shop[(mid+1)%n],target); int ret3 = max(shop[(mid+n-1)%n],target)-min(shop[(mid+n-1)%n],target); //cout << shop[mid] << " " << target << endl; return min(ret1,min(ret2,ret3)); } int solve(int n,map<int,int> &M){ map<int,int>::iterator itr = M.begin(); int ret =0; while(itr != M.end()){ ret+= Bsearch(n,(*itr).first) * (*itr).second; itr++; } return ret; } main(){ int d,n,m; while(cin>>d>>n>>m && d){ shop[0]=0; for(int i=1;i<n;i++){ int tmp; cin>>tmp; shop[i]=tmp; } shop[n++]=d; sort(shop,shop+n); map<int,int> M; for(int i=0;i<m;i++){ int tmp; cin>>tmp; M[tmp]++; } cout <<solve(n,M)<<endl; } return false; }
a.cc:36:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 36 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:38:9: error: 'cin' was not declared in this scope 38 | while(cin>>d>>n>>m && d){ | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include<map> +++ |+#include <iostream> 2 | using namespace std; a.cc:46:5: error: 'sort' was not declared in this scope; did you mean 'short'? 46 | sort(shop,shop+n); | ^~~~ | short a.cc:53:5: error: 'cout' was not declared in this scope 53 | cout <<solve(n,M)<<endl; | ^~~~ a.cc:53:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:53:24: error: 'endl' was not declared in this scope 53 | cout <<solve(n,M)<<endl; | ^~~~ a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 1 | #include<map> +++ |+#include <ostream> 2 | using namespace std;
s669404889
p00462
C++
#include<algorithm> using namespace std; #define SIZE 100002 #define QUERY 10001 int shop[SIZE]; int Bsearch(int n,int target){ int l=0,r=n-1; int mid; while(l < r){ mid = (r+l)/2; if ( shop[mid]> target){ r=mid; }else if ( shop[mid]<target){ l=mid; }else return 0; if ( l+1== r )break; } int ret1 = max(shop[mid],target)-min(shop[mid],target); int ret2 = max(shop[(mid+1)%n],target)-min(shop[(mid+1)%n],target); int ret3 = max(shop[(mid+n-1)%n],target)-min(shop[(mid+n-1)%n],target); return min(ret1,ret2); //cout << shop[mid] << " " << target << endl; return min(ret1,min(ret2,ret3)); } int solve(int n,map<int,int> &M){ map<int,int>::iterator itr = M.begin(); int ret =0; while(itr != M.end()){ ret+= Bsearch(n,(*itr).first) * (*itr).second; itr++; } return ret; } main(){ int d,n,m; while(cin>>d>>n>>m && d){ shop[0]=0; for(int i=1;i<n;i++){ int tmp; cin>>tmp; shop[i]=tmp; } shop[n++]=d; sort(shop,shop+n); map<int,int> M; for(int i=0;i<m;i++){ int tmp; cin>>tmp; M[tmp]++; } cout <<solve(n,M)<<endl; } return false; }
a.cc:27:17: error: 'map' has not been declared 27 | int solve(int n,map<int,int> &M){ | ^~~ a.cc:27:20: error: expected ',' or '...' before '<' token 27 | int solve(int n,map<int,int> &M){ | ^ a.cc: In function 'int solve(int, int)': a.cc:28:3: error: 'map' was not declared in this scope 28 | map<int,int>::iterator itr = M.begin(); | ^~~ a.cc:2:1: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>' 1 | #include<algorithm> +++ |+#include <map> 2 | using namespace std; a.cc:28:7: error: expected primary-expression before 'int' 28 | map<int,int>::iterator itr = M.begin(); | ^~~ a.cc:30:9: error: 'itr' was not declared in this scope 30 | while(itr != M.end()){ | ^~~ a.cc:30:16: error: 'M' was not declared in this scope 30 | while(itr != M.end()){ | ^ a.cc: At global scope: a.cc:37:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 37 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:39:9: error: 'cin' was not declared in this scope 39 | while(cin>>d>>n>>m && d){ | ^~~ a.cc:2:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 1 | #include<algorithm> +++ |+#include <iostream> 2 | using namespace std; a.cc:48:5: error: 'map' was not declared in this scope 48 | map<int,int> M; | ^~~ a.cc:48:5: note: 'std::map' is defined in header '<map>'; this is probably fixable by adding '#include <map>' a.cc:48:9: error: expected primary-expression before 'int' 48 | map<int,int> M; | ^~~ a.cc:52:7: error: 'M' was not declared in this scope 52 | M[tmp]++; | ^ a.cc:54:5: error: 'cout' was not declared in this scope 54 | cout <<solve(n,M)<<endl; | ^~~~ a.cc:54:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:54:20: error: 'M' was not declared in this scope 54 | cout <<solve(n,M)<<endl; | ^ a.cc:54:24: error: 'endl' was not declared in this scope 54 | cout <<solve(n,M)<<endl; | ^~~~ a.cc:2:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 1 | #include<algorithm> +++ |+#include <ostream> 2 | using namespace std;
s846204049
p00462
C++
#include<cstdio> #include<iostream> #include<vector> #define sint(i) scanf("%d",&i); #define sintt(i,j) scanf("%d%d",&i,&j); #define sinttt(i,j,k) scanf("%d%d%d",&i,&j,&k); #define rep(i,n) for(int i=0;i<n;i++) using namespace std; int mise[100002]; int main(){ while(1){ int d,n,m; sint(d); if(d==0)break; sintt(n,m); mise[0]=0; rep(i,n-1){ sint(mise[i+1]); } mise[n]=d; n++; sort(mise,mise+n); int ans=0; rep(i,m){ int aa; sint(aa); int *nn=lower_bound(mise,mise+n,aa); int kekka=min(aa-*(nn-1),*nn-aa); ans+=kekka; } printf("%d\n",ans); } }
a.cc: In function 'int main()': a.cc:29:17: error: 'sort' was not declared in this scope; did you mean 'short'? 29 | sort(mise,mise+n); | ^~~~ | short
s593721944
p00462
C++
#include<cstdio> #include<iostream> #include<vector> #include<string> #include<map> #include<stack> #include<algorithm> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) #define reps(i,n) for(int i=1;i<=n;i++) vector<int> mise; int main(){ while(1){ int d,m,n; scanf("%d",&d); if(d==0)break; scanf("%d",&n); scanf("%d",&m); mise.clear(); mise.push_back(0); mise.push_back(d); rep(i,n-1){ int a; scanf("%d",&a); mise.push_back(a); } sort(mise.begin(),mise.end()); int ans=0; rep(j,m){ int a; scanf("%d",&a); int *p=lower_bound(mise.begin(),mise.end(),a); int val1,val2; val1=*p-a; val2=a-*(p-1); if(val1<0)val1*=-1; if(val2<0)val2*=-1; ans+=min(val1,val2); } printf("%d\n",ans); } }
a.cc: In function 'int main()': a.cc:41:43: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int*' in initialization 41 | int *p=lower_bound(mise.begin(),mise.end(),a); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | __gnu_cxx::__normal_iterator<int*, std::vector<int> >
s696766148
p00462
C++
#include<cstdio> #include<iostream> #include<string> #include<map> #include<queue> #include<set> #include<algorithm> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) #define reps(i,n) for(int i=1;i<=n;i++) int main(){ while(1){ int d,n,m; cin>>d; if(d==0)break; cin>>n>>m; vector<int> shop; shop.push_back(0); shop.push_back(d); rep(i,n-1){ int a; cin>>a; shop.push_back(a); } sort(shop.begin(),shop.end()); int ans=0; rep(i,m){ int a; cin>>a; int *b = upper_bound(shop.begin(),shop.end(),a); ans += min(*b-a,a-*(b-1)); } printf("%d\n",ans); } }
a.cc: In function 'int main()': a.cc:38:45: error: cannot convert '__gnu_cxx::__normal_iterator<int*, std::vector<int> >' to 'int*' in initialization 38 | int *b = upper_bound(shop.begin(),shop.end(),a); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | __gnu_cxx::__normal_iterator<int*, std::vector<int> >
s486693925
p00462
C++
#include<cstdio> #include<vector> using namespace std; int main(void){ int d; while(scanf("%d", &d) && d != 0){ int S[100009]; int n,m; int temp; int l,ls,ss; int ans= 0; scanf("%d%d", &n, &m); S[0] = 0; S[n] = d; for(int i = 1; i < n; i++){ scanf("%d", &S[i]); } sort(S,S+n); for(int i = 0; i < m; i++){ scanf("%d", &temp); int *mx = upper_bound(S,S+n+1,temp); ls = mx - S; ss = mx -1 -S; // printf("S[%d] = %d : S[%d] = %d\n", ls, S[ls], ss, S[ss]); l = min( S[ls]-temp, temp-S[ss]); // printf("%d\n",l); ans+=l; } printf("%d\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:24:17: error: 'sort' was not declared in this scope; did you mean 'short'? 24 | sort(S,S+n); | ^~~~ | short a.cc:28:35: error: 'upper_bound' was not declared in this scope 28 | int *mx = upper_bound(S,S+n+1,temp); | ^~~~~~~~~~~
s313266715
p00462
C++
#include<stdio.h> #include<algorithm> int*it,shop[100001],n,m,d,i; int main(){ for(;scanf("%d%d%d",&d,&n,&m),shop[n]=d;i=!printf("%d\n",i)){ for(i=n;i--;) scanf("%d",shop+i) for(std::sort(shop,shop+n);m--;i+=min(*it - d, d - it[-1] )) scanf("%d",&d), it = std::upper_bound( shop, shop+n, d ); } }
a.cc: In function 'int main()': a.cc:7:43: error: expected ';' before 'for' 7 | scanf("%d",shop+i) | ^ | ; 8 | for(std::sort(shop,shop+n);m--;i+=min(*it - d, d - it[-1] )) | ~~~ a.cc:8:51: error: 'min' was not declared in this scope; did you mean 'std::min'? 8 | for(std::sort(shop,shop+n);m--;i+=min(*it - d, d - it[-1] )) | ^~~ | std::min In file included from /usr/include/c++/14/algorithm:61, from a.cc:2: /usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here 5696 | min(initializer_list<_Tp> __l, _Compare __comp) | ^~~
s252381518
p00462
C++
#include<stdio.h> #include<algorithm> *it,shop[100001],n,m,d,i; main(){ for(;scanf("%d%d%d",&d,&n,&m),shop[i=n]=d;i=!printf("%d\n",i)){ for(;--i;) scanf("%d",shop+i); for(std::sort(shop,shop+n);m--;i+=std::min(*it - d, d - it[-1] )) scanf("%d",&d), it = std::upper_bound( shop, shop+n, d ); } }
a.cc:3:4: error: expected constructor, destructor, or type conversion before ',' token 3 | *it,shop[100001],n,m,d,i; | ^ a.cc:3:17: error: expected constructor, destructor, or type conversion before ',' token 3 | *it,shop[100001],n,m,d,i; | ^ a.cc:3:19: error: expected constructor, destructor, or type conversion before ',' token 3 | *it,shop[100001],n,m,d,i; | ^ a.cc:3:21: error: expected constructor, destructor, or type conversion before ',' token 3 | *it,shop[100001],n,m,d,i; | ^ a.cc:3:23: error: expected constructor, destructor, or type conversion before ',' token 3 | *it,shop[100001],n,m,d,i; | ^ a.cc:3:25: error: expected constructor, destructor, or type conversion before ';' token 3 | *it,shop[100001],n,m,d,i; | ^ a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 4 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:5:30: error: 'd' was not declared in this scope 5 | for(;scanf("%d%d%d",&d,&n,&m),shop[i=n]=d;i=!printf("%d\n",i)){ | ^ a.cc:5:33: error: 'n' was not declared in this scope 5 | for(;scanf("%d%d%d",&d,&n,&m),shop[i=n]=d;i=!printf("%d\n",i)){ | ^ a.cc:5:36: error: 'm' was not declared in this scope 5 | for(;scanf("%d%d%d",&d,&n,&m),shop[i=n]=d;i=!printf("%d\n",i)){ | ^ a.cc:5:39: error: 'shop' was not declared in this scope 5 | for(;scanf("%d%d%d",&d,&n,&m),shop[i=n]=d;i=!printf("%d\n",i)){ | ^~~~ a.cc:5:44: error: 'i' was not declared in this scope 5 | for(;scanf("%d%d%d",&d,&n,&m),shop[i=n]=d;i=!printf("%d\n",i)){ | ^ a.cc:8:61: error: 'it' was not declared in this scope; did you mean 'int'? 8 | for(std::sort(shop,shop+n);m--;i+=std::min(*it - d, d - it[-1] )) | ^~ | int
s552088517
p00462
C++
#include<stdio.h> #include<algorithm> int*it,shop[100001],n,m,d; main(i){ for(;scanf("%d%d%d",&d,&n,&m),shop[i=n]=d;i=!printf("%d\n",i)){ for(;--i;) scanf("%d",shop+i); for(std::sort(shop,shop+n);m--;i+=std::min(*it - d, d - it[-1] )) scanf("%d",&d), it = std::upper_bound( shop, shop+n, d ); } }
a.cc:4:5: error: expected constructor, destructor, or type conversion before '(' token 4 | main(i){ | ^
s842296213
p00462
C++
#include<stdio.h> #include<algorthm> int*t,s[99999],n,m,d,i; main(){ for(;scanf("%d%d%d",&d,&n,&m),s[i=n]=d;printf("%d\n",i)){ for(;--i;) scanf("%d",s+i); for(std::sort(s,s+n);m--;i+=std::min(*t - d, d - t[-1] )) scanf("%d",&d), t = std::upper_bound( s, s+n, d ); } }
a.cc:2:9: fatal error: algorthm: No such file or directory 2 | #include<algorthm> | ^~~~~~~~~~ compilation terminated.
s175500068
p00462
C++
#include<stdio.h> #include<algorithm> int*t,,n,m,d,i,s[99999]; main(){ for(;scanf("%d%d%d",&d,&n,&m),s[i=n]=d;printf("%d\n",i)){ for(;--i;) scanf("%d",s+i); for(std::sort(s,s+n);m--;i+=std::min(*t - d, d - t[-1] )) scanf("%d",&d), t = std::upper_bound( s, s+n, d ); } }
a.cc:3:7: error: expected unqualified-id before ',' token 3 | int*t,,n,m,d,i,s[99999]; | ^ a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 4 | main(){ | ^~~~
s328884230
p00462
C++
#include<stdio.h> #include<algorithm> int*t,p="%d\n",n,m,d,i,s[99999];main(){for(;scanf("%d%d%d",&d,&n,&m),s[i=n]=d;printf(p,i)){for(;--i;)scanf(p,s+i);for(std::sort(s,s+n);m--;i+=std::min(*t-d,d-t[-1]))scanf(p,&d),t=std::upper_bound(s,s+n,d);}}
a.cc:3:9: error: invalid conversion from 'const char*' to 'int' [-fpermissive] 3 | int*t,p="%d\n",n,m,d,i,s[99999];main(){for(;scanf("%d%d%d",&d,&n,&m),s[i=n]=d;printf(p,i)){for(;--i;)scanf(p,s+i);for(std::sort(s,s+n);m--;i+=std::min(*t-d,d-t[-1]))scanf(p,&d),t=std::upper_bound(s,s+n,d);}} | ^~~~~~ | | | const char* a.cc:3:33: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 3 | int*t,p="%d\n",n,m,d,i,s[99999];main(){for(;scanf("%d%d%d",&d,&n,&m),s[i=n]=d;printf(p,i)){for(;--i;)scanf(p,s+i);for(std::sort(s,s+n);m--;i+=std::min(*t-d,d-t[-1]))scanf(p,&d),t=std::upper_bound(s,s+n,d);}} | ^~~~ a.cc: In function 'int main()': a.cc:3:86: error: invalid conversion from 'int' to 'const char*' [-fpermissive] 3 | int*t,p="%d\n",n,m,d,i,s[99999];main(){for(;scanf("%d%d%d",&d,&n,&m),s[i=n]=d;printf(p,i)){for(;--i;)scanf(p,s+i);for(std::sort(s,s+n);m--;i+=std::min(*t-d,d-t[-1]))scanf(p,&d),t=std::upper_bound(s,s+n,d);}} | ^ | | | int In file included from a.cc:1: /usr/include/stdio.h:363:43: note: initializing argument 1 of 'int printf(const char*, ...)' 363 | extern int printf (const char *__restrict __format, ...); | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~ a.cc:3:108: error: invalid conversion from 'int' to 'const char*' [-fpermissive] 3 | int*t,p="%d\n",n,m,d,i,s[99999];main(){for(;scanf("%d%d%d",&d,&n,&m),s[i=n]=d;printf(p,i)){for(;--i;)scanf(p,s+i);for(std::sort(s,s+n);m--;i+=std::min(*t-d,d-t[-1]))scanf(p,&d),t=std::upper_bound(s,s+n,d);}} | ^ | | | int /usr/include/stdio.h:428:42: note: initializing argument 1 of 'int scanf(const char*, ...)' 428 | extern int scanf (const char *__restrict __format, ...) __wur; | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~ a.cc:3:172: error: invalid conversion from 'int' to 'const char*' [-fpermissive] 3 | int*t,p="%d\n",n,m,d,i,s[99999];main(){for(;scanf("%d%d%d",&d,&n,&m),s[i=n]=d;printf(p,i)){for(;--i;)scanf(p,s+i);for(std::sort(s,s+n);m--;i+=std::min(*t-d,d-t[-1]))scanf(p,&d),t=std::upper_bound(s,s+n,d);}} | ^ | | | int /usr/include/stdio.h:428:42: note: initializing argument 1 of 'int scanf(const char*, ...)' 428 | extern int scanf (const char *__restrict __format, ...) __wur; | ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
s515394909
p00462
C++
#include<stdio.h> #include<algorithm> int*t,n,m,d,i,s[99999]; main(){ for(;scanf("%d%d%d",&d,&n,&m),s[i=n]=d;printf("%d\n",i)){ for(;--i;) scanf("%d",s+i); for(std::sort(s,s+n);m--;i+=fmin(*t-d,d-t[-1])) scanf("%d",&d), t=std::upper_bound(s,s+n,d); } }
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 4 | main(){ | ^~~~ a.cc: In function 'int main()': a.cc:8:45: error: 'fmin' was not declared in this scope 8 | for(std::sort(s,s+n);m--;i+=fmin(*t-d,d-t[-1])) | ^~~~
s554849087
p00462
C++
#include<iostream> #include<algo.h> using namespace std;int*t,n,m,d,i,s[99999];main(){for(;cin>>d>>n>>m,s[i=n]=d;cout<<i<<'\n'){for(;--i;)cin>>s[i];for(sort(s,s+n);m--;t=upper_bound(s,s+n,d),i+=min(*t-d,d-t[-1]))cin>>d;}}
a.cc:2:9: fatal error: algo.h: No such file or directory 2 | #include<algo.h> | ^~~~~~~~ compilation terminated.
s431830390
p00462
C++
#include<iostream.h> #include<algorithm.h> using namespace std; int*t,n,m,d,i,s[99999]; main(){ for(;cin>>d>>n>>m,s[i=n]=d;cout<<i<<endl){ for(;--i;) cin>>s[i]; for(sort(s,s+n);m--;t=upper_bound(s,s+n,d),i+=min(*t-d,d-t[-1])) cin>>d; } }
a.cc:1:9: fatal error: iostream.h: No such file or directory 1 | #include<iostream.h> | ^~~~~~~~~~~~ compilation terminated.
s926448234
p00462
C++
#include <cstdio> #include <vector> #include <algorithm> using namespace std; int main() { while(true) { int d, n, m; vector<int> s; scanf("%d", &d); if(d == 0) break; s.resize(n); for(int i = 0; i < n; ++i) scanf("%d", &s[i]); sort(s.begin(), s.end()); s.push_back(s[0] + d); s.push_back(s[n - 1] - d); sort(s.begin(), s.end()); int sum = 0; for(int i = 0; i < m; ++i) { int t; scanf("%d", &t); int r = lower_bound(s.begin(), s.end()) - s.begin(); l = r - 1; sum += min(abs(s[l] - t), abs(s[r] - t)); } printf("%d\n", sum); } return 0; }
a.cc: In function 'int main()': a.cc:25:20: error: no matching function for call to 'lower_bound(std::vector<int>::iterator, std::vector<int>::iterator)' 25 | int r = lower_bound(s.begin(), s.end()) - s.begin(); | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/vector:62, from a.cc:2: /usr/include/c++/14/bits/stl_algobase.h:1530:5: note: candidate: 'template<class _ForwardIterator, class _Tp> _ForwardIterator std::lower_bound(_ForwardIterator, _ForwardIterator, const _Tp&)' 1530 | lower_bound(_ForwardIterator __first, _ForwardIterator __last, | ^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algobase.h:1530:5: note: candidate expects 3 arguments, 2 provided In file included from /usr/include/c++/14/algorithm:61, from a.cc:3: /usr/include/c++/14/bits/stl_algo.h:1963:5: note: candidate: 'template<class _FIter, class _Tp, class _Compare> _FIter std::lower_bound(_FIter, _FIter, const _Tp&, _Compare)' 1963 | lower_bound(_ForwardIterator __first, _ForwardIterator __last, | ^~~~~~~~~~~ /usr/include/c++/14/bits/stl_algo.h:1963:5: note: candidate expects 4 arguments, 2 provided a.cc:26:1: error: 'l' was not declared in this scope 26 | l = r - 1; | ^
s605308470
p00462
C++
#include <cstdio> #include <vector> #include <algorithm> using namespace std; int main() { while(true) { int d, n, m; vector<int> s; scanf("%d", &d); if(d == 0) break; s.resize(n); for(int i = 0; i < n; ++i) scanf("%d", &s[i]); sort(s.begin(), s.end()); s.push_back(s[0] + d); s.push_back(s[n - 1] - d); sort(s.begin(), s.end()); int sum = 0; for(int i = 0; i < m; ++i) { int t; scanf("%d", &t); int r = lower_bound(s.begin(), s.end(), t) - s.begin(); l = r - 1; sum += min(abs(s[l] - t), abs(s[r] - t)); } printf("%d\n", sum); } return 0; }
a.cc: In function 'int main()': a.cc:26:1: error: 'l' was not declared in this scope 26 | l = r - 1; | ^
s851815878
p00462
C++
#include <iostream> using namespace std; int main() { int dp[10000],to,store[100000]; int d,n,m,minsum,prmin,x; cin >> d; while(d != 0){ cin >> n >> m; store[0] = 0; for(int i = 1; i < n; i++){ cin >> store[i]; } minsum = 0; for(int i = 0; i < m; i++){ cin >> to; prmin = INT_MAX; for(int j = 0; j < n; j++){ x = to - store[j]; if(x < 0){ x *= -1; } x = min(x,d-x); prmin = min(prmin,x); } minsum += prmin; } cout << minsum << endl; cin >> d; } return 0; }
a.cc: In function 'int main()': a.cc:21:33: error: 'INT_MAX' was not declared in this scope 21 | prmin = INT_MAX; | ^~~~~~~ a.cc:2:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 1 | #include <iostream> +++ |+#include <climits> 2 |
s990485588
p00462
C++
#include <algorithm> #include <iostream> #include <functional> #include <vector> #include <cstdlib> using namespace std; int D,N,M,K; int in; int main(void) { while(cin >> D, D){ static vector<long> d,k; static vector<long> pos; cin >> N >> M; d.push_back(0); d.push_back(0); for(int i = 0; i < N-1; i++){ cin >> in; d.push_back(in); } d.push_back(D); d.push_back(D); sort(d.begin(), d.end() ); for(int i = 0; i < M; i++){ cin >> in; k.push_back(in); } long sum = 0; for(int i = 0; i < M; i++){ long pos = (long)(lower_bound(d.begin(), d.end(), k[i] ) - d.begin()); long ans = miin( min( abs(d[pos]-k[i]), abs(d[pos-1]-k[i]) ), abs(d[pos+1]-k[i]) ); sum += ans;; } cout << sum << endl; } return 0; }
a.cc: In function 'int main()': a.cc:39:36: error: 'miin' was not declared in this scope; did you mean 'main'? 39 | long ans = miin( min( abs(d[pos]-k[i]), abs(d[pos-1]-k[i]) ), abs(d[pos+1]-k[i]) ); | ^~~~ | main
s601807289
p00462
C++
#include<vector> #include<algorithm> using namespace std; int froms[100002]; int D, N, M; int main() { loop: cin >> D; if(!D) return 0; cin >> N >> M; froms[0] = 0; for(int i = 1; i < N; i++) { int d; cin >> d; froms[i] = d; } froms[N] = D; sort(froms, froms + N + 1); int ans = 0; for(int i = 0; i < M; i++) { int k; cin >> k; int *p = lower_bound(froms, froms + N + 1, k); int *p2 = p - 1; ans += min(*p - k, k - *p2); } cout << ans << endl; goto loop; }
a.cc: In function 'int main()': a.cc:11:3: error: 'cin' was not declared in this scope 11 | cin >> D; | ^~~ a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' 2 | #include<algorithm> +++ |+#include <iostream> 3 | using namespace std; a.cc:34:3: error: 'cout' was not declared in this scope 34 | cout << ans << endl; | ^~~~ a.cc:34:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>' a.cc:34:18: error: 'endl' was not declared in this scope 34 | cout << ans << endl; | ^~~~ a.cc:3:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>' 2 | #include<algorithm> +++ |+#include <ostream> 3 | using namespace std;
s956494145
p00463
Java
import java.io.InputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.math.BigInteger; public class Main{ static PrintWriter out; static InputReader ir; static void solve(){ int n,m,h,k; while(true){ n=ir.nextInt(); m=ir.nextInt(); h=ir.nextInt(); k=ir.nextInt(); if(n==0&&m==0&&h==0&&k==0) break; int[] s=ir.nextIntArray(n); int[][] l=new int[m][]; for(int i=0;i<m;i++){ l[i]=ir.nextIntArray(2); l[i][0]--; } Arrays.sort(l,new Comparator<int[]>(){ public int compare(int[] a,int[] b){ return Integer.compare(a[1],b[1]); } }); int p=0; int[] pos=new int[n]; int[][] swp=new int[m][]; for(int i=0;i<n;i++) pos[i]=i; for(int i=0;i<m;i++){ swp[p++]=new int[]{pos[l[i][0]],pos[l[i][0]+1]}; int temp=pos[l[i][0]]; pos[l[i][0]]=pos[l[i][0]+1]; pos[l[i][0]+1]=temp; } int[] scr=new int[n]; for(int i=0;i<n;i++) scr[pos[i]]=s[i]; int tot=0; for(int i=0;i<k;i++) tot+=scr[i]; for(int i=0;i<m;i++){ if(swp[i][0]<k&&swp[i][1]<k) continue; else if(swp[i][0]<k) tot=Math.min(tot,tot-scr[pos[i][0]]+scr[pos[i][1]]); else if(swp[i][1]<k) tot=Math.min(tot,tot+scr[pos[i][0]]-scr[pos[i][1]]); } out.println(tot); } } public static void main(String[] args) throws Exception{ ir=new InputReader(System.in); out=new PrintWriter(System.out); solve(); out.flush(); } static class InputReader { private InputStream in; private byte[] buffer=new byte[1024]; private int curbuf; private int lenbuf; public InputReader(InputStream in) {this.in=in; this.curbuf=this.lenbuf=0;} public boolean hasNextByte() { if(curbuf>=lenbuf){ curbuf= 0; try{ lenbuf=in.read(buffer); }catch(IOException e) { throw new InputMismatchException(); } if(lenbuf<=0) return false; } return true; } private int readByte(){if(hasNextByte()) return buffer[curbuf++]; else return -1;} private boolean isSpaceChar(int c){return !(c>=33&&c<=126);} private void skip(){while(hasNextByte()&&isSpaceChar(buffer[curbuf])) curbuf++;} public boolean hasNext(){skip(); return hasNextByte();} public String next(){ if(!hasNext()) throw new NoSuchElementException(); StringBuilder sb=new StringBuilder(); int b=readByte(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString(); } public int nextInt() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } int res=0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public long nextLong() { if(!hasNext()) throw new NoSuchElementException(); int c=readByte(); while (isSpaceChar(c)) c=readByte(); boolean minus=false; if (c=='-') { minus=true; c=readByte(); } long res = 0; do{ if(c<'0'||c>'9') throw new InputMismatchException(); res=res*10+c-'0'; c=readByte(); }while(!isSpaceChar(c)); return (minus)?-res:res; } public double nextDouble(){return Double.parseDouble(next());} public int[] nextIntArray(int n){ int[] a=new int[n]; for(int i=0;i<n;i++) a[i]=nextInt(); return a; } public long[] nextLongArray(int n){ long[] a=new long[n]; for(int i=0;i<n;i++) a[i]=nextLong(); return a; } public char[][] nextCharMap(int n,int m){ char[][] map=new char[n][m]; for(int i=0;i<n;i++) map[i]=next().toCharArray(); return map; } } }
Main.java:51: error: array required, but int found else if(swp[i][0]<k) tot=Math.min(tot,tot-scr[pos[i][0]]+scr[pos[i][1]]); ^ Main.java:51: error: array required, but int found else if(swp[i][0]<k) tot=Math.min(tot,tot-scr[pos[i][0]]+scr[pos[i][1]]); ^ Main.java:52: error: array required, but int found else if(swp[i][1]<k) tot=Math.min(tot,tot+scr[pos[i][0]]-scr[pos[i][1]]); ^ Main.java:52: error: array required, but int found else if(swp[i][1]<k) tot=Math.min(tot,tot+scr[pos[i][0]]-scr[pos[i][1]]); ^ 4 errors
s008150344
p00463
C++
#include<bits\stdc++.h> using namespace std; typedef pair<int ,int > pii; typedef pair<int ,pii > pipii; void solve(); int N,M,H,K; int S[1010]; int now[1010]; int main() { while(scanf("%d%d%d%d",&N,&M,&H,&K),N + M + H + K) { for(int i = 1; i < N + 1; i++) { scanf("%d",&S[i]); } solve(); } return 0; } void solve() { int ans = 0,mem = 0; vector<pii> l; for(int i = 0; i < M; i++) { int a,b; scanf("%d%d",&a,&b); l.push_back(make_pair(b,a)); } sort(l.begin(),l.end()); for(int i = 1; i < N + 1; i++) { now[i] = i; } for(int i = M - 1; i >= 0; i--) { int memo = S[l[i].second]; S[l[i].second] = S[l[i].second + 1]; S[l[i].second + 1] = memo; } for(int i = 1; i < K + 1; i++) { ans += S[i]; } for(int i = 0; i < M; i++) { int Ma = max(now[l[i].second],now[l[i].second + 1]), Mi = min(now[l[i].second],now[l[i].second + 1]); if(Mi <= K && K < Ma) { mem = max(mem,S[Mi] - S[Ma]); } int memo = now[l[i].second]; now[l[i].second] = now[l[i].second + 1]; now[l[i].second + 1] = memo; } printf("%d\n",ans - mem); return; }
a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory 1 | #include<bits\stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s470000461
p00463
C++
#include<bits\stdc++.h> using namespace std; typedef pair<int ,int > pii; typedef pair<int ,pii > pipii; void solve(); int N,M,H,K; int S[1010]; int now[1010]; int main() { while(scanf("%d%d%d%d",&N,&M,&H,&K),N + M + H + K) { for(int i = 1; i < N + 1; i++) { scanf("%d",&S[i]); } solve(); } return 0; } void solve() { int ans = 0,mem = 0; vector<pii> l; for(int i = 0; i < M; i++) { int a,b; scanf("%d%d",&a,&b); l.push_back(make_pair(b,a)); } sort(l.begin(),l.end()); for(int i = 1; i < N + 1; i++) { now[i] = i; } for(int i = M - 1; i >= 0; i--) { int memo = S[l[i].second]; S[l[i].second] = S[l[i].second + 1]; S[l[i].second + 1] = memo; } for(int i = 1; i < K + 1; i++) { ans += S[i]; } for(int i = 0; i < M; i++) { int Ma = max(now[l[i].second],now[l[i].second + 1]), Mi = min(now[l[i].second],now[l[i].second + 1]); if(Mi <= K && K < Ma) { mem = max(mem,S[Mi] - S[Ma]); } int memo = now[l[i].second]; now[l[i].second] = now[l[i].second + 1]; now[l[i].second + 1] = memo; } printf("%d\n",ans - mem); return; }
a.cc:1:9: fatal error: bits\stdc++.h: No such file or directory 1 | #include<bits\stdc++.h> | ^~~~~~~~~~~~~~~ compilation terminated.
s717701975
p00463
C++
#include<iostream> #include<string> #include<cmath> #include<queue> #include<map> #include<set> #include<list> #include<iomanip> #include<vector> #include<functional> #include<algorithm> #include<cstdio> #include<unordered_map> #include<chrono> using namespace std; typedef long long ll; ll a[1001]; struct A{ ll h;//high ll a;//left ll lb,rb;//up from left,up from,right ll lc,rc;//down from left,down from right ll lv,rv;//number on vctor }; A b[100001]; struct C{ ll h;//high ll b;//number bool c;//left=true,right=false }; vector<C>c[1001]; ll n,m,h,k; struct J{ ll u1,u2; }; J u[100001]; bool operator<(J a,J b){return a.} int main(){ cin>>n>>m>>h>>k; for(ll i=1;i<=n;i++) cin>>a[i]; for(ll i=1;i<=m;i++) cin>>u[i].u1>>u[i].u2; sort(u+1,u+1+m); for(ll i=1;i<=m;i++){ ll ai=u[i].u1,bi=u[i].u2; ll oi=(ll)c[ai].size(),io=(ll)c[ai+1].size(); b[i]=A{bi,ai,-1,-1,-1,-1,oi,io}; c[ai].push_back(C{bi,i,true}); c[ai+1].push_back(C{bi,i,false}); } for(ll i=1;i<=n;i++){ ll d=i; ll e=-1; while(e + 1 != c[d].size()) { } } }
a.cc: In function 'bool operator<(J, J)': a.cc:37:34: error: expected unqualified-id before '}' token 37 | bool operator<(J a,J b){return a.} | ^ a.cc:37:34: error: expected ';' before '}' token 37 | bool operator<(J a,J b){return a.} | ^ | ;
s464339310
p00463
C++
#include<iostream> #include<string> #include<cmath> #include<queue> #include<map> #include<set> #include<list> #include<iomanip> #include<vector> #include<functional> #include<algorithm> #include<cstdio> #include<unordered_map> #include<chrono> using namespace std; typedef long long ll; ll a[1001]; struct A{ ll h;//high ll a;//left ll lb,rb;//up from left,up from,right ll lc,rc;//down from left,down from right ll lv,rv;//number on vctor }; A b[100001]; struct C{ ll h;//high ll b;//number bool c;//left=true,right=false }; vector<C>c[1001]; ll n,m,h,k; struct J{ ll u1,u2; }; J u[100001]; bool operator<(J a,J b){return a.} int main(){ cin>>n>>m>>h>>k; for(ll i=1;i<=n;i++) cin>>a[i]; for(ll i=1;i<=m;i++) cin>>u[i].u1>>u[i].u2; sort(u+1,u+1+m); for(ll i=1;i<=m;i++){ ll ai=u[i].u1,bi=u[i].u2; ll oi=(ll)c[ai].size(),io=(ll)c[ai+1].size(); b[i]=A{bi,ai,-1,-1,-1,-1,oi,io}; c[ai].push_back(C{bi,i,true}); c[ai+1].push_back(C{bi,i,false}); } for(ll i=1;i<=n;i++){ ll d=i; ll e=-1; while(e + 1 != c[d].size()) { } } }
a.cc: In function 'bool operator<(J, J)': a.cc:37:34: error: expected unqualified-id before '}' token 37 | bool operator<(J a,J b){return a.} | ^ a.cc:37:34: error: expected ';' before '}' token 37 | bool operator<(J a,J b){return a.} | ^ | ;
s467355627
p00463
C++
#include<cstdio> #include<iostream> #include<vector> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) #define reps(i,n) for(int i=1;i<=n;i++) #define sint(i) scanf("%d",&i); #define sintt(i,j) scanf("%d%d",&i,&j); #define sinttt(i,j,k) scanf("%d%d%d",&i,&j,&k); #define INF 1010000000 int hav[1001]; int get[1001]; int point[1001]; pair<int,int> bou[100001]; int main(){ while(1){ int n,m,h,k; scanf("%d%d%d%d",&n,&m,&h,&k); if(n==0)break; reps(i,n){ sint(point[i]); } rep(i,m){ int a,b; sintt(a,b); bou[i]=make_pair(b,a); } sort(bou,bou+m); rep(i,n+1)hav[i]=i; rep(i,m){ int a=bou[i].second; swap(hav[a],hav[a+1]); } reps(i,n){ get[hav[i]]=point[i]; } rep(i,n+1)hav[i]=i; int mini[1001]; rep(i,n+1)mini[i]=get[i]; rep(i,m){ int a=bou[i].second; mini[hav[a]]=min(mini[hav[a]],min(get[hav[a]],get[hav[a+1]])); swap(hav[a],hav[a+1]); mini[hav[a]]=min(mini[hav[a]],min(get[hav[a]],get[hav[a+1]])); } int ans=0; int maxs=0; int maxp=0; reps(i,k){ ans+=get[i]; if(maxs<get[i]-mini[i]){ maxs=get[i]-mini[i]; maxp=i; } } //printf("%d %d %d\n",ans,maxs,maxp); ans-=maxs; /* reps(i,n){ printf("%d ",mini[i]); }puts(""); */ printf("%d\n",ans); } }
a.cc: In function 'int main()': a.cc:37:17: error: 'sort' was not declared in this scope; did you mean 'short'? 37 | sort(bou,bou+m); | ^~~~ | short a.cc:47:25: error: reference to 'get' is ambiguous 47 | get[hav[i]]=point[i]; | ^~~ In file included from /usr/include/c++/14/bits/memory_resource.h:47, from /usr/include/c++/14/string:68, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/tuple:2517:5: note: candidates are: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const tuple<_Elements ...>&&)' 2517 | get(const tuple<_Types...>&& __t) noexcept | ^~~ /usr/include/c++/14/tuple:2505:5: note: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const tuple<_Elements ...>&)' 2505 | get(const tuple<_Types...>& __t) noexcept | ^~~ /usr/include/c++/14/tuple:2494:5: note: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(tuple<_Elements ...>&&)' 2494 | get(tuple<_Types...>&& __t) noexcept | ^~~ /usr/include/c++/14/tuple:2483:5: note: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(tuple<_Elements ...>&)' 2483 | get(tuple<_Types...>& __t) noexcept | ^~~ /usr/include/c++/14/tuple:2476:5: note: 'template<long unsigned int __i, class ... _Elements> constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&)' 2476 | get(const tuple<_Elements...>&) = delete; | ^~~ In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51: /usr/include/c++/14/bits/stl_pair.h:1307:5: note: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const pair<_Up, _Tp>&&)' 1307 | get(const pair<_Up, _Tp>&& __p) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:1302:5: note: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(pair<_Up, _Tp>&&)' 1302 | get(pair<_Up, _Tp>&& __p) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:1297:5: note: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_Up, _Tp>&)' 1297 | get(const pair<_Up, _Tp>& __p) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:1292:5: note: 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_Up, _Tp>&)' 1292 | get(pair<_Up, _Tp>& __p) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:1287:5: note: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const pair<_T1, _T2>&&)' 1287 | get(const pair<_Tp, _Up>&& __p) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:1282:5: note: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(pair<_T1, _T2>&&)' 1282 | get(pair<_Tp, _Up>&& __p) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:1277:5: note: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_T1, _T2>&)' 1277 | get(const pair<_Tp, _Up>& __p) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:1272:5: note: 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_T1, _T2>&)' 1272 | get(pair<_Tp, _Up>& __p) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:150:5: note: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp&& std::get(const array<_Tp, _Nm>&&)' 150 | get(const array<_Tp, _Nm>&&) noexcept; | ^~~ /usr/include/c++/14/bits/stl_pair.h:146:5: note: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr const _Tp& std::get(const array<_Tp, _Nm>&)' 146 | get(const array<_Tp, _Nm>&) noexcept; | ^~~ /usr/include/c++/14/bits/stl_pair.h:142:5: note: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp&& std::get(array<_Tp, _Nm>&&)' 142 | get(array<_Tp, _Nm>&&) noexcept; | ^~~ /usr/include/c++/14/bits/stl_pair.h:138:5: note: 'template<long unsigned int _Int, class _Tp, long unsigned int _Nm> constexpr _Tp& std::get(array<_Tp, _Nm>&)' 138 | get(array<_Tp, _Nm>&) noexcept; | ^~~ /usr/include/c++/14/tuple:2466:5: note: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(const tuple<_Elements ...>&&)' 2466 | get(const tuple<_Elements...>&& __t) noexcept | ^~~ /usr/include/c++/14/tuple:2457:5: note: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >&& std::get(tuple<_Elements ...>&&)' 2457 | get(tuple<_Elements...>&& __t) noexcept | ^~~ /usr/include/c++/14/tuple:2451:5: note: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(const tuple<_Elements ...>&)' 2451 | get(const tuple<_Elements...>& __t) noexcept | ^~~ /usr/include/c++/14/tuple:2445:5: note: 'template<long unsigned int __i, class ... _Elements> constexpr std::__tuple_element_t<__i, std::tuple<_Elements ...> >& std::get(tuple<_Elements ...>&)' 2445 | get(tuple<_Elements...>& __t) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:1265:5: note: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(const pair<_Tp1, _Tp2>&&)' 1265 | get(const pair<_Tp1, _Tp2>&& __in) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:1260:5: note: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr const typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(const pair<_Tp1, _Tp2>&)' 1260 | get(const pair<_Tp1, _Tp2>& __in) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:1255:5: note: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type&& std::get(pair<_Tp1, _Tp2>&&)' 1255 | get(pair<_Tp1, _Tp2>&& __in) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:1250:5: note: 'template<long unsigned int _Int, class _Tp1, class _Tp2> constexpr typename std::tuple_element<_Int, std::pair<_Tp1, _Tp2> >::type& std::get(pair<_Tp1, _Tp2>&)' 1250 | get(pair<_Tp1, _Tp2>& __in) noexcept | ^~~ a.cc:16:5: note: 'int get [1001]' 16 | int get[1001]; | ^~~ a.cc:55:35: error: reference to 'get' is ambiguous 55 | rep(i,n+1)mini[i]=get[i]; | ^~~ /usr/include/c++/14/tuple:2517:5: note: candidates are: 'template<class _Tp, class ... _Types> constexpr const _Tp&& std::get(const tuple<_Elements ...>&&)' 2517 | get(const tuple<_Types...>&& __t) noexcept | ^~~ /usr/include/c++/14/tuple:2505:5: note: 'template<class _Tp, class ... _Types> constexpr const _Tp& std::get(const tuple<_Elements ...>&)' 2505 | get(const tuple<_Types...>& __t) noexcept | ^~~ /usr/include/c++/14/tuple:2494:5: note: 'template<class _Tp, class ... _Types> constexpr _Tp&& std::get(tuple<_Elements ...>&&)' 2494 | get(tuple<_Types...>&& __t) noexcept | ^~~ /usr/include/c++/14/tuple:2483:5: note: 'template<class _Tp, class ... _Types> constexpr _Tp& std::get(tuple<_Elements ...>&)' 2483 | get(tuple<_Types...>& __t) noexcept | ^~~ /usr/include/c++/14/tuple:2476:5: note: 'template<long unsigned int __i, class ... _Elements> constexpr std::__enable_if_t<(__i >= sizeof... (_Types))> std::get(const tuple<_Elements ...>&)' 2476 | get(const tuple<_Elements...>&) = delete; | ^~~ /usr/include/c++/14/bits/stl_pair.h:1307:5: note: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const pair<_Up, _Tp>&&)' 1307 | get(const pair<_Up, _Tp>&& __p) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:1302:5: note: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(pair<_Up, _Tp>&&)' 1302 | get(pair<_Up, _Tp>&& __p) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:1297:5: note: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_Up, _Tp>&)' 1297 | get(const pair<_Up, _Tp>& __p) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:1292:5: note: 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_Up, _Tp>&)' 1292 | get(pair<_Up, _Tp>& __p) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:1287:5: note: 'template<class _Tp, class _Up> constexpr const _Tp&& std::get(const pair<_T1, _T2>&&)' 1287 | get(const pair<_Tp, _Up>&& __p) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:1282:5: note: 'template<class _Tp, class _Up> constexpr _Tp&& std::get(pair<_T1, _T2>&&)' 1282 | get(pair<_Tp, _Up>&& __p) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:1277:5: note: 'template<class _Tp, class _Up> constexpr const _Tp& std::get(const pair<_T1, _T2>&)' 1277 | get(const pair<_Tp, _Up>& __p) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:1272:5: note: 'template<class _Tp, class _Up> constexpr _Tp& std::get(pair<_T1, _T2>&)' 1272 | get(pair<_Tp, _Up>& __p) noexcept | ^~~ /usr/include/c++/14/bits/stl_pair.h:150:5: note:
s068715518
p00463
C++
#include<cstdio> #include<iostream> #include<vector> #include<string> #include<map> #include<stack> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) #define reps(i,n) for(int i=1;i<=n;i++) vector<pair<int,int> > y; int main(){ while(1){ int n,m,h,k; scanf("%d%d%d%d",&n,&m,&h,&k); if(n==0)break; int tt[1002]; rep(i,n){ scanf("%d",&tt[i]); } y.clear(); rep(j,m){ int a,b; scanf("%d%d",&a,&b); y.push_back(make_pair(b,a)); } int num[1002]; rep(i,1002)num[i]=i; sort(y.begin(),y.end()); int hav[1002]; rep(i,m){ swap(num[y[i].second-1],num[y[i].second]); } rep(i,n){ hav[num[i]]=tt[i]; } rep(i,1002)num[i]=i; int maxi=0; rep(i,m){ swap(num[y[i].second-1],num[y[i].second]); int a=num[y[i].second-1]; int b=num[y[i].second]; if(a>b)swap(a,b); if(a<k && k<=b){ int val=hav[a]-hav[b]; if(val<0)val*=-1; maxi=max(maxi,val); } } int ans=0; rep(i,k){ ans+=hav[i]; } ans-=maxi; printf("%d\n",ans); } }
a.cc: In function 'int main()': a.cc:35:17: error: 'sort' was not declared in this scope; did you mean 'short'? 35 | sort(y.begin(),y.end()); | ^~~~ | short
s519173708
p00463
C++
#include <iostream> #include <vector> #include <set> #include <utility> using namespace std; typedef pair<int, int> pii; int main(){ while(true){ int n, m, h, k; cin >> n >> m >> h >> k; if(n == 0 && m == 0 && h == 0 && k == 0){ break; } vector<int> points(n); for(int i = 0; i < n; ++i){ cin >> points[i]; } vector<pii> lines(m); for(int i = 0; i < m; ++i){ cin >> lines[i].second >> lines[i].first; } sort(lines.begin(), lines.end()); vector<int> dest(n); for(int i = 0; i < n; ++i){ dest[i] = i; } set<pii> swapTable; for(int i = 0; i < m; ++i){ swap(dest[lines[i].second - 1], dest[lines[i].second]); swapTable.insert(pii( min(dest[lines[i].second - 1], dest[lines[i].second]), max(dest[lines[i].second - 1], dest[lines[i].second]) )); } vector<int> scores(n); for(int i = 0; i < n; ++i){ scores[dest[i]] = points[i]; } int sum = 0, answer = 0; for(int i = 0; i < k; ++i){ sum += scores[i]; } answer = sum; for( set<pii>::iterator it = swapTable.begin(); it != swapTable.end(); ++it ){ if(it->first >= k || it->second < k){ continue; } answer = min(answer, sum - scores[it->first] + scores[it->second]); } cout << answer << endl; } return 0; }
a.cc: In function 'int main()': a.cc:18:17: error: 'sort' was not declared in this scope; did you mean 'short'? 18 | sort(lines.begin(), lines.end()); | ^~~~ | short
s675286178
p00463
C++
#include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <cassert> #include <iostream> #include <sstream> #include <string> #include <vector> #include <queue> #include <set> #include <map> #include <utility> #include <numeric> #include <algorithm> #include <bitset> #include <complex> #include <fstream> using namespace std; typedef unsigned uint; typedef long long Int; typedef vector<int> vint; typedef pair<int,int> pint; #define mp make_pair #define MSG(a) cout << #a << " = " << a << endl; #define rep(i, n) for(int i = 0; i < n; i++) template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; } template<class T> void chmin(T &t, T f) { if (t > f) t = f; } template<class T> void chmax(T &t, T f) { if (t < f) t = f; } int in() { int x; scanf_s("%d", &x); return x; } const int MAX_N = 1000; struct cross { int right_num, left_num; int right_point, left_point; int r, l, h; }; bool operator < (const cross &left, const cross &right) { return left.h < right.h; } int main() { int n, m, h, k; while( cin >> n >> m >> h >> k && n ) { int points[1005]; vector<cross> crosses; rep(i, n) cin >> points[i]; rep(i, m) { cross c; cin >> c.l >> c.h; c.r = c.l + 1; crosses.push_back(c); } sort(crosses.begin(), crosses.end()); int work[1001]; rep(i, n) work[i+1] = i+1; rep(i, m) { crosses[i].left_num = work[crosses[i].l]; crosses[i].right_num = work[crosses[i].r]; swap(crosses[i].l, crosses[i].r); } int score = 0; rep(i, n) work[i + 1] = points[i]; rep(i, k) score += work[i+1]; int max = 0; rep(i, m) { // out of range if( ( crosses[i].left_num <= k && crosses[i].right_num <= k ) || ( crosses[i].left_num > k && crosses[i].right_num > k ) ) continue; // right if(crosses[i].left_num <= k) { if( crosses[i].left_point >= crosses[i].right_point ) continue; chmin(max, crosses[i].right_point - crosses[i].left_point); } // left if(crosses[i].right_num <= k) { if( crosses[i].left_point <= crosses[i].right_point ) continue; chmin(max, crosses[i].left_point - crosses[i].right_point); } } cout << score - max << endl; } }
a.cc: In function 'int in()': a.cc:33:19: error: 'scanf_s' was not declared in this scope; did you mean 'scanf'? 33 | int in() { int x; scanf_s("%d", &x); return x; } | ^~~~~~~ | scanf
s910893181
p00463
C++
#include <iostream> #include <algorithm> #include <set> using namespace std; int n,m,h,k; inline long long sumk(int *score, int k){ long long ret = 0; for(int i=0;i<k;i++) ret += score[i]; return ret; } int main(){ while(cin >> n >> m >> h >> k){ bool edge[h-1][n-1]; int point[n]; int score[n]; int work[n]; long long ret = 1e+15; set<pair<int,int> > cand; fill((bool *)edge, (bool *)edge + (n-1)*(h-1), false); for(int i=0;i<n;i++){ cin >> point[i]; work[i] = i; } for(int i=0;i<m;i++){ int x,y; cin >> x >> y; edge[y-1][x-1] = true; } for(int i=0;i<h-1;i++){ for(int j=0;j<n-1;j++){ if(edge[i][j]){ cand.insert(make_pair(work[j], work[j+1])); swap(work[j], work[j+1]); } } } for(int i=0;i<n;i++){ score[work[i]] = point[i]; } ret = min(ret, sumk(score, k)); it = cand.begin(); while(it != cand.end()){ swap(score[(*it).first], score[(*it).second]); ret = min(ret, sumk(score,k)); swap(score[(*it).first], score[(*it).second]); ++it; } cout << ret << endl; } }
a.cc: In function 'int main()': a.cc:48:17: error: 'it' was not declared in this scope; did you mean 'int'? 48 | it = cand.begin(); | ^~ | int
s221420198
p00463
C++
#include <iostream> #include <cstring> #include <vector> using namespace std; int n,m,h,k; vector< pair<int,int> > g[1000]; int v[1000]; short dp[1010][1010][2]; short dp2[1010][1010][2]; int dfs(int x,int y,int l){ if( dp[x][y][l] != -1 ) return dp[x][y][l]; if( y == h ) return x; if( l == 0 ){ int ny = (*upper_bound(g[x].begin(),g[x].end(),make_pair(y,999999))).first; return dp[x][y][l] = dfs(x,ny,1); }else{ int sw = (*lower_bound(g[x].begin(),g[x].end(),make_pair(y,-999999))).second; return dp[x][y][l] = dfs(x+sw,y,0); } } int dfs2(int x,int y,int l){ if( dp2[x][y][l] != -1 ) return dp2[x][y][l]; if( y == 0 ) return x; if( l == 0 ){ int ny = (*(lower_bound(g[x].begin(),g[x].end(),make_pair(y,-999999))-1)).first; return dp2[x][y][l] = dfs2(x,ny,1); }else{ int sw = (*lower_bound(g[x].begin(),g[x].end(),make_pair(y,-999999))).second; return dp2[x][y][l] = dfs2(x+sw,y,0); } } int main(){ while(cin >> n >> m >> h >> k && n){ memset(dp,-1,sizeof(dp)); memset(dp2,-1,sizeof(dp2)); for(int i = 0 ; i < n ; i++) g[i].push_back( make_pair(0,-2) ) , g[i].push_back( make_pair(h,-2) ); for(int i = 0 ; i < n ; i++) cin >> v[i]; vector< pair<int,int> > e; for(int i = 0 ; i < m ; i++){ int a,b; cin >> a >> b; a--; g[a].push_back(make_pair(b,1)); g[a+1].push_back(make_pair(b,-1)); e.push_back(make_pair(a,b)); } for(int i = 0 ; i < n ; i++) sort(g[i].begin(),g[i].end()); long long ans = 0; for(int i = 0 ; i < k ; i++){ ans += v[dfs(0,i,0)]; } //for(int i = 0 ; i < n ; i++) cout << dfs(i,0,0) << endl; long long tans = ans; for(int i = 0 ; i < m ; i++){ int a = e[i].first , b = e[i].second; int c = dfs2(a,b,0) , d = dfs2(a+1,b,0); //cout << i << " " << ">" << dfs(a,b,1) << " " << dfs(a+1,b,1) << endl; int C = v[dfs(a,b,1)] , D = v[dfs(a+1,b,1)]; //cout << "(" << a << "," << a+1 << ")" << " - " << b << " [" << c << "," << d << "]" << " = {" << C << "," << D << "}" << endl; long long sub = ans; if( c >= k && d < k){ sub += C-D; }else if( d >= k && c < k){ sub += D-C; }else{ } //cout << "[" << a << " " << a+1 << "]" << " " << b << " " << sub << endl; //cout << sub << endl; tans = min(sub,tans); } cout << tans << endl; } }
a.cc: In function 'int dfs(int, int, int)': a.cc:21:28: error: 'upper_bound' was not declared in this scope 21 | int ny = (*upper_bound(g[x].begin(),g[x].end(),make_pair(y,999999))).first; | ^~~~~~~~~~~ a.cc: In function 'int main()': a.cc:64:46: error: 'sort' was not declared in this scope; did you mean 'short'? 64 | for(int i = 0 ; i < n ; i++) sort(g[i].begin(),g[i].end()); | ^~~~ | short
s198954762
p00463
C++
#include <cstdio> #include <queue> #include <vector> int main(void){ int n,m,h,k; scanf("%d%d%d%d",&n,&n,&h,&k); while(n!=0){ int ten[1000]={0}; int bo[100000]={0}; int maps[100000][1000]={0}; int i=0; priority_queue<pair<int,int> > que; for(i=0;i<n;i++)scanf("%d",&(ten[i])); pair<int,int>pa; for(i=0;i<m;i++){ scanf("%d%d",&(pa.second),&(pa.first)); que.push(pa); } for(i=0;i<m;i++){ pa=que.top(); bo[i]=pa.second; que.pop(); } } return 0; }
a.cc: In function 'int main()': a.cc:13:5: error: 'priority_queue' was not declared in this scope; did you mean 'std::priority_queue'? 13 | priority_queue<pair<int,int> > que; | ^~~~~~~~~~~~~~ | std::priority_queue In file included from /usr/include/c++/14/queue:66, from a.cc:2: /usr/include/c++/14/bits/stl_queue.h:496:11: note: 'std::priority_queue' declared here 496 | class priority_queue | ^~~~~~~~~~~~~~ a.cc:13:20: error: 'pair' was not declared in this scope; did you mean 'std::pair'? 13 | priority_queue<pair<int,int> > que; | ^~~~ | std::pair In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/deque:62, from /usr/include/c++/14/queue:62: /usr/include/c++/14/bits/stl_pair.h:89:12: note: 'std::pair' declared here 89 | struct pair; | ^~~~ a.cc:13:25: error: expected primary-expression before 'int' 13 | priority_queue<pair<int,int> > que; | ^~~ a.cc:15:10: error: expected primary-expression before 'int' 15 | pair<int,int>pa; | ^~~ a.cc:17:22: error: 'pa' was not declared in this scope 17 | scanf("%d%d",&(pa.second),&(pa.first)); | ^~ a.cc:18:7: error: 'que' was not declared in this scope 18 | que.push(pa); | ^~~ a.cc:21:7: error: 'pa' was not declared in this scope 21 | pa=que.top(); | ^~ a.cc:21:10: error: 'que' was not declared in this scope 21 | pa=que.top(); | ^~~
s722603049
p00463
C++
#include<iostream> #include<algorithm> #include<vector> using namespace std; pair<int,int> make_pair(int a,int b){ pair<int,int> ret; ret.first=a; ret.second=b; return ret; } bool f(pair<int,int> a,pair<int,int> b){ return a.second<=b.second; } int main(){ while(1){ int n,m,h,k,sum=0,ret=2000000001; int s[1002] char a[100000+2],b[100000+2]; char t[1005],u[1005]; vector<pair<int,int>> vp,lis; scanf("%d%d%d%d",&n,&m,&h,&k); if(n==0)break; for(int i=0;i<1000;i++){t[i]=i; u[i]=i;} for(int i=1;i<=n;i++){ scanf("%d",&s[i]); //t[i]=i; //u[i]=i; } for(int i=1;i<=m;i++){ scanf("%d%d",&a[i],&b[i]); vp.push_back(make_pair(a[i],b[i])); } sort(vp.begin(),vp.end(),f); /*for(int i=0;i<m;i++){ lis.push_back(make_pair(u[vp[i].first],u[vp[i].first+1])); int c=t[u[vp[i].first]]; t[u[vp[i].first]]=t[u[vp[i].first+1]]; t[u[vp[i].first+1]]=c; c=u[vp[i].first]; u[vp[i].first]=u[vp[i].first+1]; u[vp[i].first+1]=c; } for(int i=1;i<=k;i++)sum+=s[t[i]]; ret=sum; //cout<<ret<<endl; for(int i=0;i<m;i++){ if(lis[i].first<=k&&lis[i].second>k)ret=min(ret,sum+s[t[lis[i].second]]-s[t[lis[i].first]]); if(lis[i].first>k&&lis[i].second<=k)ret=min(ret,sum-s[t[lis[i].second]]+s[t[lis[i].first]]); }*/ printf("%d\n",ret); } return 0; }
a.cc: In function 'int main()': a.cc:18:9: error: expected initializer before 'char' 18 | char a[100000+2],b[100000+2]; | ^~~~ a.cc:25:29: error: 's' was not declared in this scope 25 | scanf("%d",&s[i]); | ^ a.cc:30:31: error: 'a' was not declared in this scope 30 | scanf("%d%d",&a[i],&b[i]); | ^ a.cc:30:37: error: 'b' was not declared in this scope 30 | scanf("%d%d",&a[i],&b[i]); | ^
s145253011
p00464
Java
import java.util.Scanner; public class Main{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); int x = 0; int y = 0; int h; int w; int n; int[][] route; while(ture){ h = scan.nextInt(); w = scan.nextInt(); n = scan.nextInt(); if(h == 0 && w == 0 && n == 0){ break; } route = new int[h][w]; for(int i = 0;i < h;i++){ for(int j = 0;j < w;j++){ route[i][j] = scan.nextInt(); } } for(int i = 0;i < n;i++){ x = 0; y = 0; while(x < h && y < w){ if(route[x][y] == 0){ route[x][y] = 1; x++; }else{ route[x][y] = 0; y++; } } } System.out.println(x+1 + " " + (y+1)); } } }
Main.java:12: error: cannot find symbol while(ture){ ^ symbol: variable ture location: class Main 1 error
s983830748
p00464
C
#include<stdio.h> #include<cstdio> #include<algorithm> #include<functional> using namespace std; int h,w,n,i,j; int kan[10000][10000]; int dp[10000][10000]; int main(void){ scanf("%d %d %d",&h,&w,&n); while(h!=0 && w!=0 && n!=0){ for(i=1;i<=h;i++){ for(j=1;j<=w;j++){ scanf("%d",&kan[i][j]); //kan=kanbann dp[i][j]=0; } } dp[1][1]=n-1; for(i=1;i<=h;i++){ for(j=1;j<=w;j++){ if(kan[i][j]==1){ if(dp[i][j]%2==1){ dp[i][j+1]+=(dp[i][j]/2)+1; dp[i+1][j]+=(dp[i][j]/2); } else { dp[i][j+1]=dp[i][j]/2; dp[i+1][j]=dp[i][j]/2; } } else if(kan[i][j]==0){ if(dp[i][j]%2==1){ dp[i][j+1]+=(dp[i][j]/2); dp[i+1][j]+=(dp[i][j]/2)+1; } else { dp[i][j+1]=dp[i][j]/2; dp[i+1][j]=dp[i][j]/2; } } } } for(i=1;i<=h;i++){ for(j=1;j<=w;j++){ if(dp[i][j]!=0){ if(dp[i][j]%2==1){ if(kan[i][j]==0){ kan[i][j]=1; } else if(kan[i][j]==1){ kan[i][j]=0; } } } } } i=1; j=1; //printf("%d %d\n",h,w); while(i<h+1 || j<w+1){ if(kan[i][j]==1){ j++; } else if(kan[i][j]==0){ i++; } if(i==h+1 || j==w+1){ break; } } printf("%d %d\n",i,j); /*for(i=1;i<=h;i++){ for(j=1;j<=w;j++){ printf("%d ",kan[i][j]); } printf("\n"); }*/ scanf("%d &d %d\n",&h,&w,&n); } return 0; }
main.c:2:9: fatal error: cstdio: No such file or directory 2 | #include<cstdio> | ^~~~~~~~ compilation terminated.
s284080859
p00464
C
#include<stdio.h> int main(void) { int h, w, n, key[1005][1005], x, y, i, j, k, l; scanf("%d %d %d", &h, &w, &n); while ( 1 ) { for ( i = 1; i <= h + 1; i++ ) { for ( j = 1; j <= j + 1; j++ ) { scanf("%d", &[i][j]); } } for ( k = 0; k < n; k++ ) { x = y = 1; while () { if ( key[y][x] == 0 ) { key[y][x] = 1; y++; } else if ( key[y][x] == 1 ) { key[y][x] = 0; x++; } if ( x == x + 1 || y == h + 1 ) break } } printf("%d %d\n", x, y); scanf("%d %d %d", &h, &w, &n); if ( h == 0 && w == 0 && n == 0 ) break; } return 0; }
main.c: In function 'main': main.c:8:26: error: expected expression before '[' token 8 | scanf("%d", &[i][j]); | ^ main.c:13:17: error: expected expression before ')' token 13 | while () { | ^ main.c:22:50: error: expected ';' before '}' token 22 | if ( x == x + 1 || y == h + 1 ) break | ^ | ; 23 | } | ~
s584309504
p00464
C
#include<stdio.h> int h,w,n; bool d[1000][1000]; int t[1000][1000]; int i,j; int main(){ while(1){ scanf("%d %d %d",&h,&w,&n); if(h==0)return 0; for(i=0;i<h;i++)for(j=0;j<w;j++){ int x; scanf("%d",&x); if(x==1)d[i][j]=true; if(x==0)d[i][j]=false; t[i][j]=0; } t[0][0]=n-1; for(i=0;i<h;i++)for(j=0;j<w;j++){ if(t[i][j]%2==0){ if(i+1<h)t[i+1][j]+=t[i][j]/2; if(j+1<w)t[i][j+1]+=t[i][j]/2; } else{ if(d[i][j]){ if(i+1<h)t[i+1][j]+=t[i][j]/2; if(j+1<w)t[i][j+1]+=t[i][j]/2+1; } else{ if(i+1<h)t[i+1][j]+=t[i][j]/2+1; if(j+1<w)t[i][j+1]+=t[i][j]/2; } d[i][j]=!d[i][j]; } } int x,y; x=0; y=0; while(x!=w&&y!=h){ if(d[y][x])x++; else y++; } printf("%d %d\n",x+1,y+1); } }
main.c:3:1: error: unknown type name 'bool' 3 | bool d[1000][1000]; | ^~~~ main.c:2:1: note: 'bool' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' 1 | #include<stdio.h> +++ |+#include <stdbool.h> 2 | int h,w,n; main.c: In function 'main': main.c:14:41: error: 'true' undeclared (first use in this function) 14 | if(x==1)d[i][j]=true; | ^~~~ main.c:14:41: note: 'true' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>' main.c:14:41: note: each undeclared identifier is reported only once for each function it appears in main.c:15:41: error: 'false' undeclared (first use in this function) 15 | if(x==0)d[i][j]=false; | ^~~~~ main.c:15:41: note: 'false' is defined in header '<stdbool.h>'; this is probably fixable by adding '#include <stdbool.h>'
s171267285
p00464
C++
#include<bits/stdc++.h> #include<algorithm> #include<vector> #include<queue> using namespace std; typedef long long ll; int h,w,n,c[1000][1000]; int dp[1001][1001]; int d[1000][1000]; int main(){ while(scanf("%d%d%d",&h,&w,&n),h){ for(int i=0;i<h;i++) for(int j=0;j<w;j++) scanf("%d",&c[i][j]); for(int i=0;i<=1000;i++) for(int j=0;j<=1000;j++) dp[i][j]=0; dp[1][1]=n-1; for(int i=1;i<=h;i++) for(int j=1;j<=w;j++){ if(i!=1){ if(c[i-2][j-1]==0) dp[i][j]+=(dp[i-1][j]+1)/2; else dp[i][j]+=dp[i-1][j]/2; } if(j!=1){ if(c[i-1][j-2]==1) dp[i][j]+=(dp[i][j-1]+1)/2; else dp[i][j]+=dp[i][j]/2; } } for(int i=0;i<h;i++) for(int j=0;j<w;j++) d[i][j]=(c[i][j]+dp[i+1][j+1])%2; int i=1,j=1; while(i<=h&&j<=w){ if(d[i-1][j-1]) j++; else i++; } printf("%d %d\n",i,j); }
a.cc: In function 'int main()': a.cc:35:10: error: expected '}' at end of input 35 | } | ^ a.cc:12:11: note: to match this '{' 12 | int main(){ | ^
s123058000
p00464
C++
#include<iostream> #define lol(i,n) for(int i=0;i<n;i++) using namespace std; int d[1010][1010],h,w,a; int main(){ while(cin>>h>>w>>a&&h){ int x=0,y=0; memset(d,0,sizeof(d)); d[0][0]=a; lol(i,h)lol(j,w){ cin>>a; d[i+1][j]+=d[i][j]/2+d[i][j]%2*(1-a); d[i][j+1]+=d[i][j]/2+d[i][j]%2*a; d[i][j]+=a; } while(x<w&&y<h){ if(d[y][x]%2)y++; else x++; } cout<<y+1<<" "<<x+1<<endl; } return 0; }
a.cc: In function 'int main()': a.cc:8:5: error: 'memset' was not declared in this scope 8 | memset(d,0,sizeof(d)); | ^~~~~~ 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 | #define lol(i,n) for(int i=0;i<n;i++)
s219081584
p00464
C++
while(1) { cin>>h>>w>>n; if(h==0&&w==0&&n==0) break; int r[w][h]; for(int i=0; i<h; i++) for(int j=0; j<w; j++) cin>>r[j][i]; int x,y; for(long l=0; l<n; l++) { x=0,y=0; while(1) { if(x>w-1 || y>h-1) break; if(r[x][y]==0) { r[x][y]=1; y++; }else{ r[x][y]=0; x++; } } if(l==n-1) cout<<y+1<<" "<<x+1<<endl; } } }
a.cc:1:3: error: expected unqualified-id before 'while' 1 | while(1) { | ^~~~~ a.cc:27:1: error: expected declaration before '}' token 27 | } | ^
s044527351
p00464
C++
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <iterator> #include <list> #include <map> #include <queue> #include <bitset> #include <fstream> #include <cmath> #include <ctime> #include <numeric> using namespace std; typedef long long ll; typedef vector<int> vint; typedef pair<int,int> pint; #define REP(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) REP(i,0,n) #define MSG(a) cout << #a << " " << a << endl; template<class T> void chmin(T &t, T f) { if (t > f) t = f; } template<class T> void chmax(T &t, T f) { if (t < f) t = f; } int dp[1000][1000]; int main() { int w, h, n; while(cin >> h >> w >> n && w) { memset(dp, 0, sizeof(dp)); vector<vint> field(w, vint(h)); rep(y, h) rep(x, w) cin >> field[x][y]; dp[0][0] = n-1; rep(x, w) rep(y, h) { // “Œ‚ð–K‚ê‚éê‡ if(x+1 < w) dp[x+1][y] += (dp[x][y] + dp[x][y] % 2 * -(1 - field[x][y] * 2)) / 2; // “ì‚ð–K‚ê‚éê‡ if(y+1 < h) dp[x][y+1] += (dp[x][y] + dp[x][y] % 2 * (1 - field[x][y] * 2)) / 2; } pint p = make_pair(0,0); while(p.first < w && p.second < h) { if(dp[p.first][p.second] & 1) field[p.first][p.second] = !field[p.first][p.second]; if(field[p.first][p.second]) p.first++; else p.second++; } cout << p.second + 1 << " " << p.first + 1 << endl; } }
a.cc: In function 'int main()': a.cc:31:17: error: 'memset' was not declared in this scope 31 | memset(dp, 0, sizeof(dp)); | ^~~~~~ a.cc:14:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 13 | #include <numeric> +++ |+#include <cstring> 14 | using namespace std;
s144296796
p00464
C++
#include <cstdio> #include <iostream> int num[1005][1005],h,w,n; pair<int,int>p; int main(){ while(1){ scanf("%d %d %d",&h,&w,&n); for(int i=1;i<=h;i++){ for(int j=1;j<=w;j++){ scanf("%d",&num[j][i]); } } int y=1,s=1,cou=0; while(1){ cou++; if(num[y][s]){ y++; num[y][s]=(num[y][s]+1)%2; if(y==w+1){ p=make_pair(y,s); break; }}else{ num[y][s]=(num[y][s]+1)%2; s++; if(s==h+1){ p=make_pair(y,s); break; } } if(cou==n){ cout << p.first << " " << p.second << endl; return 0; } if(p.first==1 && p.second==h){ cout << p.first <<" "<< p.second << endl; return 0; } if(p.first==w && p.second==1){ cout << p.first <<" "<<p.second <<endl; return 0; } } } }
a.cc:4:1: error: 'pair' does not name a type 4 | pair<int,int>p; | ^~~~ a.cc: In function 'int main()': a.cc:20:1: error: 'p' was not declared in this scope 20 | p=make_pair(y,s); | ^ a.cc:20:3: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 20 | p=make_pair(y,s); | ^~~~~~~~~ | std::make_pair In file included from /usr/include/c++/14/bits/stl_algobase.h:64, from /usr/include/c++/14/string:51, from /usr/include/c++/14/bits/locale_classes.h:40, from /usr/include/c++/14/bits/ios_base.h:41, from /usr/include/c++/14/ios:44, from /usr/include/c++/14/ostream:40, from /usr/include/c++/14/iostream:41, from a.cc:2: /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:26:1: error: 'p' was not declared in this scope 26 | p=make_pair(y,s); | ^ a.cc:26:3: error: 'make_pair' was not declared in this scope; did you mean 'std::make_pair'? 26 | p=make_pair(y,s); | ^~~~~~~~~ | std::make_pair /usr/include/c++/14/bits/stl_pair.h:1132:5: note: 'std::make_pair' declared here 1132 | make_pair(_T1&& __x, _T2&& __y) | ^~~~~~~~~ a.cc:31:1: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 31 | cout << p.first << " " << p.second << endl; return 0; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:31:9: error: 'p' was not declared in this scope 31 | cout << p.first << " " << p.second << endl; return 0; | ^ a.cc:31:39: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 31 | cout << p.first << " " << p.second << endl; return 0; | ^~~~ | std::endl /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~ a.cc:33:4: error: 'p' was not declared in this scope 33 | if(p.first==1 && p.second==h){ | ^ a.cc:34:1: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 34 | cout << p.first <<" "<< p.second << endl; return 0; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:34:37: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 34 | cout << p.first <<" "<< p.second << endl; return 0; | ^~~~ | std::endl /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~ a.cc:36:4: error: 'p' was not declared in this scope 36 | if(p.first==w && p.second==1){ | ^ a.cc:37:1: error: 'cout' was not declared in this scope; did you mean 'std::cout'? 37 | cout << p.first <<" "<<p.second <<endl; return 0; | ^~~~ | std::cout /usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here 63 | extern ostream cout; ///< Linked to standard output | ^~~~ a.cc:37:35: error: 'endl' was not declared in this scope; did you mean 'std::endl'? 37 | cout << p.first <<" "<<p.second <<endl; return 0; | ^~~~ | std::endl /usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here 744 | endl(basic_ostream<_CharT, _Traits>& __os) | ^~~~
s120286390
p00464
C++
#include <cstdio> #include <iostream.h> int num[1005][1005],h,w,n; pair<int,int>p; int main(){ while(1){ scanf("%d %d %d",&h,&w,&n); for(int i=1;i<=h;i++){ for(int j=1;j<=w;j++){ scanf("%d",&num[j][i]); } } int y=1,s=1,cou=0; while(1){ cou++; if(num[y][s]){ y++; num[y][s]=(num[y][s]+1)%2; p=make_pair(y,s); break; }else{ num[y][s]=(num[y][s]+1)%2; s++; p=make_pair(y,s); } if(cou==n){ cout << p.first << " " << p.second << endl; return 0; } if(p.first==1 && p.second==h){ cout << p.first <<" "<< p.second << endl; return 0; } if(p.first==w && p.second==1){ cout << p.first <<" "<<p.second <<endl; return 0; } } } }
a.cc:2:10: fatal error: iostream.h: No such file or directory 2 | #include <iostream.h> | ^~~~~~~~~~~~ compilation terminated.
s488456771
p00464
C++
#include <cstdio> #include <iostream.h> int num[1005][1005],h,w,n; pair<int,int>p; int main(){ while(1){ scanf("%d %d %d",&h,&w,&n); for(int i=1;i<=h;i++){ for(int j=1;j<=w;j++){ scanf("%d",&num[j][i]); } } int y=1,s=1,cou=0; while(1){ cou++; if(num[y][s]){ y++; num[y][s]=(num[y][s]+1)%2; p=make_pair(y,s); }else{ num[y][s]=(num[y][s]+1)%2; s++; p=make_pair(y,s); } if(cou==n){ cout << p.first << " " << p.second << endl; return 0; } if(p.first==1 && p.second==h){ cout << p.first <<" "<< p.second << endl; return 0; } if(p.first==w && p.second==1){ cout << p.first <<" "<<p.second <<endl; return 0; } } } }
a.cc:2:10: fatal error: iostream.h: No such file or directory 2 | #include <iostream.h> | ^~~~~~~~~~~~ compilation terminated.
s777128670
p00465
Java
### constant MAX_INT = 1 << 30 ### main loop do r = gets.strip.to_i break if r == 0 mlss = [] for k in (0..1) w, h, ex, ey = gets.strip.split(' ').map{|s| s.to_i} ex -= 1 ey -= 1 als = h.times.map{gets.strip.split(' ').map{|s| s.to_i}} mls = h.times.map{w.times.map{MAX_INT}} visited = h.times.map{w.times.map{false}} mls[ey][ex] = als[ey][ex] visited[ey][ex] = als[ey][ex] q = [[ex, ey]] mlq = [] while ! q.empty? u = q.min{|a, b| mls[a[1]][a[0]] <=> mls[b[1]][b[0]]} q.delete u x, y = u mlq << mls[y][x] break if mlq.length > r nbrs = [] nbrs << [x - 1, y] if x > 0 nbrs << [x + 1, y] if x < w - 1 nbrs << [x, y - 1] if y > 0 nbrs << [x, y + 1] if y < h - 1 for v in nbrs vx, vy = v l = [mls[y][x], als[vy][vx]].max if mls[vy][vx] > l mls[vy][vx] = l if ! visited[vy][vx] visited [vy][vx] = true q << [vx, vy] end end end end mlss << [0] + mlq end #p mlss min_sum = MAX_INT mlen0 = mlss[0].length mlen1 = mlss[1].length i0 = 0 i1 = r - i0 if i1 >= mlen1 i1 = mlen1 - 1 i0 = r - i1 end while i0 < mlen0 && i1 >= 0 sum = mlss[0][i0] + mlss[1][i1] min_sum = sum if min_sum > sum i0 += 1 i1 -= 1 end puts min_sum end
Main.java:1: error: illegal character: '#' ### constant ^ Main.java:1: error: illegal character: '#' ### constant ^ Main.java:1: error: illegal character: '#' ### constant ^ Main.java:3: error: class, interface, enum, or record expected MAX_INT = 1 << 30 ^ Main.java:5: error: illegal character: '#' ### main ^ Main.java:5: error: illegal character: '#' ### main ^ Main.java:5: error: illegal character: '#' ### main ^ Main.java:58: error: illegal character: '#' #p mlss ^ 8 errors
s788441291
p00465
C
#include<iostream> #include<cstdio> #include<queue> #include<vector> #include<algorithm> #include<map> #include<climits> using namespace std; int field[500][500],cost[500][500]; int R,W,H,X,Y; int dx[] = {1,-1,0,0}; int dy[] = {0,0,1,-1}; struct edge{ int y,x,cost; edge(int y,int x,int cost) : y(y) , x(x) , cost(cost) {} }; bool operator < (const edge &a,const edge &b){ return a.cost > b.cost; } vector<int> dijkstra(){ int x,y,nx,ny,rec; vector<int> foo(500000, INT_MAX / 4); foo[0] = 0; priority_queue<edge> que; for(int i = 0; i < H; i++){ for(int j = 0; j < W; j++){ cost[i][j] = INT_MAX; } } cost[Y][X] = 1; que.push(edge(Y,X,1)); int rank = 0; foo[rank++] = 0; while(!que.empty()){ edge crt = que.top(); que.pop(); x = crt.x; y = crt.y; foo[rank] = max(foo[rank - 1], crt.cost); rank++; if(cost[y][x] != crt.cost) continue; for(int i = 0; i < 4; i++){ nx = x + dx[i]; ny = y + dy[i]; if(nx == -1 || ny == -1 || nx == W || ny == H)continue; rec = max(field[ny][nx], crt.cost); if(cost[ny][nx] > rec){ cost[ny][nx] = rec; que.push(edge(ny,nx,rec)); } } } return foo; } int main(){ while(scanf("%d", &R)){ if(!R) break; vector<int> f(500000, INT_MAX / 2); vector<int> g(500000, INT_MAX / 2); for(int q = 0; q < 2; q++){ scanf("%d %d %d %d", &W,&H,&X,&Y); X--; Y--; for(int i = 0; i < H; i++){ for(int j = 0; j < W;j++){ scanf("%d",&field[i][j]); } } if (q == 0){ f = dijkstra(); } else { g = dijkstra(); } } int res = INT_MAX; for (int i = 0; i <= R; i++){ res = min(res, f[i] + g[R - i]); } printf("%d\n", res); } return 0; }
main.c:1:9: fatal error: iostream: No such file or directory 1 | #include<iostream> | ^~~~~~~~~~ compilation terminated.
s745176884
p00465
C++
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> Pint; typedef pair<ll, int> P; //typedef tuple<int,int,int> T; ll INFL = 1000000000000000010;//10^18 = 2^60 int INF = 2147483600;//10^9 ll MOD = 1000000007; vector<int> dy(4); vector<int> dx(4); dy.at(0) = 1; dy.at(1) = -1; dx.at(2) = 1; dx.at(3) = -1; vector<ll> Ans(0); int solve(){ int R; cin >> R; if(R == 0)return 0; int H1,W1,X1,Y1; cin >> W1 >> H1 >> X1 >> Y1; X1--; Y1--; vector<vector<ll> > mp1(H1, vector<ll>(W1)); vector<vector<ll> > d1(H1, vector<ll>(W1, INFL)); for(int i = 0; i < H1; i++){ for(int j = 0; j < W1; j++){ cin >> mp1[i][j]; } } d1[Y1][X1] = 1; priority_queue<pair<ll, pair<int, int> > > pque1; pque1.push({1, {Y1, X1}}); while(!pque1.empty()){ ll c; int y,x; c = pque1.top().first; y = pque1.top().second.first; x = pque1.top().second.second; pque1.pop(); if(c > d1[y][x]) continue; for(int i = 0; i < 4; i++){ int ny = y + dy[i]; int nx = x + dx[i]; if(0 <= ny && ny < H1 && 0 <= nx && nx < W1){ if(d1[ny][nx] > d1[y][x]){ if(d1[y][x] > mp1[ny][nx]){ d1[ny][nx] = d1[y][x]; }else{ d1[ny][nx] = mp1[ny][nx]; } pque1.push({d1[ny][nx], {ny, nx}}); }else if(d1[ny][nx] > d1[y][x]){ d1[ny][nx] = mp1[ny][nx]; pque1.push({d1[ny][nx], {ny, nx}}); } } } } int H2,W2,X2,Y2; cin >> W2 >> H2 >> X2 >> Y2; X2--; Y2--; vector<vector<ll> > mp2(H2, vector<ll>(W2)); vector<vector<ll> > d2(H2, vector<ll>(W2, INFL)); for(int i = 0; i < H2; i++){ for(int j = 0; j < W2; j++){ cin >> mp2[i][j]; } } d2[Y2][X2] = 1; priority_queue<pair<ll, pair<int, int> > > pque2; pque2.push({1, {Y2, X2}}); while(!pque2.empty()){ ll c; int y,x; c = pque2.top().first; y = pque2.top().second.first; x = pque2.top().second.second; pque2.pop(); if(c > d2[y][x]) continue; for(int i = 0; i < 4; i++){ int ny = y + dy[i]; int nx = x + dx[i]; if(0 <= ny && ny < H2 && 0 <= nx && nx < W2){ if(d2[ny][nx] > d2[y][x]){ if(d2[y][x] > mp2[ny][nx]){ d2[ny][nx] = d2[y][x]; }else{ d2[ny][nx] = mp2[ny][nx]; } pque2.push({d2[ny][nx], {ny, nx}}); }else if(d2[ny][nx] > d2[y][x]){ d2[ny][nx] = mp2[ny][nx]; pque2.push({d2[ny][nx], {ny, nx}}); } } } } vector<pair<ll,int> > O1(0); vector<ll> COST1(0); for(int i = 0; i < H1; i++){ for(int j = 0; j < W1; j++){ COST1.push_back(d1[i][j]); } } sort(COST1.begin(), COST1.end()); COST1.push_back(INFL); ll ad1 = COST1.at(0); int cnt = 0; for(int i = 0; i < COST1.size(); i++){ if(ad1 == COST1.at(i)){ cnt++; }else{ O1.push_back({ad1, cnt}); ad1 = COST1.at(i); cnt++; } } vector<pair<ll,int> > O2(1); O2.at(0).first = 0; O2.at(0).second = 0; vector<ll> COST2(0); for(int i = 0; i < H2; i++){ for(int j = 0; j < W2; j++){ COST2.push_back(d2[i][j]); } } sort(COST2.begin(), COST2.end()); COST2.push_back(INFL); ll ad2 = COST2.at(0); cnt = 0; for(int i = 0; i < COST2.size(); i++){ if(ad2 == COST2.at(i)){ cnt++; }else{ O2.push_back({ad2, cnt}); ad2 = COST2.at(i); cnt++; } } ll ans = INFL; int right = -1; for(int i = 0; i < O1.size(); i++){ ll cost = O1.at(i).first; int rest = R - O1.at(i).second; if(rest > O2.at(O2.size()-1).second) continue; int left = -1; if(right == -1){ right = O2.size(); } int mid; while(right - left > 1){ mid = (left + right) / 2; if(O2.at(mid).second >= rest){ right = mid; }else{ left = mid; } } cost += O2.at(right).first; ans = min(ans, cost); } Ans.push_back(ans); solve(); return 0; } int main(void){ solve(); for(int i = 0; i < Ans.size(); i++){ cout << Ans.at(i) << endl; } }
a.cc:12:1: error: 'dy' does not name a type 12 | dy.at(0) = 1; | ^~ a.cc:13:1: error: 'dy' does not name a type 13 | dy.at(1) = -1; | ^~ a.cc:14:1: error: 'dx' does not name a type 14 | dx.at(2) = 1; | ^~ a.cc:15:1: error: 'dx' does not name a type 15 | dx.at(3) = -1; | ^~
s288232653
p00465
C++
#include<iostream> #include<queue> #include<cstring> #include<map> #include<vector> using namespace std; #define INF (1<<24) int dy[]={-1,0,1,0}; int dx[]={0,1,0,-1}; struct state { int y,x,cost; bool operator < (const state &p)const{ return cost > p.cost; } }; int R; int th,tw,uh,uw,ty,tx,uy,ux; int t[500][500],u[500][500]; int T[100000],U[100000]; int d[500][500]; vector<int> G; map<int,int> g; void compute(int a[500][500],int H,int W,int sy,int sx,int v[100000]){ for(int i=0;i<500;i++)for(int j=0;j<500;j++)d[i][j]=INF; priority_queue<state> Q; Q.push((state){sy,sx,1}); d[sy][sx]=1; while(!Q.empty()){ state s=Q.top();Q.pop(); if(d[s.y][s.x]<s.cost)continue; v[g[s.cost]]++; for(int i=0;i<4;i++){ int ny=s.y+dy[i],nx=s.x+dx[i]; if(ny<0||nx<0)continue; if(ny>=H||nx>=W)continue; int ncost=max(a[ny][nx],s.cost); if(d[ny][nx]<=ncost)continue; d[ny][nx]=ncost; Q.push((state){ny,nx,ncost}); } } } void solve(){ sort(G.begin(),G.end()); G.erase(unique(G.begin(),G.end()),G.end()); for(int i=0;i<(int)G.size();i++)g[G[i]]=i; compute(t,th,tw,ty,tx,T); compute(u,uh,uw,uy,ux,U); int size=G.size(); for(int i=0;i<size;i++){ if(i)T[i]+=T[i-1]; if(i)U[i]+=U[i-1]; //cout<<T[i]<<" "<<U[i]<<" "<<G[i]<<endl; } int ans=INF; for(int i=0;i<size;i++){ int target=R-T[i]; int* it=lower_bound(U,U+size,target); if(it==U+size)continue; ans=min(ans,G[i]+G[it-U]); } cout<<ans<<endl; } void init(){ G.clear(); g.clear(); G.push_back(0); for(int i=0;i<100000;i++) T[i]=U[i]=0; } int main(){ while(cin>>R,R){ init(); cin>>tw>>th>>tx>>ty; ty--,tx--; for(int i=0;i<th;i++){ for(int j=0;j<tw;j++){ cin>>t[i][j]; G.push_back(t[i][j]); } } cin>>uw>>uh>>ux>>uy; uy--,ux--; for(int i=0;i<uh;i++){ for(int j=0;j<uw;j++){ cin>>u[i][j]; G.push_back(u[i][j]); } } solve(); } return 0; }
a.cc: In function 'void solve()': a.cc:48:3: error: 'sort' was not declared in this scope; did you mean 'short'? 48 | sort(G.begin(),G.end()); | ^~~~ | short a.cc:49:11: error: 'unique' was not declared in this scope 49 | G.erase(unique(G.begin(),G.end()),G.end()); | ^~~~~~
s242719361
p00465
C++
#include<bits/stdc++.h> #include<algorithm> #include<vector> #include<queue> using namespace std; typedef long long ll; typedef pair<int,int> P; int r,w[2],h[2],x[2],y[2],l[2][500][500],temp[500][500]; vector<P> d[2]; int dx[4]={1,0,-1,0}; int dy[4]={0,1,0,-1}; void search(int n){ for(int i=0;i<500;i++) for(int j=0;j<500;j++) temp[i][j]=0; priority_queue<P, vector<P>, greater<P> > q; d[n].push_back(P(0,0)); q.push(P(l[n][y[n]][x[n]],x[n]*1000+y[n])); temp[y[n]][x[n]]=1; int res=0; while(!q.empty()){ P z=q.top(),qq; while(qq=q.top(),qq.first<=z.first&&!q.empty()){ q.pop(); int X=qq.second/1000,Y=qq.second%1000; res++; for(int k=0;k<4;k++){ int i=X+dx[k],j=Y+dy[k]; if(i<0||j<0||i>=w[n]||j>=h[n]) continue; if(temp[j][i]) continue; q.push(P(l[n][j][i],i*1000+j)); temp[j][i]=1; } } d[n].push_back(P(res,l[n][z.second%1000][z.second/1000])); } } P l_b(int m){ int lb=-1,rb=d[1].size(); while(lb+1<rb){ int mid=(lb+rb)/2; if(d[1][mid].first>=m) rb=mid; else lb=mid; } return d[1][rb]; } int main(){ while(scanf("%d",&r),r!=0){ for(int i=0;i<2;i++){ scanf("%d%d%d%d",&w[i],&h[i],&x[i],&y[i]); x[i]--; y[i]--; for(int j=0;j<h[i];j++) for(int k=0;k<w[i];k++) scanf("%d",&l[i][j][k]); search(i); } int res=INT_MAX; for(int i=0;i<d[0].size();i++){ P p=l_b(r-d[0][i].first); if(p.first+d[0][i].first>=r) res=min(res,p.second+d[0][i].second); } printf("%d\n",res); for(int n=0;n<2;n++) for(int i=0;i<d[n].size();i++) d[n].pop(); } }
a.cc: In function 'int main()': a.cc:57:74: error: 'class std::vector<std::pair<int, int> >' has no member named 'pop' 57 | for(int n=0;n<2;n++) for(int i=0;i<d[n].size();i++) d[n].pop(); | ^~~
s860838722
p00465
C++
#include <iostream> #include <queue> #include <set> #include <utility> #include <algorithm> #include <cstdlib> #include <vector> using namespace std; #define INF 10000000 int ary1[510][510],ary2[510][510]; bool used[510][510]; int main(){ int R,W1,W2,H1,H2,X1,X2,Y1,Y2,imax,imay,imad,res; priority_queue<pair<int,pair<int,int> > ,vector<pair<int,pair<int,int> > >,greater<pair<int,pair<int,int> > > > que; set<int> se1,se2; vector<int> v1,v2; pair<int,pair<int,int> > pa; while(1){ v1.clear(); v2.clear(); cin>>R; if(R==0) break; cin>>W1>>H1>>Y1>>X1; X1--;Y1--; for(int i=0;i<H1;i++){ for(int j=0;j<W1;j++){ cin>>ary1[i][j]; } } cin>>W2>>H2>>Y2>>X2; X2--;Y2--; for(int i=0;i<H2;i++){ for(int j=0;j<W2;j++){ cin>>ary2[i][j]; } } memset(used,0,sizeof(used)); que.push(make_pair(1,make_pair(X1,Y1))); used[X1][Y1]=true; while(!que.empty()){ pa=que.top();que.pop(); imax=pa.second.first; imay=pa.second.second; imad=pa.first; ary1[imax][imay]=imad; if(imax>0&&(!used[imax-1][imay])){ used[imax-1][imay]=true; que.push(make_pair(max(ary1[imax-1][imay],imad),make_pair(imax-1,imay))); } if(imax<H1-1&&(!used[imax+1][imay])){ used[imax+1][imay]=true; que.push(make_pair(max(ary1[imax+1][imay],imad),make_pair(imax+1,imay))); } if(imay>0&&(!used[imax][imay-1])){ used[imax][imay-1]=true; que.push(make_pair(max(ary1[imax][imay-1],imad),make_pair(imax,imay-1))); } if(imay<W1-1&&(!used[imax][imay+1])){ used[imax][imay+1]=true; que.push(make_pair(max(ary1[imax][imay+1],imad),make_pair(imax,imay+1))); } } memset(used,0,sizeof(used)); que.push(make_pair(1,make_pair(X2,Y2))); used[X2][Y2]=true; while(!que.empty()){ pa=que.top();que.pop(); imax=pa.second.first; imay=pa.second.second; imad=pa.first; ary2[imax][imay]=imad; if(imax>0&&(!used[imax-1][imay])){ used[imax-1][imay]=true; que.push(make_pair(max(ary2[imax-1][imay],imad),make_pair(imax-1,imay))); } if(imax<H2-1&&(!used[imax+1][imay])){ used[imax+1][imay]=true; que.push(make_pair(max(ary2[imax+1][imay],imad),make_pair(imax+1,imay))); } if(imay>0&&(!used[imax][imay-1])){ used[imax][imay-1]=true; que.push(make_pair(max(ary2[imax][imay-1],imad),make_pair(imax,imay-1))); } if(imay<W2-1&&(!used[imax][imay+1])){ used[imax][imay+1]=true; que.push(make_pair(max(ary2[imax][imay+1],imad),make_pair(imax,imay+1))); } } v1.push_back(0); for(int i=0;i<H1;i++){ for(int j=0;j<W1;j++){ v1.push_back(ary1[i][j]); } } sort(v1.begin(),v1.end()); v2.push_back(0); for(int i=0;i<H2;i++){ for(int j=0;j<W2;j++){ v2.push_back(ary2[i][j]); } } sort(v2.begin(),v2.end()); res=INF; for(int i=0;i<=R;i++){ if(W1*H1>=i&&W2*H2>=R-i)res=min(res,v1.at(i)+v2.at(R-i)); } cout<<res<<endl; // /*for(int i=0;i<H1;i++){ for(int j=0;j<W1;j++){ cout<<ary1[i][j]<<" "; } cout<<endl; } for(int i=0;i<H2;i++){ for(int j=0;j<W2;j++){ cout<<ary2[i][j]<<" "; } cout<<endl; }*/ // } return 0; }
a.cc: In function 'int main()': a.cc:39:17: error: 'memset' was not declared in this scope 39 | memset(used,0,sizeof(used)); | ^~~~~~ a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 6 | #include <cstdlib> +++ |+#include <cstring> 7 | #include <vector>
s437985332
p00465
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb(a) push_back(a) #define mp(x,y) make_pair(x,y) #define mp(x,y,z) make_tuple(x,y,z) #define ALL(a) a.begin(),a.end() #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,-1,sizeof(a)) #define len(a) sizeof(a) #define ll long long #define pint pair<int,int> #define tint tuple<int,int,int> #define INF 1<<29 #define MAX 501 using namespace std; int R,W[2],H[2],X[2],Y[2],L[2][MAX][MAX],d[2][MAX][MAX],dd[4]={0,-1,0,1}; map<int,int> m[2]; void solve(){ for(;;){ cin>>R; if(!R) return; FOR(i,2){ cin>>W[i]>>H[i]>>X[i]>>Y[i]; X[i]--; Y[i]--; FOR(j,H[i]) FOR(k,W[i]) cin>>L[i][j][k]; FOR(j,H[i]) FOR(k,W[i]) d[i][j][k]=INT_MAX/3; d[i][X[i]][Y[i]]=1; priority_queue<pint,vextor<pint>,greater<pint>> pque; que.push(mp(1,X[i]*W[i]+Y[i])); while(!que.empty()){ pint p=pque.top(); pque.pop(); int x=p.second/W[i],y=p.second-x*W[i]; if(d[i][x][y]<p.first) continue; FOR(j,4){ int nx=x+dd[j],ny=y+dd[j^1]; if(nx<0||ny<0||nx>=H[i]||ny>=W[i]) continue; if(d[i][nx][ny]>max(d[i][x][y],L[i][x][y])){ d[i][nx][ny]=max(d[i][x][y],L[i][x][y]); pque.push(mp(d[i][nx][ny],nx*W[i]+ny)); } } } FOR(j,H[i]) FOR(k,W[i]) m[i][d[i][j][k]]++; for(map<int,int>::itelator ite=m[i].begin()+1;ite!=m[i].end();ite++){ m[i][ite->first]+=m[i][(ite-1)->first]; } } int mi=m[1].lower_bound(R)->first; for(map<int,int>::itelator ite=m[0].begin();ite!=m[0].end();ite++){ mi=min(mi,(ite->first)+(m[1].lower_bound(R-(ite->second))->first)); } cout<<mi<<endl; FOR(i,2) map[i].clear(); } } int main(){ solve(); return 0; }
a.cc:6:9: warning: "mp" redefined 6 | #define mp(x,y,z) make_tuple(x,y,z) | ^~ a.cc:5:9: note: this is the location of the previous definition 5 | #define mp(x,y) make_pair(x,y) | ^~ a.cc:33:32: error: macro "mp" requires 3 arguments, but only 2 given 33 | que.push(mp(1,X[i]*W[i]+Y[i])); | ^ a.cc:6:9: note: macro "mp" defined here 6 | #define mp(x,y,z) make_tuple(x,y,z) | ^~ a.cc:43:43: error: macro "mp" requires 3 arguments, but only 2 given 43 | pque.push(mp(d[i][nx][ny],nx*W[i]+ny)); | ^ a.cc:6:9: note: macro "mp" defined here 6 | #define mp(x,y,z) make_tuple(x,y,z) | ^~ a.cc: In function 'void solve()': a.cc:32:24: error: 'vextor' was not declared in this scope 32 | priority_queue<pint,vextor<pint>,greater<pint>> pque; | ^~~~~~ a.cc:32:35: error: template argument 2 is invalid 32 | priority_queue<pint,vextor<pint>,greater<pint>> pque; | ^ a.cc:32:35: error: template argument 3 is invalid a.cc:32:36: error: expected unqualified-id before ',' token 32 | priority_queue<pint,vextor<pint>,greater<pint>> pque; | ^ a.cc:32:49: error: invalid declarator before '>' token 32 | priority_queue<pint,vextor<pint>,greater<pint>> pque; | ^~ a.cc:33:4: error: 'que' was not declared in this scope 33 | que.push(mp(1,X[i]*W[i]+Y[i])); | ^~~ a.cc:33:13: error: 'mp' was not declared in this scope 33 | que.push(mp(1,X[i]*W[i]+Y[i])); | ^~ a.cc:35:12: error: 'pque' was not declared in this scope 35 | pint p=pque.top(); pque.pop(); | ^~~~ a.cc:48:22: error: 'itelator' is not a member of 'std::map<int, int>' 48 | for(map<int,int>::itelator ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^~~~~~~~ a.cc:48:50: error: 'ite' was not declared in this scope 48 | for(map<int,int>::itelator ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^~~ a.cc:53:21: error: 'itelator' is not a member of 'std::map<int, int>' 53 | for(map<int,int>::itelator ite=m[0].begin();ite!=m[0].end();ite++){ | ^~~~~~~~ a.cc:53:47: error: 'ite' was not declared in this scope; did you mean 'write'? 53 | for(map<int,int>::itelator ite=m[0].begin();ite!=m[0].end();ite++){ | ^~~ | write a.cc:57:16: error: redeclaration of 'auto i' 57 | FOR(i,2) map[i].clear(); | ^ a.cc:57:7: note: 'int i' previously declared here 57 | FOR(i,2) map[i].clear(); | ^ a.cc:2:26: note: in definition of macro 'FOR' 2 | #define FOR(i,n) for(int i=0;i<(int)(n);i++) | ^ a.cc:57:18: error: expected initializer before '.' token 57 | FOR(i,2) map[i].clear(); | ^ a.cc:57:18: error: expected ';' before '.' token
s310012854
p00465
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb(a) push_back(a) #define mp(x,y) make_pair(x,y) #define ALL(a) a.begin(),a.end() #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,-1,sizeof(a)) #define len(a) sizeof(a) #define ll long long #define pint pair<int,int> #define tint tuple<int,int,int> #define INF 1<<29 #define MAX 501 using namespace std; int R,W[2],H[2],X[2],Y[2],L[2][MAX][MAX],d[2][MAX][MAX],dd[4]={0,-1,0,1}; map<int,int> m[2]; map<int,int>::itelator ite; void solve(){ for(;;){ cin>>R; if(!R) return; FOR(i,2){ cin>>W[i]>>H[i]>>X[i]>>Y[i]; X[i]--; Y[i]--; FOR(j,H[i]) FOR(k,W[i]) cin>>L[i][j][k]; FOR(j,H[i]) FOR(k,W[i]) d[i][j][k]=INT_MAX/3; d[i][X[i]][Y[i]]=1; priority_queue<pint,vector<pint>,greater<pint>> pque; que.push(mp(1,X[i]*W[i]+Y[i])); while(!que.empty()){ pint p=pque.top(); pque.pop(); int x=p.second/W[i],y=p.second-x*W[i]; if(d[i][x][y]<p.first) continue; FOR(j,4){ int nx=x+dd[j],ny=y+dd[j^1]; if(nx<0||ny<0||nx>=H[i]||ny>=W[i]) continue; if(d[i][nx][ny]>max(d[i][x][y],L[i][x][y])){ d[i][nx][ny]=max(d[i][x][y],L[i][x][y]); pque.push(mp(d[i][nx][ny],nx*W[i]+ny)); } } } FOR(j,H[i]) FOR(k,W[i]) m[i][d[i][j][k]]++; for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ m[i][ite->first]+=m[i][(ite-1)->first]; } } int mi=m[1].lower_bound(R)->first; for(ite=m[0].begin();ite!=m[0].end();ite++){ mi=min(mi,(ite->first)+(m[1].lower_bound(R-(ite->second))->first)); } cout<<mi<<endl; FOR(i,2) map[i].clear(); } } int main(){ solve(); return 0; }
a.cc:19:15: error: 'itelator' in 'class std::map<int, int>' does not name a type 19 | map<int,int>::itelator ite; | ^~~~~~~~ a.cc: In function 'void solve()': a.cc:33:4: error: 'que' was not declared in this scope; did you mean 'pque'? 33 | que.push(mp(1,X[i]*W[i]+Y[i])); | ^~~ | pque a.cc:48:8: error: 'ite' was not declared in this scope 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^~~ a.cc:48:24: error: no match for 'operator+' (operand types are 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} and 'int') 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ~~~~~~~~~~~~^~ | | | | | int | std::map<int, int>::iterator {aka std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator} In file included from /usr/include/c++/14/bits/stl_algobase.h:67, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)' 627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed: a.cc:48:25: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)' 1798 | operator+(typename move_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed: a.cc:48:25: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ In file included from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed: a.cc:48:25: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3616 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed: a.cc:48:25: note: mismatched types 'const _CharT*' and 'std::_Rb_tree_iterator<std::pair<const int, int> >' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed: a.cc:48:25: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed: a.cc:48:25: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)' 3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed: a.cc:48:25: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed: a.cc:48:25: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed: a.cc:48:25: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3696 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3696:5: note: template argument deduction/substitution failed: a.cc:48:25: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3719 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3719:5: note: template argument deduction/substitution failed: a.cc:48:25: note: mismatched types 'const _CharT*' and 'std::_Rb_tree_iterator<std::pair<const int, int> >' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/basic_string.h:3726:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, __cxx11::basic_
s837179527
p00465
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb(a) push_back(a) #define mp(x,y) make_pair(x,y) #define ALL(a) a.begin(),a.end() #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,-1,sizeof(a)) #define len(a) sizeof(a) #define ll long long #define pint pair<int,int> #define tint tuple<int,int,int> #define INF 1<<29 #define MAX 501 using namespace std; int R,W[2],H[2],X[2],Y[2],L[2][MAX][MAX],d[2][MAX][MAX],dd[4]={0,-1,0,1}; map<int,int> m[2]; map<int,int>::iterator ite; void solve(){ for(;;){ cin>>R; if(!R) return; priority_queue<pint,vector<pint>,greater<pint>> pque; FOR(i,2){ cin>>W[i]>>H[i]>>X[i]>>Y[i]; X[i]--; Y[i]--; FOR(j,H[i]) FOR(k,W[i]) cin>>L[i][j][k]; FOR(j,H[i]) FOR(k,W[i]) d[i][j][k]=INT_MAX/3; d[i][X[i]][Y[i]]=1; que.push(mp(1,X[i]*W[i]+Y[i])); while(!que.empty()){ pint p=pque.top(); pque.pop(); int x=p.second/W[i],y=p.second-x*W[i]; if(d[i][x][y]<p.first) continue; FOR(j,4){ int nx=x+dd[j],ny=y+dd[j^1]; if(nx<0||ny<0||nx>=H[i]||ny>=W[i]) continue; if(d[i][nx][ny]>max(d[i][x][y],L[i][x][y])){ d[i][nx][ny]=max(d[i][x][y],L[i][x][y]); pque.push(mp(d[i][nx][ny],nx*W[i]+ny)); } } } FOR(j,H[i]) FOR(k,W[i]) m[i][d[i][j][k]]++; for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ m[i][ite->first]+=m[i][(ite-1)->first]; } } int mi=m[1].lower_bound(R)->first; for(ite=m[0].begin();ite!=m[0].end();ite++){ mi=min(mi,(ite->first)+(m[1].lower_bound(R-(ite->second))->first)); } cout<<mi<<endl; FOR(i,2) map[i].clear(); } } int main(){ solve(); return 0; }
a.cc: In function 'void solve()': a.cc:33:4: error: 'que' was not declared in this scope; did you mean 'pque'? 33 | que.push(mp(1,X[i]*W[i]+Y[i])); | ^~~ | pque a.cc:48:24: error: no match for 'operator+' (operand types are 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} and 'int') 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ~~~~~~~~~~~~^~ | | | | | int | std::map<int, int>::iterator {aka std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator} In file included from /usr/include/c++/14/bits/stl_algobase.h:67, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:627:5: note: candidate: 'template<class _Iterator> constexpr std::reverse_iterator<_Iterator> std::operator+(typename reverse_iterator<_Iterator>::difference_type, const reverse_iterator<_Iterator>&)' 627 | operator+(typename reverse_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:627:5: note: template argument deduction/substitution failed: a.cc:48:25: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: candidate: 'template<class _Iterator> constexpr std::move_iterator<_IteratorL> std::operator+(typename move_iterator<_IteratorL>::difference_type, const move_iterator<_IteratorL>&)' 1798 | operator+(typename move_iterator<_Iterator>::difference_type __n, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1798:5: note: template argument deduction/substitution failed: a.cc:48:25: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ In file included from /usr/include/c++/14/string:54, from /usr/include/c++/14/bitset:52, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52: /usr/include/c++/14/bits/basic_string.h:3598:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3598 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3598:5: note: template argument deduction/substitution failed: a.cc:48:25: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/basic_string.h:3616:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3616 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3616:5: note: template argument deduction/substitution failed: a.cc:48:25: note: mismatched types 'const _CharT*' and 'std::_Rb_tree_iterator<std::pair<const int, int> >' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/basic_string.h:3635:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3635 | operator+(_CharT __lhs, const basic_string<_CharT,_Traits,_Alloc>& __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3635:5: note: template argument deduction/substitution failed: a.cc:48:25: note: mismatched types 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' and 'int' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/basic_string.h:3652:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, const _CharT*)' 3652 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3652:5: note: template argument deduction/substitution failed: a.cc:48:25: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/basic_string.h:3670:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, _CharT)' 3670 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, _CharT __rhs) | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3670:5: note: template argument deduction/substitution failed: a.cc:48:25: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/basic_string.h:3682:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, const __cxx11::basic_string<_CharT, _Traits, _Allocator>&)' 3682 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3682:5: note: template argument deduction/substitution failed: a.cc:48:25: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/basic_string.h:3689:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const __cxx11::basic_string<_CharT, _Traits, _Allocator>&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3689 | operator+(const basic_string<_CharT, _Traits, _Alloc>& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3689:5: note: template argument deduction/substitution failed: a.cc:48:25: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/basic_string.h:3696:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(__cxx11::basic_string<_CharT, _Traits, _Allocator>&&, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3696 | operator+(basic_string<_CharT, _Traits, _Alloc>&& __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3696:5: note: template argument deduction/substitution failed: a.cc:48:25: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'std::__cxx11::basic_string<_CharT, _Traits, _Allocator>' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/basic_string.h:3719:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3719 | operator+(const _CharT* __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3719:5: note: template argument deduction/substitution failed: a.cc:48:25: note: mismatched types 'const _CharT*' and 'std::_Rb_tree_iterator<std::pair<const int, int> >' 48 | for(ite=m[i].begin()+1;ite!=m[i].end();ite++){ | ^ /usr/include/c++/14/bits/basic_string.h:3726:5: note: candidate: 'template<class _CharT, class _Traits, class _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Allocator> std::operator+(_CharT, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&)' 3726 | operator+(_CharT __lhs, | ^~~~~~~~ /usr/include/c++/14/bits/basic_string.h:3726:5: note: template argument deduction/substitution failed: a.cc:48:25: note: mismatched types 'std::__cxx11::basic_string<_CharT, _Trai
s975269043
p00465
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb(a) push_back(a) #define mp(x,y) make_pair(x,y) #define ALL(a) a.begin(),a.end() #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,-1,sizeof(a)) #define len(a) sizeof(a) #define ll long long #define pint pair<int,int> #define tint tuple<int,int,int> #define INF 1<<29 #define MAX 501 using namespace std; int R,W[2],H[2],X[2],Y[2],L[2][MAX][MAX],d[2][MAX][MAX],dd[4]={0,-1,0,1}; map<int,int> m[2]; map<int,int>::iterator ite; void solve(){ for(;;){ cin>>R; if(!R) return; FOR(i,2){ cin>>W[i]>>H[i]>>X[i]>>Y[i]; X[i]--; Y[i]--; FOR(j,H[i]) FOR(k,W[i]) cin>>L[i][j][k]; FOR(j,H[i]) FOR(k,W[i]) d[i][j][k]=INT_MAX/3; d[i][X[i]][Y[i]]=1; priority_queue<pint,vector<pint>,greater<pint>> pque; pque.push(mp(1,X[i]*W[i]+Y[i])); while(!pque.empty()){ pint p=pque.top(); pque.pop(); int x=p.second/W[i],y=p.second-x*W[i]; if(d[i][x][y]<p.first) continue; FOR(j,4){ int nx=x+dd[j],ny=y+dd[j^1]; if(nx<0||ny<0||nx>=H[i]||ny>=W[i]) continue; if(d[i][nx][ny]>max(d[i][x][y],L[i][x][y])){ d[i][nx][ny]=max(d[i][x][y],L[i][x][y]); pque.push(mp(d[i][nx][ny],nx*W[i]+ny)); } } } FOR(j,H[i]) FOR(k,W[i]) m[i][d[i][j][k]]++; for(ite=m[i].begin();ite!=m[i].end();ite++){ if(ite==m[i].begin()) continue; m[i][ite->first]+=m[i][(ite-1)->first]; } } int mi=m[1].lower_bound(R)->first; for(ite=m[0].begin();ite!=m[0].end();ite++){ mi=min(mi,(ite->first)+(m[1].lower_bound(R-(ite->second))->first)); } cout<<mi<<endl; FOR(i,2) map[i].clear(); } } int main(){ solve(); return 0; }
a.cc: In function 'void solve()': a.cc:50:32: error: no match for 'operator-' (operand types are 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} and 'int') 50 | m[i][ite->first]+=m[i][(ite-1)->first]; | ~~~^~ | | | | | int | std::map<int, int>::iterator {aka std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator} In file included from /usr/include/c++/14/bits/stl_algobase.h:67, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 618 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed: a.cc:50:33: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::reverse_iterator<_Iterator>' 50 | m[i][ite->first]+=m[i][(ite-1)->first]; | ^ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1790 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: template argument deduction/substitution failed: a.cc:50:33: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::move_iterator<_IteratorL>' 50 | m[i][ite->first]+=m[i][(ite-1)->first]; | ^ In file included from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/complex:370:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const complex<_Tp>&)' 370 | operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:370:5: note: template argument deduction/substitution failed: a.cc:50:33: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::complex<_Tp>' 50 | m[i][ite->first]+=m[i][(ite-1)->first]; | ^ /usr/include/c++/14/complex:379:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const _Tp&)' 379 | operator-(const complex<_Tp>& __x, const _Tp& __y) | ^~~~~~~~ /usr/include/c++/14/complex:379:5: note: template argument deduction/substitution failed: a.cc:50:33: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::complex<_Tp>' 50 | m[i][ite->first]+=m[i][(ite-1)->first]; | ^ /usr/include/c++/14/complex:388:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const _Tp&, const complex<_Tp>&)' 388 | operator-(const _Tp& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:388:5: note: template argument deduction/substitution failed: a.cc:50:33: note: mismatched types 'const std::complex<_Tp>' and 'int' 50 | m[i][ite->first]+=m[i][(ite-1)->first]; | ^ /usr/include/c++/14/complex:465:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&)' 465 | operator-(const complex<_Tp>& __x) | ^~~~~~~~ /usr/include/c++/14/complex:465:5: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/valarray:605, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166: /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:50:33: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 50 | m[i][ite->first]+=m[i][(ite-1)->first]; | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:50:33: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 50 | m[i][ite->first]+=m[i][(ite-1)->first]; | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:50:33: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 50 | m[i][ite->first]+=m[i][(ite-1)->first]; | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:50:33: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 50 | m[i][ite->first]+=m[i][(ite-1)->first]; | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:50:33: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 50 | m[i][ite->first]+=m[i][(ite-1)->first]; | ^ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const valarray<_Tp>&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:50:33: note: 'std::map<int, int>::iterator' {aka 'std::_Rb_tree<int, std::pair<const int, int>, std::_Select1st<std::pair<const int, int> >, std::less<int>, std::allocator<std::pair<const int, int> > >::iterator'} is not derived from 'const std::valarray<_Tp>' 50 | m[i][ite->first]+=m[i][(ite-1)->f
s128814618
p00465
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb(a) push_back(a) #define mp(x,y) make_pair(x,y) #define ALL(a) a.begin(),a.end() #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,-1,sizeof(a)) #define len(a) sizeof(a) #define ll long long #define pint pair<int,int> #define tint tuple<int,int,int> #define INF 1<<29 #define MAX 501 using namespace std; int R,W[2],H[2],X[2],Y[2],L[2][MAX][MAX],d[2][MAX][MAX],dd[4]={0,-1,0,1}; map<int,int> m[2]; map<int,int>::iterator ite; void solve(){ for(;;){ cin>>R; if(!R) return; FOR(i,2){ cin>>W[i]>>H[i]>>X[i]>>Y[i]; X[i]--; Y[i]--; FOR(j,H[i]) FOR(k,W[i]) cin>>L[i][j][k]; FOR(j,H[i]) FOR(k,W[i]) d[i][j][k]=INT_MAX/3; d[i][X[i]][Y[i]]=1; priority_queue<pint,vector<pint>,greater<pint>> pque; pque.push(mp(1,X[i]*W[i]+Y[i])); while(!pque.empty()){ pint p=pque.top(); pque.pop(); int x=p.second/W[i],y=p.second-x*W[i]; if(d[i][x][y]<p.first) continue; FOR(j,4){ int nx=x+dd[j],ny=y+dd[j^1]; if(nx<0||ny<0||nx>=H[i]||ny>=W[i]) continue; if(d[i][nx][ny]>max(d[i][x][y],L[i][x][y])){ d[i][nx][ny]=max(d[i][x][y],L[i][x][y]); pque.push(mp(d[i][nx][ny],nx*W[i]+ny)); } } } FOR(j,H[i]) FOR(k,W[i]) m[i][d[i][j][k]]++; for(ite=m[i].begin();ite!=m[i].end();ite++){ if(ite==m[i].begin()) continue; m[i][ite->first]+=m[i][(--ite)->first]; ite++; } } int mi=m[1].lower_bound(R)->first; for(ite=m[0].begin();ite!=m[0].end();ite++){ mi=min(mi,(ite->first)+(m[1].lower_bound(R-(ite->second))->first)); } cout<<mi<<endl; FOR(i,2) map[i].clear(); } } int main(){ solve(); return 0; }
a.cc: In function 'void solve()': a.cc:59:16: error: redeclaration of 'auto i' 59 | FOR(i,2) map[i].clear(); | ^ a.cc:59:7: note: 'int i' previously declared here 59 | FOR(i,2) map[i].clear(); | ^ a.cc:2:26: note: in definition of macro 'FOR' 2 | #define FOR(i,n) for(int i=0;i<(int)(n);i++) | ^ a.cc:59:18: error: expected initializer before '.' token 59 | FOR(i,2) map[i].clear(); | ^ a.cc:59:18: error: expected ';' before '.' token
s570150555
p00465
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb(a) push_back(a) #define mp(x,y) make_pair(x,y) #define ALL(a) a.begin(),a.end() #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,-1,sizeof(a)) #define len(a) sizeof(a) #define ll long long #define pint pair<int,int> #define tint tuple<int,int,int> #define INF 1<<29 #define MAX 501 using namespace std; int R,W[2],H[2],X[2],Y[2],L[2][MAX][MAX],d[2][MAX][MAX],dd[4]={0,-1,0,1}; map<int,int> m[2]; map<int,int>::iterator ite; vector<int> lev,sum; void solve(){ for(;;){ cin>>R; if(!R) return; FOR(i,2){ cin>>W[i]>>H[i]>>X[i]>>Y[i]; X[i]--; Y[i]--; FOR(j,H[i]) FOR(k,W[i]) cin>>L[i][j][k]; FOR(j,H[i]) FOR(k,W[i]) d[i][j][k]=INT_MAX/3; d[i][X[i]][Y[i]]=1; priority_queue<pint,vector<pint>,greater<pint>> pque; pque.push(mp(1,X[i]*W[i]+Y[i])); while(!pque.empty()){ pint p=pque.top(); pque.pop(); int x=p.second/W[i],y=p.second%W[i]; if(d[i][x][y]<p.first) continue; FOR(j,4){ int nx=x+dd[j],ny=y+dd[j^1]; if(nx<0||ny<0||nx>=H[i]||ny>=W[i]) continue; if(d[i][nx][ny]>max(d[i][x][y],L[i][nx][ny])){ d[i][nx][ny]=max(d[i][x][y],L[i][nx][ny]); pque.push(mp(d[i][nx][ny],nx*W[i]+ny)); } } } FOR(j,H[i]) FOR(k,W[i]) m[i][d[i][j][k]]++; int tot=0; lev[i].pb(0); sum[i].pb(0); for(ite=m[0].begin();ite!=m[0].end();ite++){ lev[i].pb(ite->first); tot+=ite->second; sum[i].pb(tot); } } int mi=1<<30; FOR(i,lev[0].size()){ int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); mi=min(mi,lev[ind]+lev[i]); } cout<<mi<<endl; FOR(i,2){ m[i].clear(); lev[i].clear(); sum[i].clear(); } } } int main(){ solve(); return 0; }
a.cc: In function 'void solve()': a.cc:4:15: error: request for member 'push_back' in 'lev.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 4 | #define pb(a) push_back(a) | ^~~~~~~~~ a.cc:50:11: note: in expansion of macro 'pb' 50 | lev[i].pb(0); | ^~ a.cc:4:15: error: request for member 'push_back' in 'sum.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 4 | #define pb(a) push_back(a) | ^~~~~~~~~ a.cc:51:11: note: in expansion of macro 'pb' 51 | sum[i].pb(0); | ^~ a.cc:4:15: error: request for member 'push_back' in 'lev.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 4 | #define pb(a) push_back(a) | ^~~~~~~~~ a.cc:53:12: note: in expansion of macro 'pb' 53 | lev[i].pb(ite->first); | ^~ a.cc:4:15: error: request for member 'push_back' in 'sum.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 4 | #define pb(a) push_back(a) | ^~~~~~~~~ a.cc:55:12: note: in expansion of macro 'pb' 55 | sum[i].pb(tot); | ^~ a.cc:59:16: error: request for member 'size' in 'lev.std::vector<int>::operator[](0)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 59 | FOR(i,lev[0].size()){ | ^~~~ a.cc:2:38: note: in definition of macro 'FOR' 2 | #define FOR(i,n) for(int i=0;i<(int)(n);i++) | ^ a.cc:6:18: error: request for member 'begin' in 'sum.std::vector<int>::operator[](1)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 6 | #define ALL(a) a.begin(),a.end() | ^~~~~ a.cc:60:24: note: in expansion of macro 'ALL' 60 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ^~~ a.cc:6:28: error: request for member 'end' in 'sum.std::vector<int>::operator[](1)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 6 | #define ALL(a) a.begin(),a.end() | ^~~ a.cc:60:24: note: in expansion of macro 'ALL' 60 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ^~~ a.cc:60:53: error: request for member 'begin' in 'sum.std::vector<int>::operator[](1)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 60 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ^~~~~ a.cc:66:11: error: request for member 'clear' in 'lev.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 66 | lev[i].clear(); | ^~~~~ a.cc:67:11: error: request for member 'clear' in 'sum.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 67 | sum[i].clear(); | ^~~~~
s212761640
p00465
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb push_back #define mp make_pair #define ALL(a) a.begin(),a.end() #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,-1,sizeof(a)) #define len(a) sizeof(a) #define ll long long #define pint pair<int,int> #define INF 1<<29 #define MAX 501 using namespace std; int R,W[2],H[2],X[2],Y[2],L[2][MAX][MAX],d[2][MAX][MAX],dd[4]={0,-1,0,1}; map<int,int> m[2]; map<int,int>::iterator ite; vector<int> lev,sum; void solve(){ for(;;){ cin>>R; if(!R) return; FOR(i,2){ cin>>W[i]>>H[i]>>X[i]>>Y[i]; X[i]--; Y[i]--; FOR(j,H[i]) FOR(k,W[i]) cin>>L[i][j][k]; FOR(j,H[i]) FOR(k,W[i]) d[i][j][k]=INT_MAX/3; d[i][X[i]][Y[i]]=1; priority_queue<pint,vector<pint>,greater<pint>> pque; pque.push(mp(1,X[i]*W[i]+Y[i])); while(!pque.empty()){ pint p=pque.top(); pque.pop(); int x=p.second/W[i],y=p.second%W[i]; if(d[i][x][y]<p.first) continue; FOR(j,4){ int nx=x+dd[j],ny=y+dd[j^1]; if(nx<0||ny<0||nx>=H[i]||ny>=W[i]) continue; if(d[i][nx][ny]>max(d[i][x][y],L[i][nx][ny])){ d[i][nx][ny]=max(d[i][x][y],L[i][nx][ny]); pque.push(mp(d[i][nx][ny],nx*W[i]+ny)); } } } FOR(j,H[i]) FOR(k,W[i]) m[i][d[i][j][k]]++; int tot=0; lev[i].pb(0); sum[i].pb(0); for(ite=m[0].begin();ite!=m[0].end();ite++){ lev[i].pb(ite->first); tot+=ite->second; sum[i].pb(tot); } } int mi=1<<30; FOR(i,lev[0].size()){ int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); mi=min(mi,lev[ind]+lev[i]); } cout<<mi<<endl; FOR(i,2){ m[i].clear(); lev[i].clear(); sum[i].clear(); } } } int main(){ solve(); return 0; }
a.cc: In function 'void solve()': a.cc:4:12: error: request for member 'push_back' in 'lev.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 4 | #define pb push_back | ^~~~~~~~~ a.cc:49:11: note: in expansion of macro 'pb' 49 | lev[i].pb(0); | ^~ a.cc:4:12: error: request for member 'push_back' in 'sum.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 4 | #define pb push_back | ^~~~~~~~~ a.cc:50:11: note: in expansion of macro 'pb' 50 | sum[i].pb(0); | ^~ a.cc:4:12: error: request for member 'push_back' in 'lev.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 4 | #define pb push_back | ^~~~~~~~~ a.cc:52:12: note: in expansion of macro 'pb' 52 | lev[i].pb(ite->first); | ^~ a.cc:4:12: error: request for member 'push_back' in 'sum.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 4 | #define pb push_back | ^~~~~~~~~ a.cc:54:12: note: in expansion of macro 'pb' 54 | sum[i].pb(tot); | ^~ a.cc:58:16: error: request for member 'size' in 'lev.std::vector<int>::operator[](0)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 58 | FOR(i,lev[0].size()){ | ^~~~ a.cc:2:38: note: in definition of macro 'FOR' 2 | #define FOR(i,n) for(int i=0;i<(int)(n);i++) | ^ a.cc:6:18: error: request for member 'begin' in 'sum.std::vector<int>::operator[](1)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 6 | #define ALL(a) a.begin(),a.end() | ^~~~~ a.cc:59:24: note: in expansion of macro 'ALL' 59 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ^~~ a.cc:6:28: error: request for member 'end' in 'sum.std::vector<int>::operator[](1)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 6 | #define ALL(a) a.begin(),a.end() | ^~~ a.cc:59:24: note: in expansion of macro 'ALL' 59 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ^~~ a.cc:59:53: error: request for member 'begin' in 'sum.std::vector<int>::operator[](1)', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 59 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ^~~~~ a.cc:65:11: error: request for member 'clear' in 'lev.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 65 | lev[i].clear(); | ^~~~~ a.cc:66:11: error: request for member 'clear' in 'sum.std::vector<int>::operator[](((std::vector<int>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} 66 | sum[i].clear(); | ^~~~~
s487947146
p00465
C++
#include <bits/stdc++.h> #define FOR(i,n) for(int i=0;i<(int)(n);i++) #define FORR(i,m,n) for(int i=(int)(m);i<(int)(n);i++) #define pb push_back #define mp make_pair #define ALL(a) a.begin(),a.end() #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,-1,sizeof(a)) #define len(a) sizeof(a) #define ll long long #define pint pair<int,int> #define INF 1<<29 #define MAX 501 using namespace std; int R,W[2],H[2],X[2],Y[2],L[2][MAX][MAX],d[2][MAX][MAX],dd[4]={0,-1,0,1}; map<int,int> m[2]; map<int,int>::iterator ite; vector<int> lev[2],sum[2]; void solve(){ for(;;){ cin>>R; if(!R) return; FOR(i,2){ cin>>W[i]>>H[i]>>X[i]>>Y[i]; X[i]--; Y[i]--; FOR(j,H[i]) FOR(k,W[i]) cin>>L[i][j][k]; FOR(j,H[i]) FOR(k,W[i]) d[i][j][k]=INT_MAX/3; d[i][X[i]][Y[i]]=1; priority_queue<pint,vector<pint>,greater<pint>> pque; pque.push(mp(1,X[i]*W[i]+Y[i])); while(!pque.empty()){ pint p=pque.top(); pque.pop(); int x=p.second/W[i],y=p.second%W[i]; if(d[i][x][y]<p.first) continue; FOR(j,4){ int nx=x+dd[j],ny=y+dd[j^1]; if(nx<0||ny<0||nx>=H[i]||ny>=W[i]) continue; if(d[i][nx][ny]>max(d[i][x][y],L[i][nx][ny])){ d[i][nx][ny]=max(d[i][x][y],L[i][nx][ny]); pque.push(mp(d[i][nx][ny],nx*W[i]+ny)); } } } FOR(j,H[i]) FOR(k,W[i]) m[i][d[i][j][k]]++; int tot=0; lev[i].pb(0); sum[i].pb(0); for(ite=m[0].begin();ite!=m[0].end();ite++){ lev[i].pb(ite->first); tot+=ite->second; sum[i].pb(tot); } } int mi=1<<30; FOR(i,lev[0].size()){ int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); mi=min(mi,lev[ind]+lev[i]); } cout<<mi<<endl; FOR(i,2){ m[i].clear(); lev[i].clear(); sum[i].clear(); } } } int main(){ solve(); return 0; }
a.cc: In function 'void solve()': a.cc:59:37: error: no match for 'operator-' (operand types are 'int' and 'std::vector<int>') 59 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ~^~~~~~~ | | | | int std::vector<int> In file included from /usr/include/c++/14/bits/stl_algobase.h:67, from /usr/include/c++/14/algorithm:60, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51, from a.cc:1: /usr/include/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)' 618 | operator-(const reverse_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:618:5: note: template argument deduction/substitution failed: a.cc:59:43: note: mismatched types 'const std::reverse_iterator<_Iterator>' and 'int' 59 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ^ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)' 1790 | operator-(const move_iterator<_IteratorL>& __x, | ^~~~~~~~ /usr/include/c++/14/bits/stl_iterator.h:1790:5: note: template argument deduction/substitution failed: a.cc:59:43: note: mismatched types 'const std::move_iterator<_IteratorL>' and 'int' 59 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ^ In file included from /usr/include/c++/14/ccomplex:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127: /usr/include/c++/14/complex:370:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const complex<_Tp>&)' 370 | operator-(const complex<_Tp>& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:370:5: note: template argument deduction/substitution failed: a.cc:59:43: note: mismatched types 'const std::complex<_Tp>' and 'int' 59 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ^ /usr/include/c++/14/complex:379:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&, const _Tp&)' 379 | operator-(const complex<_Tp>& __x, const _Tp& __y) | ^~~~~~~~ /usr/include/c++/14/complex:379:5: note: template argument deduction/substitution failed: a.cc:59:43: note: mismatched types 'const std::complex<_Tp>' and 'int' 59 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ^ /usr/include/c++/14/complex:388:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const _Tp&, const complex<_Tp>&)' 388 | operator-(const _Tp& __x, const complex<_Tp>& __y) | ^~~~~~~~ /usr/include/c++/14/complex:388:5: note: template argument deduction/substitution failed: a.cc:59:43: note: 'std::vector<int>' is not derived from 'const std::complex<_Tp>' 59 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ^ /usr/include/c++/14/complex:465:5: note: candidate: 'template<class _Tp> std::complex<_Tp> std::operator-(const complex<_Tp>&)' 465 | operator-(const complex<_Tp>& __x) | ^~~~~~~~ /usr/include/c++/14/complex:465:5: note: candidate expects 1 argument, 2 provided In file included from /usr/include/c++/14/valarray:605, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:166: /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom1, class _Dom2> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Expr, _Dom1, _Dom2>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const _Expr<_Dom2, typename _Dom2::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:59:43: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 59 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_Constant, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const typename _Dom::value_type&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:59:43: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 59 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const typename _Dom::value_type&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:59:43: note: 'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 59 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Expr, std::_ValArray, _Dom, typename _Dom::value_type>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const _Expr<_Dom1, typename _Dom1::value_type>&, const valarray<typename _Dom::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:59:43: note: mismatched types 'const std::_Expr<_Dom1, typename _Dom1::value_type>' and 'int' 59 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ^ /usr/include/c++/14/bits/valarray_after.h:406:5: note: candidate: 'template<class _Dom> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Expr, typename _Dom::value_type, _Dom>, typename std::__fun<std::__minus, typename _Dom1::value_type>::result_type> std::operator-(const valarray<typename _Dom::value_type>&, const _Expr<_Dom1, typename _Dom1::value_type>&)' 406 | _DEFINE_EXPR_BINARY_OPERATOR(-, struct std::__minus) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/bits/valarray_after.h:406:5: note: template argument deduction/substitution failed: a.cc:59:43: note: 'std::vector<int>' is not derived from 'const std::_Expr<_Dom1, typename _Dom1::value_type>' 59 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ^ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const valarray<_Tp>&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:59:43: note: mismatched types 'const std::valarray<_Tp>' and 'int' 59 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ^ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_ValArray, std::_Constant, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const valarray<_Tp>&, const typename valarray<_Tp>::value_type&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:59:43: note: mismatched types 'const std::valarray<_Tp>' and 'int' 59 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ^ /usr/include/c++/14/valarray:1197:1: note: candidate: 'template<class _Tp> std::_Expr<std::__detail::_BinClos<std::__minus, std::_Constant, std::_ValArray, _Tp, _Tp>, typename std::__fun<std::__minus, _Tp>::result_type> std::operator-(const typename valarray<_Tp>::value_type&, const valarray<_Tp>&)' 1197 | _DEFINE_BINARY_OPERATOR(-, __minus) | ^~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/14/valarray:1197:1: note: template argument deduction/substitution failed: a.cc:59:43: note: 'std::vector<int>' is not derived from 'const std::valarray<_Tp>' 59 | int ind=lower_bound(ALL(sum[1]),R-sum[0])-sum[1].begin(); | ^ a.cc:60:22: error: no match for 'operator+' (operand types are 'std::vector<int>' and 'std::vector<int>') 60 | mi=min(mi,lev[ind]+lev[i]); | ~~~~~~~~^~~~~~~
s471409075
p00465
C++
#include <iostream> #include <cstdio> #include <vector> #include <cmath> #include <cstring> #include <numeric> #include <algorithm> #include <functional> #include <array> #include <map> #include <queue> #include <limits.h> #include <set> #include <bitset> #include <stack> #include <cstdlib> #include <complex> #include <unordered_map> #define rep(i,s,n) for(int i = s; n > i; i++) #define REP(i,n) rep(i,0,n) #define MODU 33 #define Range(x,a,b) ((a) <= (x) && (x) <= (b)) #define POWT(x) ((x)*(x)) #define ALL(x) (x).begin(), (x).end() using namespace std; typedef vector<int> Ivec; typedef pair<int, int> pii; typedef long long int ll; const pii Dir[8] = { //????????? { 0,1 },{ 0,-1 },{ 1,0 },{ -1,0 }, { 1,1 },{ 1,-1 },{ -1,-1 },{ -1,1 } }; template<typename A, size_t N, typename T> void Fill(A(&array)[N], const T &val) { std::fill((T*)array, (T*)(array + N), val); } int main() { int r; scanf("%d", &r); int w, h, x, y; scanf("%d %d %d %d", &w, &h, &x, &y); x--; y--; vector<vector<int>> m(h, vector<int>(w)); REP(i, h) { REP(j, w) { scanf("%d", &m[i][j]); } } int w2, h2, x2, y2; scanf("%d %d %d %d", &w2, &h2, &x2, &y2); x2--; y2--; vector<vector<int>> m2(h2, vector<int>(w2)); REP(i, h2) { REP(j, w2) { scanf("%d", &m2[i][j]); } } priority_queue<pair<int, pii>, vector<pair<int, pii>>, greater<pair<int, pii>>> que; que.push({ 1,{x,y} }); map<int, int> mcount; vector<vector<int>> al(h, vector<int>(w)); while (que.size()) { int p = que.top().first; pii cur = que.top().second; que.pop(); if (al[cur.first][cur.second]) continue; al[cur.first][cur.second] = 1; mcount[p]++; REP(i, 4) { pii next = { cur.first + Dir[i].first, cur.second + Dir[i].second }; if (Range(next.first, 0, h - 1) && Range(next.second, 0, w - 1)) { if (!al[next.first][next.second]) { que.push({ max(p,m[next.first][next.second]),next }); //al[next.first][next.second] = 1; } } } } vector<pii> cou;//???????????°?????¬?????? for (auto cur : mcount) { cou.push_back({ cur.second,cur.first }); } rep(i, 1, cou.size()) { if (cou[i].first == cou[i - 1].first) { if (cou[i].second > cou[i - 1].second) cou.erase(cou.begin() + i); else cou.erase(cou.begin() + i - 1); i--; } } mcount.clear(); al.swap(vector<vector<int>>(h2,vector<int>(w2))); que.push({ 1,{x2,y2} }); while (que.size()) { int p = que.top().first; pii cur = que.top().second; que.pop(); if (al[cur.first][cur.second]) continue; al[cur.first][cur.second] = 1; mcount[p]++; REP(i, 4) { pii next = { cur.first + Dir[i].first, cur.second + Dir[i].second }; if (Range(next.first, 0, h2 - 1) && Range(next.second, 0, w2 - 1)) { if (!al[next.first][next.second]) { que.push({ max(p,m2[next.first][next.second]),next }); //al[next.first][next.second] = 1; } } } } vector<pii> cou2; for (auto cur : mcount) { cou2.push_back({ cur.second,cur.first }); } rep(i, 1, cou2.size()) { if (cou2[i].first == cou2[i - 1].first) { if (cou2[i].second > cou2[i - 1].second) cou2.erase(cou2.begin() + i); else cou2.erase(cou2.begin() + i - 1); i--; } } int Min = INT_MAX; REP(i, cou.size()) { auto itr = upper_bound(ALL(cou2) ,make_pair(cou[i].first,0)); if (itr != cou2.end()) { Min = min(Min,itr->second + cou[i].second); } } printf("%d\n", Min); return 0; }
a.cc: In function 'int main()': a.cc:99:17: error: cannot bind non-const lvalue reference of type 'std::vector<std::vector<int> >&' to an rvalue of type 'std::vector<std::vector<int> >' 99 | al.swap(vector<vector<int>>(h2,vector<int>(w2))); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/vector:66, from a.cc:3: /usr/include/c++/14/bits/stl_vector.h:1588:20: note: initializing argument 1 of 'void std::vector<_Tp, _Alloc>::swap(std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]' 1588 | swap(vector& __x) _GLIBCXX_NOEXCEPT | ~~~~~~~~^~~
s092681502
p00465
C++
#include <iostream> #include <cstdio> #include <vector> #include <cmath> #include <cstring> #include <numeric> #include <algorithm> #include <functional> #include <array> #include <map> #include <queue> #include <limits.h> #include <set> #include <stack> #include <random> #define rep(i,s,n) for(int i = (s); (n) > i; i++) #define REP(i,n) rep(i,0,n) #define RANGE(x,a,b) ((a) <= (x) && (x) <= (b)) #define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b)) #define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d)) #define POWT(x) ((x)*(x)) #define ALL(x) (x).begin(), (x).end() #define MODU 1000000007 #define bitcheck(a,b) ((a >> b) & 1) #define bitset(a,b) ( a |= (1 << b)) #define bitunset(a,b) (a &= ~(1 << b)) using namespace std; typedef pair<int, int> pii; typedef long long ll; const pii Dir[8] = { //????????? { 0,1 },{ 0,-1 },{ 1,0 },{ -1,0 }, { 1,1 },{ 1,-1 },{ -1,-1 },{ -1,1 } }; template<typename A, size_t N, typename T> void Fill(A(&array)[N], const T &val) { std::fill((T*) array, (T*) (array + N), val); } signed main() { int r; while (scanf("%d", &r)) { if (r == 0) break; int w, h, x, y; scanf("%d %d %d %d", &w, &h, &y, &x); x--; y--; vector<vector<int>> m(h, vector<int>(w)); REP(i, h) { REP(j, w) { scanf("%d", &m[i][j]); } } int w2, h2, x2, y2; scanf("%d %d %d %d", &w2, &h2, &y2, &x2); x2--; y2--; vector<vector<int>> m2(h2, vector<int>(w2)); REP(i, h2) { REP(j, w2) { scanf("%d", &m2[i][j]); } } priority_queue<pair<int, pii>, vector<pair<int, pii>>, greater<pair<int, pii>>> que; que.push({ 1,{ x,y } }); map<int, int> mcount; vector<vector<int>> al(h, vector<int>(w)); while (que.size()) { int p = que.top().first; pii cur = que.top().second; que.pop(); if (al[cur.first][cur.second]) continue; al[cur.first][cur.second] = 1; mcount[p]++; REP(i, 4) { pii next = { cur.first + Dir[i].first, cur.second + Dir[i].second }; if (RANGE(next.first, 0, h - 1) && RANGE(next.second, 0, w - 1)) { if (!al[next.first][next.second]) { que.push({ max(p,m[next.first][next.second]),next }); //al[next.first][next.second] = 1; } } } } vector<pii> cou;//????????????°??????¬?????? for (auto cur : mcount) { cou.push_back({ cur.second,cur.first }); } rep(i, 1, cou.size()) { cou[i].first += cou[i - 1].first; } rep(i, 1, cou.size()) { if (cou[i].first == cou[i - 1].first) { if (cou[i].second > cou[i - 1].second) cou.erase(cou.begin() + i); else cou.erase(cou.begin() + i - 1); i--; } } mcount.clear(); al.swap(vector<vector<int>>(h2, vector<int>(w2))); que.push({ 1,{ x2,y2 } }); while (que.size()) { int p = que.top().first; pii cur = que.top().second; que.pop(); if (al[cur.first][cur.second]) continue; al[cur.first][cur.second] = 1; mcount[p]++; REP(i, 4) { pii next = { cur.first + Dir[i].first, cur.second + Dir[i].second }; if (RANGE(next.first, 0, h2 - 1) && RANGE(next.second, 0, w2 - 1)) { if (!al[next.first][next.second]) { que.push({ max(p,m2[next.first][next.second]),next }); //al[next.first][next.second] = 1; } } } } vector<pii> cou2; for (auto cur : mcount) { cou2.push_back({ cur.second,cur.first }); } rep(i, 1, cou2.size()) { cou2[i].first += cou2[i - 1].first; } rep(i, 1, cou2.size()) { if (cou2[i].first == cou2[i - 1].first) { if (cou2[i].second > cou2[i - 1].second) cou2.erase(cou2.begin() + i); else cou2.erase(cou2.begin() + i - 1); i--; } } int Min = INT_MAX; cou.insert(cou.begin(), { 0,0 }); cou2.insert(cou2.begin(), { 0,0 }); REP(i, cou.size()) { auto itr = upper_bound(ALL(cou2), make_pair(r - cou[i].first, 0)); if (itr != cou2.end()) { Min = min(Min, itr->second + cou[i].second); } } printf("%d\n", Min); } return 0; }
a.cc: In function 'int main()': a.cc:108:25: error: cannot bind non-const lvalue reference of type 'std::vector<std::vector<int> >&' to an rvalue of type 'std::vector<std::vector<int> >' 108 | al.swap(vector<vector<int>>(h2, vector<int>(w2))); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/vector:66, from a.cc:3: /usr/include/c++/14/bits/stl_vector.h:1588:20: note: initializing argument 1 of 'void std::vector<_Tp, _Alloc>::swap(std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]' 1588 | swap(vector& __x) _GLIBCXX_NOEXCEPT | ~~~~~~~~^~~
s056088919
p00465
C++
#include <iostream> #include <cstdio> #include <vector> #include <cmath> #include <cstring> #include <numeric> #include <algorithm> #include <functional> #include <array> #include <map> #include <queue> #include <limits.h> #include <set> #include <stack> #include <random> #define rep(i,s,n) for(int i = (s); (n) > i; i++) #define REP(i,n) rep(i,0,n) #define RANGE(x,a,b) ((a) <= (x) && (x) <= (b)) #define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b)) #define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d)) #define POWT(x) ((x)*(x)) #define ALL(x) (x).begin(), (x).end() #define MODU 1000000007 #define bitcheck(a,b) ((a >> b) & 1) #define bitset(a,b) ( a |= (1 << b)) #define bitunset(a,b) (a &= ~(1 << b)) using namespace std; typedef pair<int, int> pii; typedef long long ll; const pii Dir[8] = { //????????? { 0,1 },{ 0,-1 },{ 1,0 },{ -1,0 }, { 1,1 },{ 1,-1 },{ -1,-1 },{ -1,1 } }; template<typename A, size_t N, typename T> void Fill(A(&array)[N], const T &val) { std::fill((T*) array, (T*) (array + N), val); } signed main() { int r; while (scanf("%d", &r)) { if (r == 0) break; int w, h, x, y; scanf("%d %d %d %d", &w, &h, &y, &x); x--; y--; vector<vector<int>> m(h, vector<int>(w)); REP(i, h) { REP(j, w) { scanf("%d", &m[i][j]); } } int w2, h2, x2, y2; scanf("%d %d %d %d", &w2, &h2, &y2, &x2); x2--; y2--; vector<vector<int>> m2(h2, vector<int>(w2)); REP(i, h2) { REP(j, w2) { scanf("%d", &m2[i][j]); } } priority_queue<pair<int, pii>, vector<pair<int, pii>>, greater<pair<int, pii>>> que; que.push({ 1,{ x,y } }); map<int, int> mcount; vector<vector<int>> al(h, vector<int>(w)); while (que.size()) { int p = que.top().first; pii cur = que.top().second; que.pop(); if (al[cur.first][cur.second]) continue; al[cur.first][cur.second] = 1; mcount[p]++; REP(i, 4) { pii next = { cur.first + Dir[i].first, cur.second + Dir[i].second }; if (RANGE(next.first, 0, h - 1) && RANGE(next.second, 0, w - 1)) { if (!al[next.first][next.second]) { que.push({ max(p,m[next.first][next.second]),next }); //al[next.first][next.second] = 1; } } } } vector<pii> cou;//????????????°??????¬?????? for (auto cur : mcount) { cou.push_back({ cur.second,cur.first }); } rep(i, 1, cou.size()) { cou[i].first += cou[i - 1].first; } rep(i, 1, cou.size()) { if (cou[i].first == cou[i - 1].first) { if (cou[i].second > cou[i - 1].second) cou.erase(cou.begin() + i); else cou.erase(cou.begin() + i - 1); i--; } } mcount.clear(); al.swap(vector<vector<int>>(h2, vector<int>(w2))); que.push({ 1,{ x2,y2 } }); while (que.size()) { int p = que.top().first; pii cur = que.top().second; que.pop(); if (al[cur.first][cur.second]) continue; al[cur.first][cur.second] = 1; mcount[p]++; REP(i, 4) { pii next = { cur.first + Dir[i].first, cur.second + Dir[i].second }; if (RANGE(next.first, 0, h2 - 1) && RANGE(next.second, 0, w2 - 1)) { if (!al[next.first][next.second]) { que.push({ max(p,m2[next.first][next.second]),next }); //al[next.first][next.second] = 1; } } } } vector<pii> cou2; for (auto cur : mcount) { cou2.push_back({ cur.second,cur.first }); } rep(i, 1, cou2.size()) { cou2[i].first += cou2[i - 1].first; } rep(i, 1, cou2.size()) { if (cou2[i].first == cou2[i - 1].first) { if (cou2[i].second > cou2[i - 1].second) cou2.erase(cou2.begin() + i); else cou2.erase(cou2.begin() + i - 1); i--; } } int Min = INT_MAX; cou.insert(cou.begin(), { 0,0 }); cou2.insert(cou2.begin(), { 0,0 }); REP(i, cou.size()) { auto itr = upper_bound(ALL(cou2), make_pair(r - cou[i].first, 0)); if (itr != cou2.end()) { Min = min(Min, itr->second + cou[i].second); } } printf("%d\n", Min); } return 0; }
a.cc: In function 'int main()': a.cc:108:25: error: cannot bind non-const lvalue reference of type 'std::vector<std::vector<int> >&' to an rvalue of type 'std::vector<std::vector<int> >' 108 | al.swap(vector<vector<int>>(h2, vector<int>(w2))); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /usr/include/c++/14/vector:66, from a.cc:3: /usr/include/c++/14/bits/stl_vector.h:1588:20: note: initializing argument 1 of 'void std::vector<_Tp, _Alloc>::swap(std::vector<_Tp, _Alloc>&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >]' 1588 | swap(vector& __x) _GLIBCXX_NOEXCEPT | ~~~~~~~~^~~
s595025130
p00465
C++
#include<iostream> #include<cstdio> #include<algorithm> #include<string> #include<vector> #include<queue> #include<set> #include<functional> #define int long long #define p pair<int,int> #define P pair<int,p> using namespace std; int x[4] = { -1,0,0,1 }, y[4] = { 0,-1,1,0 }; int f[500][500]; bool i[500][500]; set<p>l,r; signed main() { int a; while (cin >> a, a) { l.insert(p(0, 0)); r.insert(p(0, 0)); int b, c, d, e; cin >> c >> b >> e >> d; d--; e--; for (int g = 0; g < b; g++) { for (int h = 0; h < c; h++) { scanf("%lld", &f[g][h]); } } memset(i, true, sizeof(i)); int sum = 0, MAX = 0; priority_queue<P, vector<P>, greater<P>>Q; Q.push(P(1, p(d, e))); while (Q.size()) { P o = Q.top(); Q.pop(); MAX = o.first; if(i[o.second.first][o.second.second])sum++; i[o.second.first][o.second.second] = false; queue<p>q; q.push(p(o.second.first, o.second.second)); while (q.size()) { p t = q.front(); q.pop(); for (int i = 0; i < 4; i++) { int dx = t.first + x[i], dy = t.second + y[i]; if (dx >= 0 && dx < b&&dy >= 0 && dy < c&&::i[dx][dy]) { if (f[dx][dy] <= o.first) { sum++; q.push(p(dx,dy)); ::i[dx][dy] = false; } else { Q.push(P(f[dx][dy],p(dx,dy))); } } } } l.insert(p(sum, MAX)); } cin >> c >> b >> e >> d; d--; e--; for (int g = 0; g < b; g++) { for (int h = 0; h < c; h++) { scanf("%lld", &f[g][h]); } } memset(i, true, sizeof(i)); sum = 0; MAX = 0; priority_queue<P, vector<P>, greater<P>>U; U.push(P(1, p(d, e))); while (U.size()) { P o = U.top(); U.pop(); MAX = o.first; if (i[o.second.first][o.second.second])sum++; i[o.second.first][o.second.second] = false; queue<p>q; q.push(p(o.second.first, o.second.second)); while (q.size()) { p t = q.front(); q.pop(); for (int i = 0; i < 4; i++) { int dx = t.first + x[i], dy = t.second + y[i]; if (dx >= 0 && dx < b&&dy >= 0 && dy < c&&::i[dx][dy]) { if (f[dx][dy] <= o.first) { sum++; q.push(p(dx, dy)); ::i[dx][dy] = false; } else { U.push(P(f[dx][dy], p(dx, dy))); } } } } r.insert(p(sum, MAX)); } int MIN = LLONG_MAX/3; for (auto i = l.begin(); i != l.end(); i++) { auto j = r.lower_bound(p(a-(*i).first,0)); if (j != r.end()) { MIN = min(MIN, (*i).second + (*j).second); } } cout << MIN << endl; } }
a.cc: In function 'int main()': a.cc:29:17: error: 'memset' was not declared in this scope 29 | memset(i, true, sizeof(i)); | ^~~~~~ a.cc:9:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 8 | #include<functional> +++ |+#include <cstring> 9 | #define int long long a.cc:94:27: error: 'LLONG_MAX' was not declared in this scope 94 | int MIN = LLONG_MAX/3; | ^~~~~~~~~ a.cc:9:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 8 | #include<functional> +++ |+#include <climits> 9 | #define int long long
s706755893
p00465
C++
#include<iostream> #include<cstdio> #include<algorithm> #include<string> #include<vector> #include<queue> #include<set> #include<functional> #define int long long #define p pair<int,int> #define P pair<int,p> using namespace std; int x[4] = { -1,0,0,1 }, y[4] = { 0,-1,1,0 }; int f[500][500]; bool i[500][500]; set<p>l,r; signed main() { int a; while (cin >> a, a) { l.insert(p(0, 0)); r.insert(p(0, 0)); int b, c, d, e; cin >> c >> b >> e >> d; d--; e--; for (int g = 0; g < b; g++) { for (int h = 0; h < c; h++) { scanf("%lld", &f[g][h]); } } memset(i, true, sizeof(i)); int sum = 0, MAX = 0; priority_queue<P, vector<P>, greater<P>>Q; Q.push(P(1, p(d, e))); while (Q.size()) { P o = Q.top(); Q.pop(); MAX = o.first; if(i[o.second.first][o.second.second])sum++; i[o.second.first][o.second.second] = false; queue<p>q; q.push(p(o.second.first, o.second.second)); while (q.size()) { p t = q.front(); q.pop(); for (int i = 0; i < 4; i++) { int dx = t.first + x[i], dy = t.second + y[i]; if (dx >= 0 && dx < b&&dy >= 0 && dy < c&&::i[dx][dy]) { if (f[dx][dy] <= o.first) { sum++; q.push(p(dx,dy)); ::i[dx][dy] = false; } else { Q.push(P(f[dx][dy],p(dx,dy))); } } } } l.insert(p(sum, MAX)); } cin >> c >> b >> e >> d; d--; e--; for (int g = 0; g < b; g++) { for (int h = 0; h < c; h++) { scanf("%lld", &f[g][h]); } } memset(i, true, sizeof(i)); sum = 0; MAX = 0; priority_queue<P, vector<P>, greater<P>>U; U.push(P(1, p(d, e))); while (U.size()) { P o = U.top(); U.pop(); MAX = o.first; if (i[o.second.first][o.second.second])sum++; i[o.second.first][o.second.second] = false; queue<p>q; q.push(p(o.second.first, o.second.second)); while (q.size()) { p t = q.front(); q.pop(); for (int i = 0; i < 4; i++) { int dx = t.first + x[i], dy = t.second + y[i]; if (dx >= 0 && dx < b&&dy >= 0 && dy < c&&::i[dx][dy]) { if (f[dx][dy] <= o.first) { sum++; q.push(p(dx, dy)); ::i[dx][dy] = false; } else { U.push(P(f[dx][dy], p(dx, dy))); } } } } r.insert(p(sum, MAX)); } int MIN = LLONG_MAX/3; for (auto i = l.begin(); i != l.end(); i++) { auto j = r.lower_bound(p(a-(*i).first,0)); if (j != r.end()) { MIN = min(MIN, (*i).second + (*j).second); } } cout << 0 << endl; } }
a.cc: In function 'int main()': a.cc:29:17: error: 'memset' was not declared in this scope 29 | memset(i, true, sizeof(i)); | ^~~~~~ a.cc:9:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 8 | #include<functional> +++ |+#include <cstring> 9 | #define int long long a.cc:94:27: error: 'LLONG_MAX' was not declared in this scope 94 | int MIN = LLONG_MAX/3; | ^~~~~~~~~ a.cc:9:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 8 | #include<functional> +++ |+#include <climits> 9 | #define int long long
s135274973
p00465
C++
#include <queue> #include <cstdio> #pragma warning(disable : 4996) using namespace std; struct state { int sx, sy, cost; }; bool operator<(const state& s1, const state& s2) { return s1.cost < s2.cost; } int R, H[2], W[2], sx[2], sy[2], a[2][509][509], b[2][250009]; bool vis[509][509]; int dir[] = { 0, 1, 0, -1 }; int main() { while (scanf("%d", &R), R) { for (int i = 0; i < 2; i++) { scanf("%d%d%d%d", &W[i], &H[i], &sy[i], &sx[i]); sy[i]--, sx[i]--; for (int j = 0; j < H[i]; j++) { for (int k = 0; k < W[i]; k++) { scanf("%d", &a[i][j][k]); vis[j][k] = false; } } priority_queue<state> que; que.push(state{ sx[i], sy[i], -1 }); vis[sx[i]][sy[i]] = true; while (!que.empty()) { state u = que.top(); que.pop(); for (int j = 0; j < 4; j++) { int tx = u.sx + dir[j], ty = u.sy + dir[j ^ 1]; if (0 <= tx && tx < H[i] && 0 <= ty && ty < W[i] && !vis[tx][ty]) { a[i][tx][ty] = max(a[i][tx][ty], a[i][u.sx][u.sy]); vis[tx][ty] = true; que.push(state{ tx, ty, -a[i][tx][ty] }); } } } for (int j = 0; j < H[i]; j++) { for (int k = 0; k < W[i]; k++) { b[i][j * W[i] + k] = a[i][j][k]; } } sort(b[i], b[i] + H[i] * W[i]); } int ret = 2000000009; R -= 2; for (int i = 0; i <= R && i < H[0] * W[0] && i < H[1] * W[1]; i++) ret = min(ret, b[0][i] + b[1][R - i]); if (R == -1) ret = 2; printf("%d\n", ret); } return 0; }
a.cc: In function 'int main()': a.cc:40:25: error: 'sort' was not declared in this scope; did you mean 'short'? 40 | sort(b[i], b[i] + H[i] * W[i]); | ^~~~ | short
s870284091
p00465
C++
#include <bits/stdc++.h> using namespace std; #define int long long typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,int> plli; typedef pair<int,pii> pipii; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef vector<pii> vpii; #define rep(i,n) for (int i=0;i<(n);i++) #define rep2(i,a,b) for (int i=(a);i<(b);i++) #define rrep(i,n) for (int i=(n);i>=0;i--) #define rrep2(i,a,b) for (int i=(a);i>b;i--) #define pb push_back #define fi first #define se second #define all(a) (a).begin(),(a).end() const ll mod = 1e9 + 7; const ll INF = 1<<30; const int dx4[4] = {1, 0, -1, 0}; const int dy4[4] = {0, 1, 0, -1}; const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1}; const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1}; const double pi = 3.141592653589793; int r; int w1, h1, x1, y1; int w2, h2, x2, y2; int g1[505][505], g2[505][505]; bool check(int y, int x, int h, int w) { if ((0 <= y && y < h) && (0 <= x && x < w)) return true; return false; } vector<int> search(int sy, int sx, int h, int w, int g[505][505]) { priority_queue<pipii, vector<pipii>, greater<pipii>> pq; pq.push(make_pair(1LL, make_pair(sy, sx))); bool visited[h + 5][w + 5]={}; vector<int> cnt; cnt.pb(0); int now_level = 1; visited[sy][sx] = true; while (!pq.empty()) { pipii p = pq.top(); pq.pop(); int level = p.fi; int y = p.se.fi; int x = p.se.se; //cout << level << endl; if (now_level < level) { cnt.pb(level); now_level = level; } else { cnt.pb(now_level); } rep(i, 4) { int ny = y + dy4[i]; int nx = x + dx4[i]; if (!check(ny, nx, h, w) || visited[ny][nx]) continue; pq.push(make_pair(g[ny][nx], make_pair(ny, nx))); //cout << ny << nx << endl; visited[ny][nx] = true; } } return cnt; } signed main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> r; while (r != 0) { cin >> w1 >> h1 >> x1 >> y1; x1--;y1--; rep(i, h1)rep(j, w1) cin >> g1[i][j]; cin >> w2 >> h2 >> x2 >> y2; x2--;y2--; rep(i, h2)rep(j, w2) cin >> g2[i][j]; vector<int> cnt1 = search(y1, x1, h1, w1, g1); vector<int> cnt2 = search(y2, x2, h2, w2, g2); int ans = 1e12; rep(i, r + 1) { if (cnt1.size() <= i) break; if (cnt2.size() <= r - i) continue; ans = min(ans, cnt1[i] + cnt2[r - i]); } cout << ans << endl; cin >> r; } }
a.cc:33:17: error: 'long long int y1' redeclared as different kind of entity 33 | int w1, h1, x1, y1; | ^~ In file included from /usr/include/features.h:523, from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683, from /usr/include/c++/14/cassert:43, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33, from a.cc:1: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)' 257 | __MATHCALL (y1,, (_Mdouble_)); | ^~~~~~~~~~ a.cc: In function 'int main()': a.cc:81:31: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept') 81 | cin >> w1 >> h1 >> x1 >> y1; | ~~~~~~~~~~~~~~~~~~~~~ ^~ ~~ | | | | | double(double) noexcept | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} 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: /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:81:34: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept' 81 | cin >> w1 >> h1 >> x1 >> y1; | ^~ /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:81:34: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive] 81 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:81:34: error: cannot bind rvalue '(short int)y1' to 'short int&' /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:81:34: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive] 81 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:81:34: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&' /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:81:34: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive] 81 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:81:34: error: cannot bind rvalue '(int)y1' to 'int&' /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:81:34: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive] 81 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:81:34: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&' /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:81:34: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive] 81 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:81:34: error: cannot bind rvalue '(long int)y1' to 'long int&' /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:81:34: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive] 81 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:81:34: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&' /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:81:34: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive] 81 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:81:34: error: cannot bind rvalue '(long long int)y1' to 'long long int&' /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:81:34: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive] 81 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:81:34: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&' /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>]' (near match) 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed: a.cc:81:34: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive] 81 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:81:34: error: cannot bind rvalue '(void*)y1' to 'void*&' /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>]' (near match) 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed: a.cc:81:34: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive] 81 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept /usr/include/c++/14/istream:126:
s522948183
p00465
C++
#include <bits/stdc++.h> using namespace std; #define int long long typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,int> plli; typedef pair<int,pii> pipii; typedef vector<int> vi; typedef vector<ll> vll; typedef vector<vi> vvi; typedef vector<vvi> vvvi; typedef vector<pii> vpii; #define rep(i,n) for (int i=0;i<(n);i++) #define rep2(i,a,b) for (int i=(a);i<(b);i++) #define rrep(i,n) for (int i=(n);i>=0;i--) #define rrep2(i,a,b) for (int i=(a);i>b;i--) #define pb push_back #define fi first #define se second #define all(a) (a).begin(),(a).end() const ll mod = 1e9 + 7; const ll INF = 1<<30; const int dx4[4] = {1, 0, -1, 0}; const int dy4[4] = {0, 1, 0, -1}; const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1}; const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1}; const double pi = 3.141592653589793; int r; int w1, h1, x1, y1; int w2, h2, x2, y2; int g1[505][505], g2[505][505]; bool check(int y, int x, int h, int w) { if ((0 <= y && y < h) && (0 <= x && x < w)) return true; return false; } vector<int> search(int sy, int sx, int h, int w, int g[505][505]) { priority_queue<pipii, vector<pipii>, greater<pipii>> pq; pq.push(make_pair(1LL, make_pair(sy, sx))); bool visited[h + 5][w + 5]={}; vector<int> cnt; cnt.pb(0); int now_level = 1; visited[sy][sx] = true; while (!pq.empty()) { pipii p = pq.top(); pq.pop(); int level = p.fi; int y = p.se.fi; int x = p.se.se; if (now_level < level) { cnt.pb(level); now_level = level; } else { cnt.pb(now_level); } rep(i, 4) { int ny = y + dy4[i]; int nx = x + dx4[i]; if (!check(ny, nx, h, w) || visited[ny][nx]) continue; pq.push(make_pair(g[ny][nx], make_pair(ny, nx))); visited[ny][nx] = true; } } return cnt; } signed main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> r; while (r != 0) { cin >> w1 >> h1 >> x1 >> y1; x1--;y1--; rep(i, h1)rep(j, w1) cin >> g1[i][j]; cin >> w2 >> h2 >> x2 >> y2; x2--;y2--; rep(i, h2)rep(j, w2) cin >> g2[i][j]; vector<int> cnt1 = search(y1, x1, h1, w1, g1); vector<int> cnt2 = search(y2, x2, h2, w2, g2); int ans = 1e12; rep(i, r + 1) { if (cnt1.size() <= i) break; if (cnt2.size() <= r - i) continue; ans = min(ans, cnt1[i] + cnt2[r - i]); } cout << ans << endl; cin >> r; } }
a.cc:33:17: error: 'long long int y1' redeclared as different kind of entity 33 | int w1, h1, x1, y1; | ^~ In file included from /usr/include/features.h:523, from /usr/include/x86_64-linux-gnu/c++/14/bits/os_defines.h:39, from /usr/include/x86_64-linux-gnu/c++/14/bits/c++config.h:683, from /usr/include/c++/14/cassert:43, from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:33, from a.cc:1: /usr/include/x86_64-linux-gnu/bits/mathcalls.h:257:1: note: previous declaration 'double y1(double)' 257 | __MATHCALL (y1,, (_Mdouble_)); | ^~~~~~~~~~ a.cc: In function 'int main()': a.cc:79:31: error: no match for 'operator>>' (operand types are 'std::basic_istream<char>::__istream_type' {aka 'std::basic_istream<char>'} and 'double(double) noexcept') 79 | cin >> w1 >> h1 >> x1 >> y1; | ~~~~~~~~~~~~~~~~~~~~~ ^~ ~~ | | | | | double(double) noexcept | std::basic_istream<char>::__istream_type {aka std::basic_istream<char>} 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: /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:79:34: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'double (*)(double) noexcept' 79 | cin >> w1 >> h1 >> x1 >> y1; | ^~ /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:79:34: error: invalid conversion from 'double (*)(double) noexcept' to 'short int' [-fpermissive] 79 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:79:34: error: cannot bind rvalue '(short int)y1' to 'short int&' /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:79:34: error: invalid conversion from 'double (*)(double) noexcept' to 'short unsigned int' [-fpermissive] 79 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:79:34: error: cannot bind rvalue '(short unsigned int)y1' to 'short unsigned int&' /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:79:34: error: invalid conversion from 'double (*)(double) noexcept' to 'int' [-fpermissive] 79 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:79:34: error: cannot bind rvalue '(int)y1' to 'int&' /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:79:34: error: invalid conversion from 'double (*)(double) noexcept' to 'unsigned int' [-fpermissive] 79 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:79:34: error: cannot bind rvalue '(unsigned int)y1' to 'unsigned int&' /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:79:34: error: invalid conversion from 'double (*)(double) noexcept' to 'long int' [-fpermissive] 79 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:79:34: error: cannot bind rvalue '(long int)y1' to 'long int&' /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:79:34: error: invalid conversion from 'double (*)(double) noexcept' to 'long unsigned int' [-fpermissive] 79 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:79:34: error: cannot bind rvalue '(long unsigned int)y1' to 'long unsigned int&' /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:79:34: error: invalid conversion from 'double (*)(double) noexcept' to 'long long int' [-fpermissive] 79 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:79:34: error: cannot bind rvalue '(long long int)y1' to 'long long int&' /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:79:34: error: invalid conversion from 'double (*)(double) noexcept' to 'long long unsigned int' [-fpermissive] 79 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:79:34: error: cannot bind rvalue '(long long unsigned int)y1' to 'long long unsigned int&' /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>]' (near match) 328 | operator>>(void*& __p) | ^~~~~~~~ /usr/include/c++/14/istream:328:7: note: conversion of argument 1 would be ill-formed: a.cc:79:34: error: invalid conversion from 'double (*)(double) noexcept' to 'void*' [-fpermissive] 79 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept a.cc:79:34: error: cannot bind rvalue '(void*)y1' to 'void*&' /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>]' (near match) 122 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /usr/include/c++/14/istream:122:7: note: conversion of argument 1 would be ill-formed: a.cc:79:34: error: invalid conversion from 'double (*)(double) noexcept' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} [-fpermissive] 79 | cin >> w1 >> h1 >> x1 >> y1; | ^~ | | | double (*)(double) noexcept /usr/include/c++/14/istream:126:
s931181881
p00465
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
s233210186
p00465
C++
#include <iostream> #include <list> #include <vector> using namespace std; const int FIELD_SIZE = 502 * 502; // ”Ô•º‚Ì‚½‚ß+2‚·‚é const int FIELD_WIDTH = 502; int field[FIELD_SIZE]; // ì‹Æ—p—̈æ typedef struct LevelRoomRelation { int level, room; // ”FØƒŒƒxƒ‹, •”‰®” } LevelRoomRelation; int fill(int r, int p, list<int> *nexts){ int count = 1; field[p] = 0; if(field[p + 1] == 0){ // ’Ê‰ßÏ‚Ý }else if(field[p + 1] <= r){ // ‚»‚Ì•”‰®‚É“ü‚é count += fill(r, p + 1, nexts); }else{ // Œã‚Å“ü‚郊ƒXƒg‚֒ljÁ list<int>::iterator it = nexts->begin(); while(it != nexts->end()){ if(field[*it] >= field[p + 1]){ break; } it++; } nexts->insert(it, p + 1); } if(field[p - 1] == 0){ // ’Ê‰ßÏ‚Ý }else if(field[p - 1] <= r){ // ‚»‚Ì•”‰®‚É“ü‚é count += fill(r, p - 1, nexts); }else{ // Œã‚Å“ü‚郊ƒXƒg‚֒ljÁ list<int>::iterator it = nexts->begin(); while(it != nexts->end()){ if(field[*it] >= field[p - 1]){ break; } it++; } nexts->insert(it, p - 1); } if(field[p + FIELD_WIDTH] == 0){ // ’Ê‰ßÏ‚Ý }else if(field[p + FIELD_WIDTH] <= r){ // ‚»‚Ì•”‰®‚É“ü‚é count += fill(r, p + FIELD_WIDTH, nexts); }else{ // Œã‚Å“ü‚郊ƒXƒg‚֒ljÁ list<int>::iterator it = nexts->begin(); while(it != nexts->end()){ if(field[*it] >= field[p + FIELD_WIDTH]){ break; } it++; } nexts->insert(it, p + FIELD_WIDTH); } if(field[p - FIELD_WIDTH] == 0){ // ’Ê‰ßÏ‚Ý }else if(field[p - FIELD_WIDTH] <= r){ // ‚»‚Ì•”‰®‚É“ü‚é count += fill(r, p - FIELD_WIDTH, nexts); }else{ // Œã‚Å“ü‚郊ƒXƒg‚֒ljÁ list<int>::iterator it = nexts->begin(); while(it != nexts->end()){ if(field[*it] >= field[p - FIELD_WIDTH]){ break; } it++; } nexts->insert(it, p - FIELD_WIDTH); } return count; } void calculateLevel(int r, list<LevelRoomRelation> *answer){ // –â‘è‚Ì“ü—Í int w, h, x, y; scanf("%d%d%d%d", &w, &h, &x, &y); memset(field, 0, sizeof(int) * FIELD_SIZE); for(int i = 1; i <= h; i++){ for(int j = 1; j <= w; j++){ scanf("%d", &(field[i * FIELD_WIDTH + j])); } } // ŒvŽZ‚·‚é int currentLevel = 0, currentRoomCount = 0, remains = w * h; list<int> nexts; nexts.push_back(x + y * FIELD_WIDTH); list<int>::iterator front = nexts.begin(); while(currentRoomCount < r && remains > 0){ while(front != nexts.end()){ currentLevel = field[*front]; if(currentLevel != 0){ break; } front++; } while(front != nexts.end() && field[*front] <= currentLevel){ if(field[*front] != 0){ // ‚Ü‚¾’ʉ߂µ‚Ä‚¢‚È‚¢ê‡ int fillResult = fill(currentLevel, (*front), &nexts); currentRoomCount += fillResult; remains -= fillResult; } front++; } LevelRoomRelation lrr; lrr.level = currentLevel; lrr.room = currentRoomCount; answer->push_back(lrr); } } int main(){ while(true){ int r; scanf("%d", &r); if(r == 0){ break; } LevelRoomRelation lrr; lrr.level = 0; lrr.room = 0; list<LevelRoomRelation> office1; calculateLevel(r, &office1); office1.insert(office1.begin(), lrr); { // cout << "Office1 dump:" << endl; list<LevelRoomRelation>::iterator it = office1.begin(); while(it != office1.end()){ // cout << "Level: " << (*it).level << " / " << "Room: " << (*it).room << endl; it++; } } list<LevelRoomRelation> office2; calculateLevel(r, &office2); office2.insert(office2.begin(), lrr); { // cout << "Office2 dump:" << endl; list<LevelRoomRelation>::iterator it = office2.begin(); while(it != office2.end()){ // cout << "Level: " << (*it).level << " / " << "Room: " << (*it).room << endl; it++; } } int minLevel = 0x7fffffff; list<LevelRoomRelation>::iterator it1 = office1.begin(), it2 = office2.end(); int level2, level1 = 0; int roomCount2, roomCount1 = 0, roomCount; while(true){ if(it2 == office2.begin()){ if(it1 == office1.end()){ break; } }else{ it2--; } level2 = (*it2).level; roomCount2 = (*it2).room; roomCount = roomCount2 + roomCount1; while(it1 != office1.end() && roomCount < r){ roomCount1 = (*it1).room; roomCount = roomCount2 + roomCount1; level1 = (*it1).level; it1++; } // cout << "office1: " << level1 << " / office2: " << level2 << endl; if(minLevel > (level2 + level1)){ minLevel = level2 + level1; } } cout << minLevel << endl; } return 0; }
a.cc: In function 'void calculateLevel(int, std::__cxx11::list<LevelRoomRelation>*)': a.cc:68:9: error: 'memset' was not declared in this scope 68 | memset(field, 0, sizeof(int) * FIELD_SIZE); | ^~~~~~ a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 3 | #include <vector> +++ |+#include <cstring> 4 |
s318556815
p00465
C++
#include<cstdio> #include<algorithm> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) #define reps(i,n) for(int i=1;i<=n;i++) const int INF=1010000000; int R; int w[2],h[2],st[2],gl[2]; int masu[2][501][501]; int need[2][25001]; int visit[501][501]; int dx[4]={1,0,-1,0}; int dy[4]={0,1,0,-1}; int glcont; void saiki(int w,int h,int x,int y,int masu[501][501],int mn){ if(x<0 || y<0 || x>=w || y>=h)return; if(masu[x][y]>mn)return; if(visit[x][y]==1)return; visit[x][y]=1; rep(i,4){ saiki(w,h,x+dx[i],y+dy[i],masu,mn); } glcont++; } int main(){ while(1){ scanf("%d",&R); if(R==0)break; rep(i,2){ scanf("%d%d%d%d",&w[i],&h[i],&st[i],&gl[i]); rep(j,h[i]){ rep(k,w[i]){ scanf("%d",&masu[i][k][j]); } } } int left,right; left=0; right=1000000001; rep(i,2)rep(j,250001)need[i][j]=INF; rep(i,2){ rep(n,w[i]*h[i]+1){ int left,right; left=0;right=1000000001; while(1){ double half= double(left+right)/2.0; rep(rr,w[i])rep(ee,h[i])visit[rr][ee]=0; glcont=0; saiki(w[i],h[i],st[i]-1,gl[i]-1,masu[i],int(half)); if(glcont<n){ left=half+0.5; }else{ right=half; } if(left==right){ break; } } need[i][n]=left; } } int mini=INT_MAX; int dd=0; if(w[0]*h[0] < w[1]+h[1]){ dd=1; } rep(i,250001){ if(R-i<0)break; mini = min(mini, need[dd][i] + need[!dd][R-i]); } /* rep(i,2){ puts(""); rep(n,w[i]*h[i]+1){ printf("%d %d\n",n,need[i][n]); } }*/ printf("%d\n",mini); } }
a.cc: In function 'int main()': a.cc:82:26: error: 'INT_MAX' was not declared in this scope 82 | int mini=INT_MAX; | ^~~~~~~ a.cc:3:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 2 | #include<algorithm> +++ |+#include <climits> 3 |
s878632824
p00465
C++
#include <stdio.h> #include <queue> #include <limits.h> using namespace std; struct room { int level, x, y; room(int level, int x, int y) { this->level = level, this->x = x, this->y = y; } bool operator < (room rhs) const { return this->level > rhs.level; } }; int map[2][500][500]; bool visit[2][500][500]; int result[2][100001]; int main() { int r, w[2], h[2], sx[2], sy[2], tmp, sec, open, ans; while(true) { scanf("%d", &r); if(r == 0) break; for(int i = 0; i < 2; ++i) { scanf("%d%d%d%d", &w[i], &h[i], &sx[i], &sy[i]); --sx[i], --sy[i]; for(int y = 0; y < h[i]; ++y) { for(int x = 0; x < w[i]; ++x) { scanf("%d", &tmp); map[i][x][y] = tmp; visit[i][x][y] = false; } } for(int j = 1; j <= r; ++j) result[i][j] = -1; result[i][0] = 0; } priority_queue<room> next; queue<room> seek; for(int i = 0; i < 2; ++i) { open = 0; sec = 0; next.push(room(1, sx[i], sy[i])); while(!next.empty() && open < r) { sec = next.top().level; while(!next.empty()) { room m = next.top(); if(m.level > sec) break; visit[i][m.x][m.y] = true; seek.push(m); next.pop(); } while(!seek.empty()) { room at = seek.front(); seek.pop(); result[i][++open] = sec; for(int rx = at.x - 1; rx < at.x + 2; ++rx) { for(int ry = at.y - 1; ry < at.y + 2; ++ry) { if(abs(rx - at.x) + abs(ry - at.y) != 1) continue; if(rx < 0 || rx >= w[i] || ry < 0 || ry >= h[i]) continue; if(visit[i][rx][ry]) continue; if(map[i][rx][ry] <= sec) { seek.push(room(map[i][rx][ry], rx, ry)); visit[i][rx][ry] = true; } else { next.push(room(map[i][rx][ry], rx, ry)); visit[i][rx][ry] = true; } } } } } for(int j = 1; j <= open; ++j) { if(result[i][j] == -1) result[i][j] = result[i][j - 1]; printf("%d ", result[i][j]); } printf("\n%d: open=%d level=%d\n", i, open, sec); } ans = INT_MAX; for(int i = 0; i <= r; ++i) { if(result[0][i] == -1 || result[1][r - i] == -1) continue; ans = min(ans, result[0][i] + result[1][r - i]); } printf("%d\n", ans); } return 0; }
a.cc: In function 'int main()': a.cc:64:60: error: 'abs' was not declared in this scope; did you mean 'ans'? 64 | if(abs(rx - at.x) + abs(ry - at.y) != 1) continue; | ^~~ | ans
s204532832
p00465
C++
#include <iostream> #include <algorithm> #include <string> #include <vector> #include <iterator> #include <list> #include <map> #include <queue> #include <bitset> #include <fstream> #include <cmath> #include <ctime> #include <numeric> using namespace std; typedef long long ll; typedef vector<int> vint; typedef pair<int,int> pint; #define REP(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) REP(i,0,n) #define MSG(a) cout << #a << " " << a << endl; template<class T> void chmin(T &t, T f) { if (t > f) t = f; } template<class T> void chmax(T &t, T f) { if (t < f) t = f; } struct node { int x, y, cost; node(int x, int y, int cost) : x(x), y(y), cost(cost) {} }; bool operator < (const node &a, const node &b) { return a.cost > b.cost; } int room[500][500]; int from[500 * 500]; bool flag[500][500]; int main() { int r; while(cin >> r && r) { // key, value map<int, int> result[2]; result[0][0] = result[1][0] = 0; // Dijkstra rep(i, 2) { int w, h, sx, sy; cin >> w >> h >> sx >> sy; sx--; sy--; rep(y, h) rep(x, w) cin >> room[y][x]; priority_queue<node> que; memset(flag, 0, sizeof(flag)); for(que.push(node(sx, sy, room[sy][sx])); !que.empty(); que.pop()) { node q = que.top(); if(flag[q.y][q.x]) continue; else flag[q.y][q.x] = true; result[i][q.cost]++; int dx[] = {-1,0,1,0} , dy[] = {0,-1,0,1}; rep(d, 4) { int tx = q.x + dx[d], ty = q.y + dy[d]; if(0 <= tx && tx < w && 0 <= ty && ty < h && !flag[ty][tx]) que.push(node(tx, ty, max(q.cost, room[ty][tx]))); } } } int res = INT_MAX; int sum_one = 0; vector<int> u; for(map<int, int>::iterator it = result[1].begin(); it != result[1].end(); it++) { from[u.size()] = it->first; u.push_back(it->second + sum_one); sum_one += it->second; } u.push_back(INT_MAX); int sum_one_second = 0; for(map<int, int>::iterator it = result[0].begin(); it != result[0].end(); it++) { int l = it->first, c = it->second + sum_one_second, ac = *lower_bound(u.begin(), u.end(), r - l); if(ac != INT_MAX) { int al = from[lower_bound(u.begin(), u.end(), r - c) - u.begin()]; chmin(res, l + al); } sum_one_second += it->second; } cout << res << endl; } }
a.cc: In function 'int main()': a.cc:56:25: error: 'memset' was not declared in this scope 56 | memset(flag, 0, sizeof(flag)); | ^~~~~~ a.cc:14:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>' 13 | #include <numeric> +++ |+#include <cstring> 14 | using namespace std; a.cc:76:27: error: 'INT_MAX' was not declared in this scope 76 | int res = INT_MAX; | ^~~~~~~ a.cc:14:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>' 13 | #include <numeric> +++ |+#include <climits> 14 | using namespace std;
s133643321
p00465
C++
#include <cstdio> #include <algorithm> #include <queue> using namespace std; typedef pair<int,pair<int,int>> PP; int r,w[2],h[2],x[2],y[2]; long long level[501][501][2]; bool used[501][501][2]={}; long long sparklingdaydream[501][501][2]; long long need[250005][2]={}; long long s[250005]={},d[250005]={}; int main(){ while(1){ memset(need,0,sizeof(need)); memset(s,0,sizeof(s)); memset(d,0,sizeof(d)); memset(used,false,sizeof(used)); priority_queue<PP,vector<PP>,greater<PP>>pque; scanf("%d",&r); if(r==0) break; scanf("%d %d %d %d",&w[0],&h[0],&x[0],&y[0]); for(int r=0;r<501;r++){ for(int g=0;g<501;g++){ sparklingdaydream[r][g][0]=1000000000000; level[r][g][0]=1000000000000; } } for(int i=1;i<=h[0];i++){ for(int j=1;j<=w[0];j++){ scanf("%lld",&level[j][i][0]); } } sparklingdaydream[x[0]][y[0]][0]=1; pque.push(make_pair(sparklingdaydream[x[0]][y[0]][0],make_pair(x[0],y[0]))); int dx[3]={0,1,-1}; int dy[3]={0,1,-1}; while(!pque.empty()){ PP p=pque.top(); pque.pop(); used[p.second.first][p.second.second][0]=true; for(int k=0;k<3;k++){ for(int l=0;l<3;l++){ if(k!=l && (k==0 || l==0)){ if(!used[p.second.first+dx[k]][p.second.second+dy[l]][0]){ if(p.second.first+dx[k]>=1 && p.second.first+dx[k]<=w[0] && p.second.second+dy[l]>=1 && p.second.second+dy[l]<=h[0]){ long long h=p.first; sparklingdaydream[p.second.first+dx[k]][p.second.second+dy[l]][0]=max(h,level[p.second.first+dx[k]][p.second.second+dy[l]][0]); pque.push(make_pair(sparklingdaydream[p.second.first+dx[k]][p.second.second+dy[l]][0],make_pair(p.second.first+dx[k],p.second.second+dy[l]))); used[p.second.first+dx[k]][p.second.second+dy[l]][0]=true; } } } } } } for(int r=0;r<501;r++){ for(int g=0;g<501;g++){ sparklingdaydream[r][g][1]=1000000000000; level[r][g][1]=1000000000000; } } scanf("%d %d %d %d",&w[1],&h[1],&x[1],&y[1]); for(int i=1;i<=h[1];i++){ for(int j=1;j<=w[1];j++){ scanf("%lld",&level[j][i][1]); } } sparklingdaydream[x[1]][y[1]][1]=1; pque.push(make_pair(sparklingdaydream[x[1]][y[1]][1],make_pair(x[1],y[1]))); while(!pque.empty()){ PP p=pque.top(); pque.pop(); used[p.second.first][p.second.second][1]=true; for(int k=0;k<3;k++){ for(int l=0;l<3;l++){ if(k!=l && (k==0 || l==0)){ if(!used[p.second.first+dx[k]][p.second.second+dy[l]][1]){ if(p.second.first+dx[k]>=1 && p.second.first+dx[k]<=w[1] && p.second.second+dy[l]>=1 && p.second.second+dy[l]<=h[1]){ long long h=p.first; sparklingdaydream[p.second.first+dx[k]][p.second.second+dy[l]][1]=max(h,level[p.second.first+dx[k]][p.second.second+dy[l]][1]); pque.push(make_pair(sparklingdaydream[p.second.first+dx[k]][p.second.second+dy[l]][1],make_pair(p.second.first+dx[k],p.second.second+dy[l]))); used[p.second.first+dx[k]][p.second.second+dy[l]][1]=true; } } } } } } int g=0; for(int i=1;i<=w[0];i++){ for(int j=1;j<=h[0];j++){ s[g]=sparklingdaydream[i][j][0]; g++; } } sort(s,s+g); int eee=1; for(int i=0;i<g;i++){ if(s[i]!=s[i+1]){ for(int j=eee;j<=i+1;j++){ need[j][0]=s[i]; eee=i+2; } } } g=0; for(int i=1;i<=w[1];i++){ for(int j=1;j<=h[1];j++){ d[g]=sparklingdaydream[i][j][1]; g++; } } sort(d,d+g); eee=1; for(int i=0;i<g;i++){ if(d[i]!=d[i+1]){ for(int j=eee;j<=i+1;j++){ need[j][1]=d[i]; eee=i+2; } } } long long ans=10000000000; for(int i=1;i<250005;i++){ for(int j=0;j<2;j++){ if(!need[i][j]){ need[i][j]=10000000000000; } } } for(int i=0;i<=r;i++){ ans=min(ans,need[i][0]+need[r-i][1]); } printf("%lld\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:14:17: error: 'memset' was not declared in this scope 14 | memset(need,0,sizeof(need)); | ^~~~~~ 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 | using namespace std;
s777475076
p00465
C++
#include <cstdio> #include <algorithm> #include <queue> using namespace std; typedef pair<int,pair<int,int>> PP; int r,w[2],h[2],x[2],y[2]; long long level[501][501][2]; bool used[501][501][2]={}; long long sparklingdaydream[501][501][2]; long long need[250005][2]={}; long long s[250005]={},d[250005]={}; int main(){ while(1){ memset(need,0,sizeof(need)); memset(s,0,sizeof(s)); memset(d,0,sizeof(d)); memset(used,false,sizeof(used)); priority_queue<PP,vector<PP>,greater<PP>>pque; scanf("%d",&r); if(r==0) break; scanf("%d %d %d %d",&w[0],&h[0],&x[0],&y[0]); for(int r=0;r<501;r++){ for(int g=0;g<501;g++){ sparklingdaydream[r][g][0]=1000000000000; level[r][g][0]=1000000000000; } } for(int i=1;i<=h[0];i++){ for(int j=1;j<=w[0];j++){ scanf("%lld",&level[j][i][0]); } } sparklingdaydream[x[0]][y[0]][0]=1; pque.push(make_pair(sparklingdaydream[x[0]][y[0]][0],make_pair(x[0],y[0]))); int dx[3]={0,1,-1}; int dy[3]={0,1,-1}; while(!pque.empty()){ PP p=pque.top(); pque.pop(); used[p.second.first][p.second.second][0]=true; for(int k=0;k<3;k++){ for(int l=0;l<3;l++){ if(k!=l && (k==0 || l==0)){ if(!used[p.second.first+dx[k]][p.second.second+dy[l]][0]){ if(p.second.first+dx[k]>=1 && p.second.first+dx[k]<=w[0] && p.second.second+dy[l]>=1 && p.second.second+dy[l]<=h[0]){ long long h=p.first; sparklingdaydream[p.second.first+dx[k]][p.second.second+dy[l]][0]=max(h,level[p.second.first+dx[k]][p.second.second+dy[l]][0]); pque.push(make_pair(sparklingdaydream[p.second.first+dx[k]][p.second.second+dy[l]][0],make_pair(p.second.first+dx[k],p.second.second+dy[l]))); used[p.second.first+dx[k]][p.second.second+dy[l]][0]=true; } } } } } } for(int r=0;r<501;r++){ for(int g=0;g<501;g++){ sparklingdaydream[r][g][1]=1000000000000; level[r][g][1]=1000000000000; } } scanf("%d %d %d %d",&w[1],&h[1],&x[1],&y[1]); for(int i=1;i<=h[1];i++){ for(int j=1;j<=w[1];j++){ scanf("%lld",&level[j][i][1]); } } sparklingdaydream[x[1]][y[1]][1]=1; pque.push(make_pair(sparklingdaydream[x[1]][y[1]][1],make_pair(x[1],y[1]))); while(!pque.empty()){ PP p=pque.top(); pque.pop(); used[p.second.first][p.second.second][1]=true; for(int k=0;k<3;k++){ for(int l=0;l<3;l++){ if(k!=l && (k==0 || l==0)){ if(!used[p.second.first+dx[k]][p.second.second+dy[l]][1]){ if(p.second.first+dx[k]>=1 && p.second.first+dx[k]<=w[1] && p.second.second+dy[l]>=1 && p.second.second+dy[l]<=h[1]){ long long h=p.first; sparklingdaydream[p.second.first+dx[k]][p.second.second+dy[l]][1]=max(h,level[p.second.first+dx[k]][p.second.second+dy[l]][1]); pque.push(make_pair(sparklingdaydream[p.second.first+dx[k]][p.second.second+dy[l]][1],make_pair(p.second.first+dx[k],p.second.second+dy[l]))); used[p.second.first+dx[k]][p.second.second+dy[l]][1]=true; } } } } } } int g=0; for(int i=1;i<=w[0];i++){ for(int j=1;j<=h[0];j++){ s[g]=sparklingdaydream[i][j][0]; g++; } } sort(s,s+g); int eee=1; for(int i=0;i<g;i++){ if(s[i]!=s[i+1]){ for(int j=eee;j<=i+1;j++){ need[j][0]=s[i]; eee=i+2; } } } g=0; for(int i=1;i<=w[1];i++){ for(int j=1;j<=h[1];j++){ d[g]=sparklingdaydream[i][j][1]; g++; } } sort(d,d+g); eee=1; for(int i=0;i<g;i++){ if(d[i]!=d[i+1]){ for(int j=eee;j<=i+1;j++){ need[j][1]=d[i]; eee=i+2; } } } long long ans=10000000000; for(int i=1;i<250005;i++){ for(int j=0;j<2;j++){ if(!need[i][j]){ need[i][j]=10000000000000; } } } for(int i=0;i<=r;i++){ ans=min(ans,need[i][0]+need[r-i][1]); } printf("%lld\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:14:17: error: 'memset' was not declared in this scope 14 | memset(need,0,sizeof(need)); | ^~~~~~ 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 | using namespace std;
s539871051
p00465
C++
#include <cstdio> #include <algorithm> #include <queue> using namespace std; typedef pair<int,pair<int,int> > PP; int r,w[2],h[2],x[2],y[2]; long long level[501][501][2]; bool used[501][501][2]={}; long long sparklingdaydream[501][501][2]; long long need[250005][2]={}; long long s[250005]={},d[250005]={}; int main(){ while(1){ memset(need,0,sizeof(need)); memset(s,0,sizeof(s)); memset(d,0,sizeof(d)); memset(used,false,sizeof(used)); priority_queue<PP,vector<PP>,greater<PP> >pque; scanf("%d",&r); if(r==0) break; scanf("%d %d %d %d",&w[0],&h[0],&x[0],&y[0]); for(int r=0;r<501;r++){ for(int g=0;g<501;g++){ sparklingdaydream[r][g][0]=1000000000000; level[r][g][0]=1000000000000; } } for(int i=1;i<=h[0];i++){ for(int j=1;j<=w[0];j++){ scanf("%lld",&level[j][i][0]); } } sparklingdaydream[x[0]][y[0]][0]=1; pque.push(make_pair(sparklingdaydream[x[0]][y[0]][0],make_pair(x[0],y[0]))); int dx[3]={0,1,-1}; int dy[3]={0,1,-1}; while(!pque.empty()){ PP p=pque.top(); pque.pop(); used[p.second.first][p.second.second][0]=true; for(int k=0;k<3;k++){ for(int l=0;l<3;l++){ if(k!=l && (k==0 || l==0)){ if(!used[p.second.first+dx[k]][p.second.second+dy[l]][0]){ if(p.second.first+dx[k]>=1 && p.second.first+dx[k]<=w[0] && p.second.second+dy[l]>=1 && p.second.second+dy[l]<=h[0]){ long long h=p.first; sparklingdaydream[p.second.first+dx[k]][p.second.second+dy[l]][0]=max(h,level[p.second.first+dx[k]][p.second.second+dy[l]][0]); pque.push(make_pair(sparklingdaydream[p.second.first+dx[k]][p.second.second+dy[l]][0],make_pair(p.second.first+dx[k],p.second.second+dy[l]))); used[p.second.first+dx[k]][p.second.second+dy[l]][0]=true; } } } } } } for(int r=0;r<501;r++){ for(int g=0;g<501;g++){ sparklingdaydream[r][g][1]=1000000000000; level[r][g][1]=1000000000000; } } scanf("%d %d %d %d",&w[1],&h[1],&x[1],&y[1]); for(int i=1;i<=h[1];i++){ for(int j=1;j<=w[1];j++){ scanf("%lld",&level[j][i][1]); } } sparklingdaydream[x[1]][y[1]][1]=1; pque.push(make_pair(sparklingdaydream[x[1]][y[1]][1],make_pair(x[1],y[1]))); while(!pque.empty()){ PP p=pque.top(); pque.pop(); used[p.second.first][p.second.second][1]=true; for(int k=0;k<3;k++){ for(int l=0;l<3;l++){ if(k!=l && (k==0 || l==0)){ if(!used[p.second.first+dx[k]][p.second.second+dy[l]][1]){ if(p.second.first+dx[k]>=1 && p.second.first+dx[k]<=w[1] && p.second.second+dy[l]>=1 && p.second.second+dy[l]<=h[1]){ long long h=p.first; sparklingdaydream[p.second.first+dx[k]][p.second.second+dy[l]][1]=max(h,level[p.second.first+dx[k]][p.second.second+dy[l]][1]); pque.push(make_pair(sparklingdaydream[p.second.first+dx[k]][p.second.second+dy[l]][1],make_pair(p.second.first+dx[k],p.second.second+dy[l]))); used[p.second.first+dx[k]][p.second.second+dy[l]][1]=true; } } } } } } int g=0; for(int i=1;i<=w[0];i++){ for(int j=1;j<=h[0];j++){ s[g]=sparklingdaydream[i][j][0]; g++; } } sort(s,s+g); int eee=1; for(int i=0;i<g;i++){ if(s[i]!=s[i+1]){ for(int j=eee;j<=i+1;j++){ need[j][0]=s[i]; eee=i+2; } } } g=0; for(int i=1;i<=w[1];i++){ for(int j=1;j<=h[1];j++){ d[g]=sparklingdaydream[i][j][1]; g++; } } sort(d,d+g); eee=1; for(int i=0;i<g;i++){ if(d[i]!=d[i+1]){ for(int j=eee;j<=i+1;j++){ need[j][1]=d[i]; eee=i+2; } } } long long ans=10000000000; for(int i=1;i<250005;i++){ for(int j=0;j<2;j++){ if(!need[i][j]){ need[i][j]=10000000000000; } } } for(int i=0;i<=r;i++){ ans=min(ans,need[i][0]+need[r-i][1]); } printf("%lld\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:14:17: error: 'memset' was not declared in this scope 14 | memset(need,0,sizeof(need)); | ^~~~~~ 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 | using namespace std;
s722858881
p00465
C++
#include <cstdio> #include <algorithm> #include <queue> using namespace std; typedef pair<int,pair<int,int> > PP; int r,w[2],h[2],x[2],y[2]; long long level[501][501][2]; bool used[501][501][2]={}; long long sparklingdaydream[501][501][2]; long long need[250005][2]={}; long long s[250005]={},d[250005]={}; int main(){ while(1){ memset(need,0,sizeof(need) ); memset(s,0,sizeof(s) ); memset(d,0,sizeof(d) ); memset(used,false,sizeof(used) ); priority_queue<PP,vector<PP>,greater<PP> >pque; scanf("%d",&r); if(r==0) break; scanf("%d %d %d %d",&w[0],&h[0],&x[0],&y[0]); for(int r=0;r<501;r++){ for(int g=0;g<501;g++){ sparklingdaydream[r][g][0]=1000000000000; level[r][g][0]=1000000000000; } } for(int i=1;i<=h[0];i++){ for(int j=1;j<=w[0];j++){ scanf("%lld",&level[j][i][0]); } } sparklingdaydream[x[0]][y[0]][0]=1; pque.push(make_pair(sparklingdaydream[x[0]][y[0]][0],make_pair(x[0],y[0]))); int dx[3]={0,1,-1}; int dy[3]={0,1,-1}; while(!pque.empty()){ PP p=pque.top(); pque.pop(); used[p.second.first][p.second.second][0]=true; for(int k=0;k<3;k++){ for(int l=0;l<3;l++){ if(k!=l && (k==0 || l==0)){ if(!used[p.second.first+dx[k]][p.second.second+dy[l]][0]){ if(p.second.first+dx[k]>=1 && p.second.first+dx[k]<=w[0] && p.second.second+dy[l]>=1 && p.second.second+dy[l]<=h[0]){ long long h=p.first; sparklingdaydream[p.second.first+dx[k]][p.second.second+dy[l]][0]=max(h,level[p.second.first+dx[k]][p.second.second+dy[l]][0]); pque.push(make_pair(sparklingdaydream[p.second.first+dx[k]][p.second.second+dy[l]][0],make_pair(p.second.first+dx[k],p.second.second+dy[l]))); used[p.second.first+dx[k]][p.second.second+dy[l]][0]=true; } } } } } } for(int r=0;r<501;r++){ for(int g=0;g<501;g++){ sparklingdaydream[r][g][1]=1000000000000; level[r][g][1]=1000000000000; } } scanf("%d %d %d %d",&w[1],&h[1],&x[1],&y[1]); for(int i=1;i<=h[1];i++){ for(int j=1;j<=w[1];j++){ scanf("%lld",&level[j][i][1]); } } sparklingdaydream[x[1]][y[1]][1]=1; pque.push(make_pair(sparklingdaydream[x[1]][y[1]][1],make_pair(x[1],y[1]))); while(!pque.empty()){ PP p=pque.top(); pque.pop(); used[p.second.first][p.second.second][1]=true; for(int k=0;k<3;k++){ for(int l=0;l<3;l++){ if(k!=l && (k==0 || l==0)){ if(!used[p.second.first+dx[k]][p.second.second+dy[l]][1]){ if(p.second.first+dx[k]>=1 && p.second.first+dx[k]<=w[1] && p.second.second+dy[l]>=1 && p.second.second+dy[l]<=h[1]){ long long h=p.first; sparklingdaydream[p.second.first+dx[k]][p.second.second+dy[l]][1]=max(h,level[p.second.first+dx[k]][p.second.second+dy[l]][1]); pque.push(make_pair(sparklingdaydream[p.second.first+dx[k]][p.second.second+dy[l]][1],make_pair(p.second.first+dx[k],p.second.second+dy[l]))); used[p.second.first+dx[k]][p.second.second+dy[l]][1]=true; } } } } } } int g=0; for(int i=1;i<=w[0];i++){ for(int j=1;j<=h[0];j++){ s[g]=sparklingdaydream[i][j][0]; g++; } } sort(s,s+g); int eee=1; for(int i=0;i<g;i++){ if(s[i]!=s[i+1]){ for(int j=eee;j<=i+1;j++){ need[j][0]=s[i]; eee=i+2; } } } g=0; for(int i=1;i<=w[1];i++){ for(int j=1;j<=h[1];j++){ d[g]=sparklingdaydream[i][j][1]; g++; } } sort(d,d+g); eee=1; for(int i=0;i<g;i++){ if(d[i]!=d[i+1]){ for(int j=eee;j<=i+1;j++){ need[j][1]=d[i]; eee=i+2; } } } long long ans=10000000000; for(int i=1;i<250005;i++){ for(int j=0;j<2;j++){ if(!need[i][j]){ need[i][j]=10000000000000; } } } for(int i=0;i<=r;i++){ ans=min(ans,need[i][0]+need[r-i][1]); } printf("%lld\n",ans); } return 0; }
a.cc: In function 'int main()': a.cc:14:9: error: 'memset' was not declared in this scope 14 | memset(need,0,sizeof(need) ); | ^~~~~~ 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 | using namespace std;
s290920795
p00465
C++
#include <iostream> #include <list> #include <map> #include <cstring> using namespace std; const int FIELD_SIZE = 502 * 502; // 逡ェ蜈オ縺ョ縺溘a+2縺吶k const int FIELD_WIDTH = 502; int field[FIELD_SIZE]; // 菴懈・ュ逕ィ鬆伜沺 typedef struct LevelRoomRelation { int level, room; // 隱崎ィシ繝ャ繝吶Ν, 驛ィ螻区焚 } LevelRoomRelation; int fill(int r, int p, multimap<int, int> *nexts){ int count = 1; field[p] = 0; if(field[p + 1] == 0){ // 騾夐℃貂医∩ }else if(field[p + 1] <= r){ // 縺昴&#65533;驛ィ螻九↓蜈・繧&#65533; count += fill(r, p + 1, nexts); }else{ // 蠕後〒蜈・繧九Μ繧ケ繝医∈霑ス蜉&#65533; nexts->insert(multimap<int, int>::value_type(field[p + 1], p + 1)); } if(field[p - 1] == 0){ // 騾夐℃貂医∩ }else if(field[p - 1] <= r){ // 縺昴&#65533;驛ィ螻九↓蜈・繧&#65533; count += fill(r, p - 1, nexts); }else{ // 蠕後〒蜈・繧九Μ繧ケ繝医∈霑ス蜉&#65533; nexts->insert(multimap<int, int>::value_type(field[p - 1], p - 1)); } if(field[p + FIELD_WIDTH] == 0){ // 騾夐℃貂医∩ }else if(field[p + FIELD_WIDTH] <= r){ // 縺昴&#65533;驛ィ螻九↓蜈・繧&#65533; count += fill(r, p + FIELD_WIDTH, nexts); }else{ // 蠕後〒蜈・繧九Μ繧ケ繝医∈霑ス蜉&#65533; nexts->insert(multimap<int, int>::value_type(field[p + FIELD_WIDTH], p + FIELD_WIDTH)); } if(field[p - FIELD_WIDTH] == 0){ // 騾夐℃貂医∩ }else if(field[p - FIELD_WIDTH] <= r){ // 縺昴&#65533;驛ィ螻九↓蜈・繧&#65533; count += fill(r, p - FIELD_WIDTH, nexts); }else{ // 蠕後〒蜈・繧九Μ繧ケ繝医∈霑ス蜉&#65533; nexts->insert(multimap<int, int>::value_type(field[p - FIELD_WIDTH], p - FIELD_WIDTH)); } return count; } void calculateLevel(int r, list<LevelRoomRelation> *answer){ // 蝠城。後&#65533;蜈・蜉&#65533; int w, h, x, y; scanf("%d%d%d%d", &w, &h, &x, &y); memset(field, 0, sizeof(int) * FIELD_SIZE); for(int i = 1; i <= h; i++){ for(int j = 1; j <= w; j++){ scanf("%d", &(field[i * FIELD_WIDTH + j])); } } // 險育ョ励☆繧&#65533; int currentLevel = 0, currentRoomCount = 0, remains = w * h; multimap<int, int> nexts; nexts.insert(multimap<int, int>::value_type(1, x + y * FIELD_WIDTH)); multimap<int, int>::iterator front = nexts.begin(); while(currentRoomCount < r && remains > 0){ while(front != nexts.end()){ currentLevel = field[(*front).second]; if(currentLevel != 0){ break; } multimap<int, int>::iterator tmp = front; front++; nexts.erase(tmp); } while(front != nexts.end() && field[(*front).second] <= currentLevel){ if(field[(*front).second] != 0){ // 縺セ縺&#65533;&#65533;驕弱@縺ヲ縺&#65533;↑縺&#65533;&#65533;蜷&#65533; int fillResult = fill(currentLevel, (*front).second, &nexts); currentRoomCount += fillResult; remains -= fillResult; } multimap<int, int>::iterator tmp = front; front++; nexts.erase(tmp); } LevelRoomRelation lrr; lrr.level = currentLevel; lrr.room = currentRoomCount; answer->push_back(lrr); //cout << "Level: " << (lrr).level << " / " << "Room: " << (lrr).room << endl; } } int main(){ while(true){ int r; if(!~scanf("%d", &r)){ break; } if(r == 0){ break; } LevelRoomRelation lrr; lrr.level = 0; lrr.room = 0; list<LevelRoomRelation> office1; calculateLevel(r, &office1); office1.insert(office1.begin(), lrr); { // cout << "Office1 dump:" << endl; list<LevelRoomRelation>::iterator it = office1.begin(); while(it != office1.end()){ // cout << "Level: " << (*it).level << " / " << "Room: " << (*it).room << endl; it++; } } list<LevelRoomRelation> office2; calculateLevel(r, &office2); office2.insert(office2.begin(), lrr); { // cout << "Office2 dump:" << endl; list<LevelRoomRelation>::iterator it = office2.begin(); while(it != office2.end()){ // cout << "Level: " << (*it).level << " / " << "Room: " << (*it).room << endl; it++; } } int minLevel = 0x7fffffff; list<LevelRoomRelation>::iterator it1 = office1.begin(), it2 = office2.end(); int level2, level1 = 0; int roomCount2, roomCount1 = 0, roomCount; while(true){ if(it2 == office2.begin()){ if(it1 == office1.end()){ break; } }else{ it2--; } level2 = (*it2).level; roomCount2 = (*it2).room; roomCount = roomCount2 + roomCount1; while(it1 != office1.end() && roomCount < r){ roomCount1 = (*it1).room; roomCount = roomCount2 + roomCount1; level1 = (*it1).level; it1++; } // cout << "office1: " << level1 << " / office2: " << level2 << endl; if(minLevel > (level2 + level1)){ minLevel = level2 + level1; } } cout << minLevel << endl; } return 0; }
a.cc: In function 'void calculateLevel(int, std::__cxx11::list<LevelRoomRelation>*)': a.cc:39:24: error: 'w' was not declared in this scope 39 | scanf("%d%d%d%d", &w, &h, &x, &y); | ^ a.cc:39:28: error: 'h' was not declared in this scope 39 | scanf("%d%d%d%d", &w, &h, &x, &y); | ^ a.cc:39:32: error: 'x' was not declared in this scope 39 | scanf("%d%d%d%d", &w, &h, &x, &y); | ^ a.cc:39:36: error: 'y' was not declared in this scope 39 | scanf("%d%d%d%d", &w, &h, &x, &y); | ^ a.cc:50:11: error: 'currentRoomCount' was not declared in this scope 50 | while(currentRoomCount < r && remains > 0){ | ^~~~~~~~~~~~~~~~ a.cc:50:35: error: 'remains' was not declared in this scope 50 | while(currentRoomCount < r && remains > 0){ | ^~~~~~~ a.cc:52:13: error: 'currentLevel' was not declared in this scope 52 | currentLevel = field[(*front).second]; | ^~~~~~~~~~~~ a.cc:58:65: error: 'currentLevel' was not declared in this scope 58 | while(front != nexts.end() && field[(*front).second] <= currentLevel){ | ^~~~~~~~~~~~ a.cc:60:37: error: 'fillResult' was not declared in this scope 60 | currentRoomCount += fillResult; | ^~~~~~~~~~ a.cc:68:21: error: 'currentLevel' was not declared in this scope 68 | lrr.level = currentLevel; | ^~~~~~~~~~~~
s828564817
p00466
Java
#include <stdio.h> int main(void) { int goukei, i, n; scanf("%d", &goukei); for(i = 0; i < 9; i++){ scanf("%d", &n); goukei = goukei - n; } printf("%d\n", goukei); return 0; }
Main.java:1: error: illegal character: '#' #include <stdio.h> ^ Main.java:1: error: class, interface, enum, or record expected #include <stdio.h> ^ Main.java:5: error: class, interface, enum, or record expected scanf("%d", &goukei); ^ Main.java:6: error: class, interface, enum, or record expected for(i = 0; i < 9; i++){ ^ Main.java:6: error: class, interface, enum, or record expected for(i = 0; i < 9; i++){ ^ Main.java:6: error: class, interface, enum, or record expected for(i = 0; i < 9; i++){ ^ Main.java:8: error: class, interface, enum, or record expected goukei = goukei - n; ^ Main.java:9: error: class, interface, enum, or record expected } ^ Main.java:11: error: class, interface, enum, or record expected return 0; ^ Main.java:12: error: class, interface, enum, or record expected } ^ 10 errors
s117229057
p00466
Java
import java.util.*; public class Myon { Myon(){} public static void main(String[] args) { new Myon().run(); } public void run(){ Scanner cin = new Scanner(System.in); while(true){ int a = cin.nextInt(); for(int i=0;i<9;i++) a -= cin.nextInt(); System.out.println(a); } } // END CUT HERE }
Main.java:3: error: class Myon is public, should be declared in a file named Myon.java public class Myon { ^ 1 error
s033668127
p00466
C
#include<stdio.h> int main(void) { int a,s; int i,n,x; while(1){ scanf("%d",&n); if(n==0){ break; } s=0 for(i=0;i<9;i++){ scanf("%d",&a); s+=a; } x=n-s; } printf("%d\n",x); return 0; }
main.c: In function 'main': main.c:11:20: error: expected ';' before 'for' 11 | s=0 | ^ | ; 12 | for(i=0;i<9;i++){ | ~~~
s501658819
p00466
C
#include<stdio.h> int main(void) { int a,s; int i,n,x; while(1){ scanf("%d",&n); if(n==0){ break; } s=0 for(i=0;i<9;i++){ scanf("%d",&a); s+=a; } x=n-s; printf("%d\n",x); } return 0; }
main.c: In function 'main': main.c:11:20: error: expected ';' before 'for' 11 | s=0 | ^ | ; 12 | for(i=0;i<9;i++){ | ~~~
s852084893
p00466
C
#include<stdio.h> int main(void) { int a,s; int i,n,x; while(1){ scanf("%d",&n); if(n==0){ break; } s=0 for(i=0;i<9;i++){ scanf("%d",&a); s+=a; } x=n-s; printf("%d\n",x); } return 0; }
main.c: In function 'main': main.c:11:20: error: expected ';' before 'for' 11 | s=0 | ^ | ; 12 | for(i=0;i<9;i++){ | ~~~
s498169902
p00466
C
#include<stdio.h> int main(){ int a[10],i; scanf("%d",&a[0]); if(&a[0] =0){ goto exit; for(i=0;i<9;i++){ scanf("%d",&a[i+1]); } printf("%d",a[0]-a[1]-a[2]-a[3]-a[4]-a[5]-a[6]-a[7]-a[8]-a[9]); exit : return(0); }
main.c: In function 'main': main.c:5:12: error: lvalue required as left operand of assignment 5 | if(&a[0] =0){ | ^ main.c:13:1: error: expected declaration or statement at end of input 13 | } | ^
s896511479
p00466
C
9850 1050 800 420 380 600 820 2400 1800 980
main.c:1:1: error: expected identifier or '(' before numeric constant 1 | 9850 | ^~~~