submission_id stringlengths 10 10 | problem_id stringlengths 6 6 | language stringclasses 3 values | code stringlengths 1 522k | compiler_output stringlengths 43 10.2k |
|---|---|---|---|---|
s532360590 | p00232 | C++ | #include<iostream>
#include<cstdio>
using namespace std;
#define MAX 100
#define MMAX 5001
int X, Y, Z, A[MAX], V[MAX], E[MAX];
void compute() {
float P[MMAX][MAX];
for (int i = 0; i < MMAX; i++) {
for (int j = 0; j <= Y; j++)
P[i][j] = 0;
}
P[0][0] = 1.0;
int np, nv;
for (int j = 0; j < Y; j++) {
for (int i = 0; i < MMAX; i++) {
if (P[i][j] == 0)
continue;
for (int k = 0; k < X; k++) {
np = min(Y, j + V[k]);
nv = i;
if (E[np] == 1) {
np = min(Y, np + A[np]);
} else if (E[np] == 2) {
nv = i + A[np];
} else if (E[np] == 3) {
nv = max(0, i - A[np]);
}
P[nv][np] += P[i][j] * (1.0 / X);
}
}
}
double ex = 0;
for (int i = 0; i < MMAX; i++)
ex += P[i][Y] * i;
cout << (int) ex << endl;
}
void main() {
int n, e, a;
while(1) {
cin >> X >> Y >> Z;
if ( X == 0 && Y == 0 && Z == 0 ) break;
for ( int i = 0; i <= Y; i++ ) A[i] = E[i] = 0;
for ( int i = 0; i < X; i++ ) cin >> V[i];
for ( int i = 0; i < Z; i++ ) {
cin >> n >> e >> a;
A[n] = a;
E[n] = e;
}
compute();
}
return 0;
} | a.cc:38:1: error: '::main' must return 'int'
38 | void main() {
| ^~~~
|
s305224299 | p00232 | C++ | #include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
enum {GO=1,GET=2,LOST=3};
/*
[bgÍ4íÞ
}XÌy <= 50
50 * 50 * (100*50) * 4
dp[ith][jth turn][syojikin] = p^[
*/
const int N = 53;
const int M = 5001;
ll dp[N][2][M];
//event,eventvalue
//¡ñæÌ}XÉiÞ±ÆÍȢƼè·éB
double solve(int n,int X,int *rt,int *event,int *eval,int sum){
rep(i,n+1)rep(j,2)rep(k,M)dp[i][j][k] = 0;
dp[0][0][0] = 1;
double prob = 1/(double)X;
double ret = 0;
rep(j,n+1){//turn
bool isupd=false;
rep(i,n){//pos
rep(k,sum+1){//money
if (dp[i][0][k] == 0)continue;
rep(l,X){
int next = i + rt[l];
int nextm=k;
while(next < n && event[next] == 1)next += eval[next];
if (next < n){
if (event[next] == 2){
nextm += eval[next];
}else if (event[next] == 3){
nextm -= eval[next];
}
}
next = min(next,n);
nextm= max(0,nextm);
isupd=true;
dp[next][1][nextm] += dp[i][0][k];
}
}
}
rep(k,sum+1){
ret += (dp[n][1][k]*prob)* k;
}
prob *= (1/(double)X);
rep(i,n)rep(k,sum+1){
dp[i][0][k] = dp[i][1][k];
dp[i][1][k] = 0;
}
rep(k,sum+1)dp[n][0][k] = 0,dp[n][1][k] = 0;
//if (!isupd)break;
}
return ret;
}
main(){
int X,n,z;
while(cin>>X>>n>>z && X){
int event[n],eval[n],rt[X];
rep(i,n)event[i] = 0;
rep(i,X)cin>>rt[i];
int sum = 0;
rep(i,z){
int tmp;cin>>tmp;
cin>>event[tmp]>>eval[tmp];
if (event[tmp] == 2)sum += eval[tmp];
}
sum++;
double ans = floor(solve(n,X,rt,event,eval,sum)+1e-10);
printf("%lld\n",(ll)ans);
}
} | a.cc:62:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
62 | main(){
| ^~~~
a.cc: In function 'int main()':
a.cc:75:18: error: 'floor' was not declared in this scope
75 | double ans = floor(solve(n,X,rt,event,eval,sum)+1e-10);
| ^~~~~
|
s667081633 | p00232 | C++ | #include <cstdio>
#include <cstring>
#include <map>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
int x, y, z, n, a, e;
int v[4];
P event[55];
double dp[55][5050][2];
//double dp[55][5050];
int main() {
while (scanf("%d%d%d",&x,&y,&z)) {
if (!x&&!y&&!z) break;
fill(event, event+55, P(0,0));
memset(dp, 0, sizeof(dp));
for (int i=0; i<x; i++) scanf("%d",&v[i]);
for (int i=0; i<z; i++) {
scanf("%d%d%d",&n,&a,&e);
event[n]=P(a,e);
// event[n]=P((a==1),a==3?-e:e);
}
dp[0][0][0]=1.0;
// dp[0][0]=1.0;
for (int i=0; i<y; i++) {
if (event[i].first==1) {
int next=min(y,i+event[i].second);
for (int j=0; j<5050; j++) {
dp[next][j][1]+=dp[i][j][0];
for (int k=0; k<x; k++) {
int next2=min(y,i+v[k]);
dp[next2][j][0]+=dp[i][j][1]/x;
}
}
} else {
for (int j=0; j<5050; j++) {
if (dp[i][j][0]==0.0&&dp[i][j][1]==0.0) continue;
for (int k=0; k<x; k++) {
int next=min(y,i+v[k]);
if (event[i].first==2) {
dp[next][j+event[i].second][0]+=dp[i][j][0]/x;
dp[next][j][0]+=dp[i][j][1]/x;
} else if (event[i].first==3) {
dp[next][max(0,j-event[i].second)][0]+=dp[i][j][0]/x;
dp[next][j][0]+=dp[i][j][1]/x;
} else {
dp[next][j][0]+=(dp[i][j][0]+dp[i][j][1])/x;
}
}
}
}
/* for (int j=0; j<5050; j++) {
if (dp[i][j]==0.0) continue;
for (int k=0; k<x; k++) {
int nv=min(y,i+v[k]);
int np=j;
if (nv<y) {
if (event[nv].first) nv+=event[nv].second;
else np+=event[nv].second;
}
dp[min(y,nv)][max(0,np)]+=dp[i][j]/x;
}
}
}*/
double res=0.0;
for (int k=0; k<5050; k++) res+=(dp[y][k][0]+dp[y][k][1])*k;
// for (int k=0; k<5050; k++) res+=dp[y][k]*k;
// printf("%.0f\n",res);
printf("%d\n",(int)res);
}
} | a.cc: In function 'int main()':
a.cc:90:2: error: expected '}' at end of input
90 | }
| ^
a.cc:21:12: note: to match this '{'
21 | int main() {
| ^
|
s381185263 | p00232 | C++ | #include "stdafx.h"
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
int x,y,z;
int invN[51],invE[51],invA[51],le[5];
long double dp[5001][51];
using namespace std;
void life(int m,int n){
int a,b,c;
int next,gm;
int flag=1;
if(n==y)return;
//ルーレットを回す
for(a=0;a<x;a++){
next=n+le[a];
//ゴール
if(next>=y){
dp[m][y]+=dp[m][n]/x;
}else{
//イベントマスにとまったか
flag=0;
for(b=0;b<z;b++){
if(next==invN[b]){
flag=1;
//イベントマスに止まった
if(invE[b]==1){
c=next+invA[b];
if(c>=y)c=y;
dp[m][c]+=dp[m][n]/x;
life(m,c);
}
if(invE[b]==2){
gm=m+invA[b];
dp[gm][next]+=dp[m][n]/x;
life(gm,next);
}
if(invE[b]==3){
gm=m-invA[b];
if(gm<0)gm=0;
dp[gm][next]+=dp[m][n]/x;
life(gm,next);
}
}
}
//イベントマスに止まらなかった
if(flag==0){
dp[m][next]+=dp[m][n]/x;
life(m,next);
}
}
}
}
int main(void){
int a,b;
int ans=0;
while(1){
for(b=0;b<5001;b++)for(a=0;a<51;a++)dp[b][a]=0.0;
dp[0][0]=1;
ans=0;
cin >> x >> y >> z;
for(a=0;a<x;a++)cin >> le[a];
for(a=0;a<z;a++)cin >> invN[a] >> invE[a] >> invA[a];
life(0,0);
for(a=0;a<5001;a++)ans+=a*dp[a][y];
cout << ans <<endl;
}
return 0;
} | a.cc:1:10: fatal error: stdafx.h: No such file or directory
1 | #include "stdafx.h"
| ^~~~~~~~~~
compilation terminated.
|
s920516953 | p00232 | C++ | int x,y,z;
int invN[51],invE[51],invA[51],le[5];
double dp[5001][51];
double ans=0;
using namespace std;
void life(int m,int n){
int a,b,c;
int next,gm;
int flag=1;
if(n==y)return;
//ルーレットを回す
for(a=0;a<x;a++){
next=n+le[a];
//ゴール
if(next>=y){
ans+=m*dp[m][n]/x;
}else{
//イベントマスにとまったか
flag=0;
for(b=0;b<z;b++){
if(next==invN[b]){
flag=1;
//イベントマスに止まった
if(invE[b]==1){
c=next+invA[b];
if(c>=y)c=y;
dp[m][c]+=dp[m][n]/x;
life(m,c);
}
if(invE[b]==2){
gm=m+invA[b];
dp[gm][next]+=dp[m][n]/x;
life(gm,next);
}
if(invE[b]==3){
gm=m-invA[b];
if(gm<0)gm=0;
dp[gm][next]+=dp[m][n]/x;
life(gm,next);
}
}
}
//イベントマスに止まらなかった
if(flag==0){
dp[m][next]+=dp[m][n]/x;
life(m,next);
}
}
}
}
int main(void){
int a,b;
while(1){
dp[0][0]=1;
ans=0.0;
cin >> x >> y >> z;
if(x==0)break;
for(b=0;b<=y*100;b++)for(a=1;a<=y;a++)dp[b][a]=0.0;
for(a=0;a<x;a++)cin >> le[a];
for(a=0;a<z;a++)cin >> invN[a] >> invE[a] >> invA[a];
life(0,0);
cout << (int)ans << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:60:17: error: 'cin' was not declared in this scope
60 | cin >> x >> y >> z;
| ^~~
a.cc:1:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
+++ |+#include <iostream>
1 | int x,y,z;
a.cc:66:17: error: 'cout' was not declared in this scope
66 | cout << (int)ans << endl;
| ^~~~
a.cc:66:17: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:66:37: error: 'endl' was not declared in this scope
66 | cout << (int)ans << endl;
| ^~~~
a.cc:1:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
+++ |+#include <ostream>
1 | int x,y,z;
|
s675371312 | p00232 | C++ | #include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0;i < n;i++)
vector<int> V;
struct Cell
{
int N, E, A;
};
vector<Cell> cells;
float memo[50][100 * 50];
float rec(int current, int patternNum, int money) {
if(memo[current][money] != -1) return memo[current][money];
//cout << "current " << current << ' ' << patternNum << endl;
if(current >= cells.size() - 1) {
//cout << "goal! " << patternNum << ' ' << money << endl;
return 1.0 * money / patternNum;
}
Cell &cell = cells[current];
switch(cell.E) {
case 1:
current += cell.A;
break;
case 2:
money += cell.A;
break;
case 3:
money = max(0, money - cell.A);
break;
}
float ret = 0;
rep(i, V.size()) {
ret += rec(current + V[i], patternNum * V.size(), money);
}
return ret;
}
int main() {
int X, Y, Z;
while(true) {
cin >> X >> Y >> Z;
if(!X && !Y && !Z) break;
V = vector<int>(X);
rep(i, X) cin >> V[i];
Cell zero = {0, 0, 0};
cells = vector<Cell>(Y + 1, zero);
rep(i, Z) {
Cell cell;
cin >> cell.N >> cell.E >> cell.A;
cells[cell.N] = cell;
}
memset(memo, -1, 50 * 100 * 50 * sizeof(float));
cout << (int)rec(0, 1, 0) << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:63:9: error: 'memset' was not declared in this scope
63 | memset(memo, -1, 50 * 100 * 50 * sizeof(float));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include <vector>
+++ |+#include <cstring>
3 | using namespace std;
|
s334126656 | p00233 | C++ | #include<iostream>
using namespace std;
 
int main(){
  int n;
 
  while(cin >> n && n){
    int res = 0,k=0,tmp = 1;
    while(n){
      res += ((n%10)+10)%10 * tmp;
      if(n%10<0)n-=10;
      
      tmp *= 10;
      n /= -10;
      k++;
    }
    cout << res << endl;
  }
} | a.cc:3:2: error: stray '#' in program
3 |  
| ^
a.cc:5:2: error: stray '#' in program
5 |   int n;
| ^
a.cc:5:8: error: stray '#' in program
5 |   int n;
| ^
a.cc:6:2: error: stray '#' in program
6 |  
| ^
a.cc:7:2: error: stray '#' in program
7 |   while(cin >> n && n){
| ^
a.cc:7:8: error: stray '#' in program
7 |   while(cin >> n && n){
| ^
a.cc:8:2: error: stray '#' in program
8 |     int res = 0,k=0,tmp = 1;
| ^
a.cc:8:8: error: stray '#' in program
8 |     int res = 0,k=0,tmp = 1;
| ^
a.cc:8:14: error: stray '#' in program
8 |     int res = 0,k=0,tmp = 1;
| ^
a.cc:8:20: error: stray '#' in program
8 |     int res = 0,k=0,tmp = 1;
| ^
a.cc:9:2: error: stray '#' in program
9 |     while(n){
| ^
a.cc:9:8: error: stray '#' in program
9 |     while(n){
| ^
a.cc:9:14: error: stray '#' in program
9 |     while(n){
| ^
a.cc:9:20: error: stray '#' in program
9 |     while(n){
| ^
a.cc:10:2: error: stray '#' in program
10 |       res += ((n%10)+10)%10 * tmp;
| ^
a.cc:10:8: error: stray '#' in program
10 |       res += ((n%10)+10)%10 * tmp;
| ^
a.cc:10:14: error: stray '#' in program
10 |       res += ((n%10)+10)%10 * tmp;
| ^
a.cc:10:20: error: stray '#' in program
10 |       res += ((n%10)+10)%10 * tmp;
| ^
a.cc:10:26: error: stray '#' in program
10 |       res += ((n%10)+10)%10 * tmp;
| ^
a.cc:10:32: error: stray '#' in program
10 |       res += ((n%10)+10)%10 * tmp;
| ^
a.cc:11:2: error: stray '#' in program
11 |       if(n%10<0)n-=10;
| ^
a.cc:11:8: error: stray '#' in program
11 |       if(n%10<0)n-=10;
| ^
a.cc:11:14: error: stray '#' in program
11 |       if(n%10<0)n-=10;
| ^
a.cc:11:20: error: stray '#' in program
11 |       if(n%10<0)n-=10;
| ^
a.cc:11:26: error: stray '#' in program
11 |       if(n%10<0)n-=10;
| ^
a.cc:11:32: error: stray '#' in program
11 |       if(n%10<0)n-=10;
| ^
a.cc:12:2: error: stray '#' in program
12 |       
| ^
a.cc:12:8: error: stray '#' in program
12 |       
| ^
a.cc:12:14: error: stray '#' in program
12 |       
| ^
a.cc:12:20: error: stray '#' in program
12 |       
| ^
a.cc:12:26: error: stray '#' in program
12 |       
| ^
a.cc:12:32: error: stray '#' in program
12 |       
| ^
a.cc:13:2: error: stray '#' in program
13 |       tmp *= 10;
| ^
a.cc:13:8: error: stray '#' in program
13 |       tmp *= 10;
| ^
a.cc:13:14: error: stray '#' in program
13 |       tmp *= 10;
| ^
a.cc:13:20: error: stray '#' in program
13 |       tmp *= 10;
| ^
a.cc:13:26: error: stray '#' in program
13 |       tmp *= 10;
| ^
a.cc:13:32: error: stray '#' in program
13 |       tmp *= 10;
| ^
a.cc:14:2: error: stray '#' in program
14 |       n /= -10;
| ^
a.cc:14:8: error: stray '#' in program
14 |       n /= -10;
| ^
a.cc:14:14: error: stray '#' in program
14 |       n /= -10;
| ^
a.cc:14:20: error: stray '#' in program
14 |       n /= -10;
| ^
a.cc:14:26: error: stray '#' in program
14 |       n /= -10;
| ^
a.cc:14:32: error: stray '#' in program
14 |       n /= -10;
| ^
a.cc:15:2: error: stray '#' in program
15 |       k++;
| ^
a.cc:15:8: error: stray '#' in program
15 |       k++;
| ^
a.cc:15:14: error: stray '#' in program
15 |       k++;
| ^
a.cc:15:20: error: stray '#' in program
15 |       k++;
| ^
a.cc:15:26: error: stray '#' in program
15 |       k++;
| ^
a.cc:15:32: error: stray '#' in program
15 |       k++;
| ^
a.cc:16:2: error: stray '#' in program
16 |     }
| ^
a.cc:16:8: error: stray '#' in program
16 |     }
| ^
a.cc:16:14: error: stray '#' in program
16 |     }
| ^
a.cc:16:20: error: stray '#' in program
16 |     }
| ^
a.cc:17:2: error: stray '#' in program
17 |     cout << res << endl;
| ^
a.cc:17:8: error: stray '#' in program
17 |     cout << res << endl;
| ^
a.cc:17:14: error: stray '#' in program
17 |     cout << res << endl;
| ^
a.cc:17:20: error: stray '#' in program
17 |     cout << res << endl;
| ^
a.cc:18:2: error: stray '#' in program
18 |   }
| ^
a.cc:18:8: error: stray '#' in program
18 |   }
| ^
a.cc:3:3: error: expected unqualified-id before numeric constant
3 |  
| ^~~
a.cc: In function 'int main()':
a.cc:5:3: error: lvalue required as unary '&' operand
5 |   int n;
| ^~~
a.cc:5:9: error: lvalue required as unary '&' operand
5 |   int n;
| ^~~
a.cc:6:3: error: lvalue required as unary '&' operand
6 |  
| ^~~
a.cc:7:3: error: lvalue required as unary '&' operand
7 |   while(cin >> n && n){
| ^~~
a.cc:7:9: error: lvalue required as unary '&' operand
7 |   while(cin >> n && n){
| ^~~
a.cc:8:3: error: lvalue required as unary '&' operand
8 |     int res = 0,k=0,tmp = 1;
| ^~~
a.cc:8:9: error: lvalue required as unary '&' operand
8 |     int res = 0,k=0,tmp = 1;
| ^~~
a.cc:8:15: error: lvalue required as unary '&' operand
8 |     int res = 0,k=0,tmp = 1;
| ^~~
a.cc:8:21: error: lvalue required as unary '&' operand
8 |     int res = 0,k=0,tmp = 1;
| ^~~
a.cc:9:3: error: lvalue required as unary '&' operand
9 |     while(n){
| ^~~
a.cc:9:9: error: lvalue required as unary '&' operand
9 |     while(n){
| ^~~
a.cc:9:15: error: lvalue required as unary '&' operand
9 |     while(n){
| ^~~
a.cc:9:21: error: lvalue required as unary '&' operand
9 |     while(n){
| ^~~
a.cc:10:3: error: lvalue required as unary '&' operand
10 |       res += ((n%10)+10)%10 * tmp;
| ^~~
a.cc:10:9: error: lvalue required as unary '&' operand
10 |       res += ((n%10)+10)%10 * tmp;
| ^~~
a.cc:10:15: error: lvalue required as unary '&' operand
10 |       res += ((n%10)+10)%10 * tmp;
| ^~~
a.cc:10:21: error: lvalue required as unary '&' operand
10 |       res += ((n%10)+10)%10 * tmp;
| ^~~
a.cc:10:27: error: lvalue required as unary '&' operand
10 |       res += ((n%10)+10)%10 * tmp;
| ^~~
a.cc:10:33: error: lvalue required as unary '&' operand
10 |       res += ((n%10)+10)%10 * tmp;
| ^~~
a.cc:11:3: error: lvalue required as unary '&' operand
11 |       if(n%10<0)n-=10;
| ^~~
a.cc:11:9: error: lvalue required as unary '&' operand
11 |       if(n%10<0)n-=10;
| ^~~
a.cc:11:15: error: lvalue required as unary '&' operand
11 |       if(n%10<0)n-=10;
| ^~~
a.cc:11:21: error: lvalue required as unary '&' operand
11 |       if(n%10<0)n-=10;
| ^~~
a.cc:11:27: error: lvalue required as unary '&' operand
11 |       if(n%10<0)n-=10;
| ^~~
a.cc:11:33: error: lvalue required as unary '&' operand
11 |       if(n%10<0)n-=10;
| ^~~
a.cc:12:3: error: lvalue required as unary '&' operand
12 |   & |
s109055079 | p00233 | C++ | #include<iostream>
using namespace std;
 
int main(){
  int n;
 
  while(cin >> n && n){
    int res = 0,k=0,tmp = 1;
    while(n){
      res += ((n%10)+10)%10 * tmp;
      if(n%10<0)n-=10;
      
      tmp *= 10;
      n /= -10;
      k++;
    }
    cout << res << endl;
  }
} | a.cc:3:2: error: stray '#' in program
3 |  
| ^
a.cc:5:2: error: stray '#' in program
5 |   int n;
| ^
a.cc:5:8: error: stray '#' in program
5 |   int n;
| ^
a.cc:6:2: error: stray '#' in program
6 |  
| ^
a.cc:7:2: error: stray '#' in program
7 |   while(cin >> n && n){
| ^
a.cc:7:8: error: stray '#' in program
7 |   while(cin >> n && n){
| ^
a.cc:8:2: error: stray '#' in program
8 |     int res = 0,k=0,tmp = 1;
| ^
a.cc:8:8: error: stray '#' in program
8 |     int res = 0,k=0,tmp = 1;
| ^
a.cc:8:14: error: stray '#' in program
8 |     int res = 0,k=0,tmp = 1;
| ^
a.cc:8:20: error: stray '#' in program
8 |     int res = 0,k=0,tmp = 1;
| ^
a.cc:9:2: error: stray '#' in program
9 |     while(n){
| ^
a.cc:9:8: error: stray '#' in program
9 |     while(n){
| ^
a.cc:9:14: error: stray '#' in program
9 |     while(n){
| ^
a.cc:9:20: error: stray '#' in program
9 |     while(n){
| ^
a.cc:10:2: error: stray '#' in program
10 |       res += ((n%10)+10)%10 * tmp;
| ^
a.cc:10:8: error: stray '#' in program
10 |       res += ((n%10)+10)%10 * tmp;
| ^
a.cc:10:14: error: stray '#' in program
10 |       res += ((n%10)+10)%10 * tmp;
| ^
a.cc:10:20: error: stray '#' in program
10 |       res += ((n%10)+10)%10 * tmp;
| ^
a.cc:10:26: error: stray '#' in program
10 |       res += ((n%10)+10)%10 * tmp;
| ^
a.cc:10:32: error: stray '#' in program
10 |       res += ((n%10)+10)%10 * tmp;
| ^
a.cc:11:2: error: stray '#' in program
11 |       if(n%10<0)n-=10;
| ^
a.cc:11:8: error: stray '#' in program
11 |       if(n%10<0)n-=10;
| ^
a.cc:11:14: error: stray '#' in program
11 |       if(n%10<0)n-=10;
| ^
a.cc:11:20: error: stray '#' in program
11 |       if(n%10<0)n-=10;
| ^
a.cc:11:26: error: stray '#' in program
11 |       if(n%10<0)n-=10;
| ^
a.cc:11:32: error: stray '#' in program
11 |       if(n%10<0)n-=10;
| ^
a.cc:12:2: error: stray '#' in program
12 |       
| ^
a.cc:12:8: error: stray '#' in program
12 |       
| ^
a.cc:12:14: error: stray '#' in program
12 |       
| ^
a.cc:12:20: error: stray '#' in program
12 |       
| ^
a.cc:12:26: error: stray '#' in program
12 |       
| ^
a.cc:12:32: error: stray '#' in program
12 |       
| ^
a.cc:13:2: error: stray '#' in program
13 |       tmp *= 10;
| ^
a.cc:13:8: error: stray '#' in program
13 |       tmp *= 10;
| ^
a.cc:13:14: error: stray '#' in program
13 |       tmp *= 10;
| ^
a.cc:13:20: error: stray '#' in program
13 |       tmp *= 10;
| ^
a.cc:13:26: error: stray '#' in program
13 |       tmp *= 10;
| ^
a.cc:13:32: error: stray '#' in program
13 |       tmp *= 10;
| ^
a.cc:14:2: error: stray '#' in program
14 |       n /= -10;
| ^
a.cc:14:8: error: stray '#' in program
14 |       n /= -10;
| ^
a.cc:14:14: error: stray '#' in program
14 |       n /= -10;
| ^
a.cc:14:20: error: stray '#' in program
14 |       n /= -10;
| ^
a.cc:14:26: error: stray '#' in program
14 |       n /= -10;
| ^
a.cc:14:32: error: stray '#' in program
14 |       n /= -10;
| ^
a.cc:15:2: error: stray '#' in program
15 |       k++;
| ^
a.cc:15:8: error: stray '#' in program
15 |       k++;
| ^
a.cc:15:14: error: stray '#' in program
15 |       k++;
| ^
a.cc:15:20: error: stray '#' in program
15 |       k++;
| ^
a.cc:15:26: error: stray '#' in program
15 |       k++;
| ^
a.cc:15:32: error: stray '#' in program
15 |       k++;
| ^
a.cc:16:2: error: stray '#' in program
16 |     }
| ^
a.cc:16:8: error: stray '#' in program
16 |     }
| ^
a.cc:16:14: error: stray '#' in program
16 |     }
| ^
a.cc:16:20: error: stray '#' in program
16 |     }
| ^
a.cc:17:2: error: stray '#' in program
17 |     cout << res << endl;
| ^
a.cc:17:8: error: stray '#' in program
17 |     cout << res << endl;
| ^
a.cc:17:14: error: stray '#' in program
17 |     cout << res << endl;
| ^
a.cc:17:20: error: stray '#' in program
17 |     cout << res << endl;
| ^
a.cc:18:2: error: stray '#' in program
18 |   }
| ^
a.cc:18:8: error: stray '#' in program
18 |   }
| ^
a.cc:3:3: error: expected unqualified-id before numeric constant
3 |  
| ^~~
a.cc: In function 'int main()':
a.cc:5:3: error: lvalue required as unary '&' operand
5 |   int n;
| ^~~
a.cc:5:9: error: lvalue required as unary '&' operand
5 |   int n;
| ^~~
a.cc:6:3: error: lvalue required as unary '&' operand
6 |  
| ^~~
a.cc:7:3: error: lvalue required as unary '&' operand
7 |   while(cin >> n && n){
| ^~~
a.cc:7:9: error: lvalue required as unary '&' operand
7 |   while(cin >> n && n){
| ^~~
a.cc:8:3: error: lvalue required as unary '&' operand
8 |     int res = 0,k=0,tmp = 1;
| ^~~
a.cc:8:9: error: lvalue required as unary '&' operand
8 |     int res = 0,k=0,tmp = 1;
| ^~~
a.cc:8:15: error: lvalue required as unary '&' operand
8 |     int res = 0,k=0,tmp = 1;
| ^~~
a.cc:8:21: error: lvalue required as unary '&' operand
8 |     int res = 0,k=0,tmp = 1;
| ^~~
a.cc:9:3: error: lvalue required as unary '&' operand
9 |     while(n){
| ^~~
a.cc:9:9: error: lvalue required as unary '&' operand
9 |     while(n){
| ^~~
a.cc:9:15: error: lvalue required as unary '&' operand
9 |     while(n){
| ^~~
a.cc:9:21: error: lvalue required as unary '&' operand
9 |     while(n){
| ^~~
a.cc:10:3: error: lvalue required as unary '&' operand
10 |       res += ((n%10)+10)%10 * tmp;
| ^~~
a.cc:10:9: error: lvalue required as unary '&' operand
10 |       res += ((n%10)+10)%10 * tmp;
| ^~~
a.cc:10:15: error: lvalue required as unary '&' operand
10 |       res += ((n%10)+10)%10 * tmp;
| ^~~
a.cc:10:21: error: lvalue required as unary '&' operand
10 |       res += ((n%10)+10)%10 * tmp;
| ^~~
a.cc:10:27: error: lvalue required as unary '&' operand
10 |       res += ((n%10)+10)%10 * tmp;
| ^~~
a.cc:10:33: error: lvalue required as unary '&' operand
10 |       res += ((n%10)+10)%10 * tmp;
| ^~~
a.cc:11:3: error: lvalue required as unary '&' operand
11 |       if(n%10<0)n-=10;
| ^~~
a.cc:11:9: error: lvalue required as unary '&' operand
11 |       if(n%10<0)n-=10;
| ^~~
a.cc:11:15: error: lvalue required as unary '&' operand
11 |       if(n%10<0)n-=10;
| ^~~
a.cc:11:21: error: lvalue required as unary '&' operand
11 |       if(n%10<0)n-=10;
| ^~~
a.cc:11:27: error: lvalue required as unary '&' operand
11 |       if(n%10<0)n-=10;
| ^~~
a.cc:11:33: error: lvalue required as unary '&' operand
11 |       if(n%10<0)n-=10;
| ^~~
a.cc:12:3: error: lvalue required as unary '&' operand
12 |   & |
s897544136 | p00233 | C++ | #include <iostream>
#include <string>
using namespace std;
#define rep(x,to) for(int x=0; x<(to); ++(x))
int main() {
int x;
while(cin >> x, x) {
string ans = "";
while(x) {
int tmp = (x % 10 + 10) % 10;
ans += '0' + tmp;
x = (x - tmp) / -10;
}
reverse(ans.begin(), ans.end());
cout << ans << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:15:9: error: 'reverse' was not declared in this scope
15 | reverse(ans.begin(), ans.end());
| ^~~~~~~
|
s944178959 | p00233 | C++ | #include<cstdio>
#include<string>
using namespace std;
typedef long long ll;
int main(){
for(ll n;scanf("%lld",&n),n;){
string ans;
while(n){
int dgt=n%10;
if(dgt<0) dgt+=10;
ans+=(dgt+'0');
n=(n-dgt)/-10;
}
reverse(ans.begin(),ans.end());
puts(ans.c_str());
}
return 0;
} | a.cc: In function 'int main()':
a.cc:17:17: error: 'reverse' was not declared in this scope
17 | reverse(ans.begin(),ans.end());
| ^~~~~~~
|
s822243074 | p00233 | C++ | char s[];n,a;main(r){for(;scanf("%d",&a)*a;puts(s+n))for(;a;a=(r-a)/10)r=(a%10+10)%10,s[--n]=r+48;} | a.cc:1:6: error: storage size of 's' isn't known
1 | char s[];n,a;main(r){for(;scanf("%d",&a)*a;puts(s+n))for(;a;a=(r-a)/10)r=(a%10+10)%10,s[--n]=r+48;}
| ^
a.cc:1:10: error: 'n' does not name a type
1 | char s[];n,a;main(r){for(;scanf("%d",&a)*a;puts(s+n))for(;a;a=(r-a)/10)r=(a%10+10)%10,s[--n]=r+48;}
| ^
a.cc:1:18: error: expected constructor, destructor, or type conversion before '(' token
1 | char s[];n,a;main(r){for(;scanf("%d",&a)*a;puts(s+n))for(;a;a=(r-a)/10)r=(a%10+10)%10,s[--n]=r+48;}
| ^
|
s336099790 | p00233 | C++ | #include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll rsum[]={1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000,10000000000};
//int dm[]={1,-1};
ll abs(ll a){ return a>0?a:-a; }
int main(){
ll n;
while(scanf("%lld",&n),n){
int st = 0;
ll res = 0;
if(n<0) st = 1;
n=abs(n);
int k=0;
bool tf = false;
while(n>0){
ll a = n%10;
if(!(st&1)){
if(tf){
a++;
}
tf=false;
} else {
if(a!=0){
a = 10-a;
tf=true;
}
}
res += a*rsum[k];
k++; st++;
n/=10;
}
if(tf){
res += rsum[k];
}
printf("%lld\n",res);
}
} | a.cc: In function 'int main()':
a.cc:17:10: error: call of overloaded 'abs(ll&)' is ambiguous
17 | n=abs(n);
| ~~~^~~
In file included from /usr/include/c++/14/cstdlib:79,
from /usr/include/c++/14/ext/string_conversions.h:43,
from /usr/include/c++/14/bits/basic_string.h:4154,
from /usr/include/c++/14/string:54,
from /usr/include/c++/14/bits/locale_classes.h:40,
from /usr/include/c++/14/bits/ios_base.h:41,
from /usr/include/c++/14/ios:44,
from /usr/include/c++/14/ostream:40,
from /usr/include/c++/14/iostream:41,
from a.cc:2:
/usr/include/stdlib.h:980:12: note: candidate: 'int abs(int)'
980 | extern int abs (int __x) __THROW __attribute__ ((__const__)) __wur;
| ^~~
a.cc:10:4: note: candidate: 'll abs(ll)'
10 | ll abs(ll a){ return a>0?a:-a; }
| ^~~
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); }
| ^~~
|
s660337846 | p00233 | C++ | #include<stdio.h>
long long solve(int x){
int ans[] = {9, 0, 9, 0, 9, 0, 9, 0, 9, 0, 9, 0};
long long now = -909090909090;
now = (long long)x - now;
int p = 11, i;
while(now){
ans[p] = abs(ans[p] - (now % 10));
p--;now/=10;
}
char res[100];
for(i = 0;i < 12;i++)res[i] = ans[i] + '0';
res[12] = 0;
sscanf(res, "%lld", &now);
return now;
}
int main(){
int n;
while(scanf("%d", &n), n)
printf("%lld\n", solve(n));
return 0;
} | a.cc: In function 'long long int solve(int)':
a.cc:11:18: error: 'abs' was not declared in this scope; did you mean 'ans'?
11 | ans[p] = abs(ans[p] - (now % 10));
| ^~~
| ans
|
s331073675 | p00234 | Java | import java.util.Scanner;
//Aizu Buried Treasure
public class Main{
int w, h, f, m, o;
long[][] a;
long[][][][] dp;
long get(int i, int j, int s, int rest){
if(i==h)return 0;
if(rest<1)return dp[i][j][s][rest] = 1L<<30;
if(dp[i][j][s][rest]!=-1)return dp[i][j][s][rest];
long x = 0;
int nr = rest;
int ns = s;
if((s&(1<<j))!=0){
ns -= 1<<j;
if(a[i][j]<0)x = -a[i][j];
else {
a[i][j] = Math.min(m, a[i][j]);
nr = (int)Math.min(m, nr+a[i][j]);
}
}
long min = 1<<30;
min = Math.min(min, x+get(i+1,j,(1<<w)-1,nr-1));
if(j>0)min = Math.min(min, x+get(i,j-1,ns,nr-1));
if(j<w-1)min = Math.min(min, x+get(i,j+1,ns,nr-1));
return dp[i][j][s][rest] = min;
}
void run(){
Scanner sc = new Scanner(System.in);
while(true){
w = sc.nextInt();
h = sc.nextInt();
if((w|h)==0)break;
f = sc.nextInt();
m = sc.nextInt();
o = sc.nextInt();
a = new long[h][w];
for(int i=0;i<h;i++)for(int j=0;j<w;j++)a[i][j]=sc.nextLong();
dp = new long[h][w][1<<w][m+1];
for(int i=0;i<h;i++)for(int j=0;j<w;j++)for(int k=0;k<1<<w;k++)for(int l=0;l<=m;l++)dp[i][j][k][l]=-1;
long min = 1<<30;
for(int j=0;j<w;j++)min = Math.min(min, get(0,j,(1<<w)-1,o-1));
System.out.println(min==1<<30||f<min?"NA":min);
}
}
public static void main(String[] args) {
new AOJ0234().run();
}
} | Main.java:53: error: cannot find symbol
new AOJ0234().run();
^
symbol: class AOJ0234
location: class Main
1 error
|
s052167095 | p00234 | C | W,H,m,c[10][10];DP[51][10][10][10][10];CalcO(o,x,y){c[x][y]>0?o+=c[x][y]:0;return o>0?o>m?m:o:0;}CalcF(f,x,y){return c[x][y]<0?f+c[x][y]:f;}Walk(x,y,l,r,o,f){int*p=&DP[o][y][x][l][r];f>*p?*p=f:0;}Dig(x,y,l,r,o,f){Walk(x,y,l,r,CalcO(o-1,x,y),CalcF(f,x,y));}main(){int*p,x,y,g,d,v,f,o,l,r,f0;for(;scanf("%d%d%d%d%d",&W,&H,&f0,&m,&o)*W;memset(DP,!printf(f?"%d\n":"NA\n",f0-f),sizeof(*DP)*2)){rep(y,H)rep(x,W)scanf("%d",&c[x][y]);f0++;if(o>1)rep(x,W)DP[CalcO(o-1,x,0)][0][x][x][x]=CalcF(f0,x,0);rep(y,H-1)rep(g,W)for(o=m;o>1;o--)rep(d,2)rep(l,W-g)rep(v,g+1)if(r=l+g,p=&DP[o][y][x=d?l+v:r-v][l][r],f=*p){*p=0;Dig(x,y+1,x,x,o,f);x?x>l?Walk(x-1,y,l,r,o-1,f):Dig(x-1,y,x-1,r,o,f):0;x<W-1?x<r?Walk(x+1,y,l,r,o-1,f):Dig(x+1,y,l,x+1,o,f):0;}f=0;rep(x,W)rep(o,m)p=&DP[o+1][H-1][x][x][x],*p>f?f=*p:0,*p=0;}} | main.c:1:1: warning: data definition has no type or storage class
1 | W,H,m,c[10][10];DP[51][10][10][10][10];CalcO(o,x,y){c[x][y]>0?o+=c[x][y]:0;return o>0?o>m?m:o:0;}CalcF(f,x,y){return c[x][y]<0?f+c[x][y]:f;}Walk(x,y,l,r,o,f){int*p=&DP[o][y][x][l][r];f>*p?*p=f:0;}Dig(x,y,l,r,o,f){Walk(x,y,l,r,CalcO(o-1,x,y),CalcF(f,x,y));}main(){int*p,x,y,g,d,v,f,o,l,r,f0;for(;scanf("%d%d%d%d%d",&W,&H,&f0,&m,&o)*W;memset(DP,!printf(f?"%d\n":"NA\n",f0-f),sizeof(*DP)*2)){rep(y,H)rep(x,W)scanf("%d",&c[x][y]);f0++;if(o>1)rep(x,W)DP[CalcO(o-1,x,0)][0][x][x][x]=CalcF(f0,x,0);rep(y,H-1)rep(g,W)for(o=m;o>1;o--)rep(d,2)rep(l,W-g)rep(v,g+1)if(r=l+g,p=&DP[o][y][x=d?l+v:r-v][l][r],f=*p){*p=0;Dig(x,y+1,x,x,o,f);x?x>l?Walk(x-1,y,l,r,o-1,f):Dig(x-1,y,x-1,r,o,f):0;x<W-1?x<r?Walk(x+1,y,l,r,o-1,f):Dig(x+1,y,l,x+1,o,f):0;}f=0;rep(x,W)rep(o,m)p=&DP[o+1][H-1][x][x][x],*p>f?f=*p:0,*p=0;}}
| ^
main.c:1:1: error: type defaults to 'int' in declaration of 'W' [-Wimplicit-int]
main.c:1:3: error: type defaults to 'int' in declaration of 'H' [-Wimplicit-int]
1 | W,H,m,c[10][10];DP[51][10][10][10][10];CalcO(o,x,y){c[x][y]>0?o+=c[x][y]:0;return o>0?o>m?m:o:0;}CalcF(f,x,y){return c[x][y]<0?f+c[x][y]:f;}Walk(x,y,l,r,o,f){int*p=&DP[o][y][x][l][r];f>*p?*p=f:0;}Dig(x,y,l,r,o,f){Walk(x,y,l,r,CalcO(o-1,x,y),CalcF(f,x,y));}main(){int*p,x,y,g,d,v,f,o,l,r,f0;for(;scanf("%d%d%d%d%d",&W,&H,&f0,&m,&o)*W;memset(DP,!printf(f?"%d\n":"NA\n",f0-f),sizeof(*DP)*2)){rep(y,H)rep(x,W)scanf("%d",&c[x][y]);f0++;if(o>1)rep(x,W)DP[CalcO(o-1,x,0)][0][x][x][x]=CalcF(f0,x,0);rep(y,H-1)rep(g,W)for(o=m;o>1;o--)rep(d,2)rep(l,W-g)rep(v,g+1)if(r=l+g,p=&DP[o][y][x=d?l+v:r-v][l][r],f=*p){*p=0;Dig(x,y+1,x,x,o,f);x?x>l?Walk(x-1,y,l,r,o-1,f):Dig(x-1,y,x-1,r,o,f):0;x<W-1?x<r?Walk(x+1,y,l,r,o-1,f):Dig(x+1,y,l,x+1,o,f):0;}f=0;rep(x,W)rep(o,m)p=&DP[o+1][H-1][x][x][x],*p>f?f=*p:0,*p=0;}}
| ^
main.c:1:5: error: type defaults to 'int' in declaration of 'm' [-Wimplicit-int]
1 | W,H,m,c[10][10];DP[51][10][10][10][10];CalcO(o,x,y){c[x][y]>0?o+=c[x][y]:0;return o>0?o>m?m:o:0;}CalcF(f,x,y){return c[x][y]<0?f+c[x][y]:f;}Walk(x,y,l,r,o,f){int*p=&DP[o][y][x][l][r];f>*p?*p=f:0;}Dig(x,y,l,r,o,f){Walk(x,y,l,r,CalcO(o-1,x,y),CalcF(f,x,y));}main(){int*p,x,y,g,d,v,f,o,l,r,f0;for(;scanf("%d%d%d%d%d",&W,&H,&f0,&m,&o)*W;memset(DP,!printf(f?"%d\n":"NA\n",f0-f),sizeof(*DP)*2)){rep(y,H)rep(x,W)scanf("%d",&c[x][y]);f0++;if(o>1)rep(x,W)DP[CalcO(o-1,x,0)][0][x][x][x]=CalcF(f0,x,0);rep(y,H-1)rep(g,W)for(o=m;o>1;o--)rep(d,2)rep(l,W-g)rep(v,g+1)if(r=l+g,p=&DP[o][y][x=d?l+v:r-v][l][r],f=*p){*p=0;Dig(x,y+1,x,x,o,f);x?x>l?Walk(x-1,y,l,r,o-1,f):Dig(x-1,y,x-1,r,o,f):0;x<W-1?x<r?Walk(x+1,y,l,r,o-1,f):Dig(x+1,y,l,x+1,o,f):0;}f=0;rep(x,W)rep(o,m)p=&DP[o+1][H-1][x][x][x],*p>f?f=*p:0,*p=0;}}
| ^
main.c:1:7: error: type defaults to 'int' in declaration of 'c' [-Wimplicit-int]
1 | W,H,m,c[10][10];DP[51][10][10][10][10];CalcO(o,x,y){c[x][y]>0?o+=c[x][y]:0;return o>0?o>m?m:o:0;}CalcF(f,x,y){return c[x][y]<0?f+c[x][y]:f;}Walk(x,y,l,r,o,f){int*p=&DP[o][y][x][l][r];f>*p?*p=f:0;}Dig(x,y,l,r,o,f){Walk(x,y,l,r,CalcO(o-1,x,y),CalcF(f,x,y));}main(){int*p,x,y,g,d,v,f,o,l,r,f0;for(;scanf("%d%d%d%d%d",&W,&H,&f0,&m,&o)*W;memset(DP,!printf(f?"%d\n":"NA\n",f0-f),sizeof(*DP)*2)){rep(y,H)rep(x,W)scanf("%d",&c[x][y]);f0++;if(o>1)rep(x,W)DP[CalcO(o-1,x,0)][0][x][x][x]=CalcF(f0,x,0);rep(y,H-1)rep(g,W)for(o=m;o>1;o--)rep(d,2)rep(l,W-g)rep(v,g+1)if(r=l+g,p=&DP[o][y][x=d?l+v:r-v][l][r],f=*p){*p=0;Dig(x,y+1,x,x,o,f);x?x>l?Walk(x-1,y,l,r,o-1,f):Dig(x-1,y,x-1,r,o,f):0;x<W-1?x<r?Walk(x+1,y,l,r,o-1,f):Dig(x+1,y,l,x+1,o,f):0;}f=0;rep(x,W)rep(o,m)p=&DP[o+1][H-1][x][x][x],*p>f?f=*p:0,*p=0;}}
| ^
main.c:1:17: warning: data definition has no type or storage class
1 | W,H,m,c[10][10];DP[51][10][10][10][10];CalcO(o,x,y){c[x][y]>0?o+=c[x][y]:0;return o>0?o>m?m:o:0;}CalcF(f,x,y){return c[x][y]<0?f+c[x][y]:f;}Walk(x,y,l,r,o,f){int*p=&DP[o][y][x][l][r];f>*p?*p=f:0;}Dig(x,y,l,r,o,f){Walk(x,y,l,r,CalcO(o-1,x,y),CalcF(f,x,y));}main(){int*p,x,y,g,d,v,f,o,l,r,f0;for(;scanf("%d%d%d%d%d",&W,&H,&f0,&m,&o)*W;memset(DP,!printf(f?"%d\n":"NA\n",f0-f),sizeof(*DP)*2)){rep(y,H)rep(x,W)scanf("%d",&c[x][y]);f0++;if(o>1)rep(x,W)DP[CalcO(o-1,x,0)][0][x][x][x]=CalcF(f0,x,0);rep(y,H-1)rep(g,W)for(o=m;o>1;o--)rep(d,2)rep(l,W-g)rep(v,g+1)if(r=l+g,p=&DP[o][y][x=d?l+v:r-v][l][r],f=*p){*p=0;Dig(x,y+1,x,x,o,f);x?x>l?Walk(x-1,y,l,r,o-1,f):Dig(x-1,y,x-1,r,o,f):0;x<W-1?x<r?Walk(x+1,y,l,r,o-1,f):Dig(x+1,y,l,x+1,o,f):0;}f=0;rep(x,W)rep(o,m)p=&DP[o+1][H-1][x][x][x],*p>f?f=*p:0,*p=0;}}
| ^~
main.c:1:17: error: type defaults to 'int' in declaration of 'DP' [-Wimplicit-int]
main.c:1:40: error: return type defaults to 'int' [-Wimplicit-int]
1 | W,H,m,c[10][10];DP[51][10][10][10][10];CalcO(o,x,y){c[x][y]>0?o+=c[x][y]:0;return o>0?o>m?m:o:0;}CalcF(f,x,y){return c[x][y]<0?f+c[x][y]:f;}Walk(x,y,l,r,o,f){int*p=&DP[o][y][x][l][r];f>*p?*p=f:0;}Dig(x,y,l,r,o,f){Walk(x,y,l,r,CalcO(o-1,x,y),CalcF(f,x,y));}main(){int*p,x,y,g,d,v,f,o,l,r,f0;for(;scanf("%d%d%d%d%d",&W,&H,&f0,&m,&o)*W;memset(DP,!printf(f?"%d\n":"NA\n",f0-f),sizeof(*DP)*2)){rep(y,H)rep(x,W)scanf("%d",&c[x][y]);f0++;if(o>1)rep(x,W)DP[CalcO(o-1,x,0)][0][x][x][x]=CalcF(f0,x,0);rep(y,H-1)rep(g,W)for(o=m;o>1;o--)rep(d,2)rep(l,W-g)rep(v,g+1)if(r=l+g,p=&DP[o][y][x=d?l+v:r-v][l][r],f=*p){*p=0;Dig(x,y+1,x,x,o,f);x?x>l?Walk(x-1,y,l,r,o-1,f):Dig(x-1,y,x-1,r,o,f):0;x<W-1?x<r?Walk(x+1,y,l,r,o-1,f):Dig(x+1,y,l,x+1,o,f):0;}f=0;rep(x,W)rep(o,m)p=&DP[o+1][H-1][x][x][x],*p>f?f=*p:0,*p=0;}}
| ^~~~~
main.c: In function 'CalcO':
main.c:1:40: error: type of 'o' defaults to 'int' [-Wimplicit-int]
main.c:1:40: error: type of 'x' defaults to 'int' [-Wimplicit-int]
main.c:1:40: error: type of 'y' defaults to 'int' [-Wimplicit-int]
main.c: At top level:
main.c:1:98: error: return type defaults to 'int' [-Wimplicit-int]
1 | W,H,m,c[10][10];DP[51][10][10][10][10];CalcO(o,x,y){c[x][y]>0?o+=c[x][y]:0;return o>0?o>m?m:o:0;}CalcF(f,x,y){return c[x][y]<0?f+c[x][y]:f;}Walk(x,y,l,r,o,f){int*p=&DP[o][y][x][l][r];f>*p?*p=f:0;}Dig(x,y,l,r,o,f){Walk(x,y,l,r,CalcO(o-1,x,y),CalcF(f,x,y));}main(){int*p,x,y,g,d,v,f,o,l,r,f0;for(;scanf("%d%d%d%d%d",&W,&H,&f0,&m,&o)*W;memset(DP,!printf(f?"%d\n":"NA\n",f0-f),sizeof(*DP)*2)){rep(y,H)rep(x,W)scanf("%d",&c[x][y]);f0++;if(o>1)rep(x,W)DP[CalcO(o-1,x,0)][0][x][x][x]=CalcF(f0,x,0);rep(y,H-1)rep(g,W)for(o=m;o>1;o--)rep(d,2)rep(l,W-g)rep(v,g+1)if(r=l+g,p=&DP[o][y][x=d?l+v:r-v][l][r],f=*p){*p=0;Dig(x,y+1,x,x,o,f);x?x>l?Walk(x-1,y,l,r,o-1,f):Dig(x-1,y,x-1,r,o,f):0;x<W-1?x<r?Walk(x+1,y,l,r,o-1,f):Dig(x+1,y,l,x+1,o,f):0;}f=0;rep(x,W)rep(o,m)p=&DP[o+1][H-1][x][x][x],*p>f?f=*p:0,*p=0;}}
| ^~~~~
main.c: In function 'CalcF':
main.c:1:98: error: type of 'f' defaults to 'int' [-Wimplicit-int]
main.c:1:98: error: type of 'x' defaults to 'int' [-Wimplicit-int]
main.c:1:98: error: type of 'y' defaults to 'int' [-Wimplicit-int]
main.c: At top level:
main.c:1:141: error: return type defaults to 'int' [-Wimplicit-int]
1 | W,H,m,c[10][10];DP[51][10][10][10][10];CalcO(o,x,y){c[x][y]>0?o+=c[x][y]:0;return o>0?o>m?m:o:0;}CalcF(f,x,y){return c[x][y]<0?f+c[x][y]:f;}Walk(x,y,l,r,o,f){int*p=&DP[o][y][x][l][r];f>*p?*p=f:0;}Dig(x,y,l,r,o,f){Walk(x,y,l,r,CalcO(o-1,x,y),CalcF(f,x,y));}main(){int*p,x,y,g,d,v,f,o,l,r,f0;for(;scanf("%d%d%d%d%d",&W,&H,&f0,&m,&o)*W;memset(DP,!printf(f?"%d\n":"NA\n",f0-f),sizeof(*DP)*2)){rep(y,H)rep(x,W)scanf("%d",&c[x][y]);f0++;if(o>1)rep(x,W)DP[CalcO(o-1,x,0)][0][x][x][x]=CalcF(f0,x,0);rep(y,H-1)rep(g,W)for(o=m;o>1;o--)rep(d,2)rep(l,W-g)rep(v,g+1)if(r=l+g,p=&DP[o][y][x=d?l+v:r-v][l][r],f=*p){*p=0;Dig(x,y+1,x,x,o,f);x?x>l?Walk(x-1,y,l,r,o-1,f):Dig(x-1,y,x-1,r,o,f):0;x<W-1?x<r?Walk(x+1,y,l,r,o-1,f):Dig(x+1,y,l,x+1,o,f):0;}f=0;rep(x,W)rep(o,m)p=&DP[o+1][H-1][x][x][x],*p>f?f=*p:0,*p=0;}}
| ^~~~
main.c: In function 'Walk':
main.c:1:141: error: type of 'x' defaults to 'int' [-Wimplicit-int]
main.c:1:141: error: type of 'y' defaults to 'int' [-Wimplicit-int]
main.c:1:141: error: type of 'l' defaults to 'int' [-Wimplicit-int]
main.c:1:141: error: type of 'r' defaults to 'int' [-Wimplicit-int]
main.c:1:141: error: type of 'o' defaults to 'int' [-Wimplicit-int]
main.c:1:141: error: type of 'f' defaults to 'int' [-Wimplicit-int]
main.c: At top level:
main.c:1:197: error: return type defaults to 'int' [-Wimplicit-int]
1 | W,H,m,c[10][10];DP[51][10][10][10][10];CalcO(o,x,y){c[x][y]>0?o+=c[x][y]:0;return o>0?o>m?m:o:0;}CalcF(f,x,y){return c[x][y]<0?f+c[x][y]:f;}Walk(x,y,l,r,o,f){int*p=&DP[o][y][x][l][r];f>*p?*p=f:0;}Dig(x,y,l,r,o,f){Walk(x,y,l,r,CalcO(o-1,x,y),CalcF(f,x,y));}main(){int*p,x,y,g,d,v,f,o,l,r,f0;for(;scanf("%d%d%d%d%d",&W,&H,&f0,&m,&o)*W;memset(DP,!printf(f?"%d\n":"NA\n",f0-f),sizeof(*DP)*2)){rep(y,H)rep(x,W)scanf("%d",&c[x][y]);f0++;if(o>1)rep(x,W)DP[CalcO(o-1,x,0)][0][x][x][x]=CalcF(f0,x,0);rep(y,H-1)rep(g,W)for(o=m;o>1;o--)rep(d,2)rep(l,W-g)rep(v,g+1)if(r=l+g,p=&DP[o][y][x=d?l+v:r-v][l][r],f=*p){*p=0;Dig(x,y+1,x,x,o,f);x?x>l?Walk(x-1,y,l,r,o-1,f):Dig(x-1,y,x-1,r,o,f):0;x<W-1?x<r?Walk(x+1,y,l,r,o-1,f):Dig(x+1,y,l,x+1,o,f):0;}f=0;rep(x,W)rep(o,m)p=&DP[o+1][H-1][x][x][x],*p>f?f=*p:0,*p=0;}}
| ^~~
main.c: In function 'Dig':
main.c:1:197: error: type of 'x' defaults to 'int' [-Wimplicit-int]
main.c:1:197: error: type of 'y' defaults to 'int' [-Wimplicit-int]
main.c:1:197: error: type of 'l' defaults to 'int' [-Wimplicit-int]
main.c:1:197: error: type of 'r' defaults to 'int' [-Wimplicit-int]
main.c:1:197: error: type of 'o' defaults to 'int' [-Wimplicit-int]
main.c:1:197: error: type of 'f' defaults to 'int' [-Wimplicit-int]
main.c: At top level:
main.c:1:257: error: return type defaults to 'int' [-Wimplicit-int]
1 | W,H,m,c[10][10];DP[51][10][10][10][10];CalcO(o,x,y){c[x][y]>0?o+=c[x][y]:0;return o>0?o>m?m:o:0;}CalcF(f, |
s298717820 | p00234 | C++ | #include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>
using namespace std;
#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second
#define debug(x) #x << "=" << (x)
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif
typedef long long int lli;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;
const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1},dy[]={0,1,0};
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
os << "[";
for (const auto &v : vec) {
os << v << ",";
}
os << "]";
return os;
}
struct State{
int x,y,d,o,s;
State(int a,int b,int h,int e,int g):x(b),y(a),d(h),o(e),s(g){}
bool operator>(const State& s)const{
return d>s.d;
}
};
int W,H,f,m,o,c[10][10],d[10][10][51][1<<10],ans;
void Solve(){
fill_n((int*)d,10*10*51*(1<<10),INF);
ans=INF;
priority_queue<State,vector<State>,greater<State>> que;
REP(x,0,W){
int cost=0,oxy=o-1;
if(c[0][x]<0) cost=-c[0][x];
else oxy=min(m,oxy+c[0][x]);
if(cost>f||oxy==0) continue;
d[0][x][o][1<<x]=cost;
que.push(State(0,x,cost,oxy,1<<x));
}
while(!que.empty()){
State v=que.top();
que.pop();
int vy=v.y,vx=v.x,vd=v.d,vo=v.o,vs=v.s;
if(vy==H-1) ans=min(ans,d[vy][vx][vo][vs]);
if(d[vy][vx][vo][vs]<vd||vo<=1) continue;
/*
REP(i,0,3){
int ny=vy+dy[i],nx=vx+dx[i];
if(ny<0||H<=ny||nx<0||W<=nx) continue;
int cost=0,no=vo-1,ns=vs|(1<<nx);
if(ny!=vy||((vs>>nx)&1)==0){
if(c[ny][nx]<0) cost=-c[ny][nx];
else no=min(m,no+c[ny][nx]);
}
if(ny!=vy) ns=1<<nx;
if(vd+cost<d[ny][nx][no][ns]&&vd+cost<=f){
d[ny][nx][no][ns]=vd+cost;
que.push(State(ny,nx,d[ny][nx][no][ns],no,ns));
}
}
}
*/
}
int main(){
std::ios::sync_with_stdio(false);
std::cin.tie(0);
while(true){
cin >> W >> H;
if(W==0&&H==0) break;
cin >> f >> m >> o;
REP(y,0,H) REP(x,0,W) cin >> c[y][x];
Solve();
if(ans==INF) cout << "NA";
else cout << ans;
cout << endl;
}
return 0;
} | a.cc: In function 'void Solve()':
a.cc:98:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
98 | int main(){
| ^~
a.cc:98:9: note: remove parentheses to default-initialize a variable
98 | int main(){
| ^~
| --
a.cc:98:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:98:11: error: a function-definition is not allowed here before '{' token
98 | int main(){
| ^
a.cc:112:2: error: expected '}' at end of input
112 | }
| ^
a.cc:61:13: note: to match this '{'
61 | void Solve(){
| ^
|
s270076714 | p00234 | C++ | //Solution for aoj:0212 Highway Express Bus
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<functional>
using namespace std;
struct S {
int cost, x, y, o, xh;
S(int c, int in_x, int in_y, int in_o, int in_xh) : cost(c), x(in_x), y(in_y), o(in_o), xh(in_xh){}
bool operator<(const S &s) const {
return cost < s.cost;
}
};
const int INF = -1000000000, INF2=10000000;
int w, h, f, m, o, ans;
int stratum[11][11];
int c[11][11][51];
priority_queue<S> pq;
void dijkstra(){
int move[3] = { 1, -1, 1 };//?´y,?´x,?´x
while (!pq.empty()){
S a = pq.top();
pq.pop();
if (!a.o) continue;
for (int i = 0; i < 3; i++){
if (i&&a.x+move[i]<=w&&0<a.x+move[i]){
if (stratum[a.y][a.x+move[i]]< 0 && a.cost + stratum[a.y][a.x+move[i]] >= -f&&a.cost + stratum[a.y][a.x+move[i]]>c[a.y][a.x + move[i]][a.o - 1]){
c[a.y][a.x + move[i]][a.o - 1] = a.cost + stratum[a.y][a.x+move[i]];
pq.push({ c[a.y][a.x + move[i]][a.o - 1], a.x + move[i], a.y, a.o - 1 ,a.xh+move[i]});
}
else if (stratum[a.y][a.x+move[i]] > 0){
if (stratum[a.y][a.x + move[i]] + a.x - 1 >= m)
stratum[a.y][a.x + move[i]] = m - a.x + 2;
c[a.y][a.x + move[i]][a.o + stratum[a.y][a.x + move[i]] - 1] = a.cost;
pq.push({ c[a.y][a.x + move[i]][a.o + stratum[a.y][a.x + move[i]] - 1], a.x + move[i], a.y, a.o + stratum[a.y][a.x + move[i]] - 1, a.xh+move[i] });
//if (a.xh)
// for (int j = 1; j <= a.xh; j++)
// if (stratum[a.y][a.x+move[i]]>j)
// pq.push({ c[a.y][a.x + move[i]][a.o + stratum[a.y][a.x + move[i]] - 1], a.x + +move[i] + j, a.y, a.o + stratum[a.y][a.x + move[i]] - 1 - j, a.xh + move[i] });
//if (a.xh < 0)
// for (int j = -1; j <= a.xh; j--)
// if (stratum[a.y][a.x+move[i]]>-j)
// pq.push({ c[a.y][a.x + move[i]][a.o + stratum[a.y][a.x + move[i]] - 1], a.x + +move[i] + j, a.y, a.o + stratum[a.y][a.x + move[i]] - 1 + j, a.xh + move[i] });
}
}
else if(!i&&a.y+move[i]<=h){
if (stratum[a.y+move[i]][a.x] < 0 && a.cost + stratum[a.y+move[i]][a.x] >= -f&&a.cost+stratum[a.y+move[i]][a.x]>c[a.y+move[i]][a.x][a.o-1]){
c[a.y + move[i]][a.x][a.o - 1] = a.cost + stratum[a.y+move[i]][a.x];
pq.push({ c[a.y + move[i]][a.x][a.o - 1], a.x, a.y + move[i], a.o - 1, 0 });
}
else if (stratum[a.y+move[i]][a.x] > 0){
if (stratum[a.y+move[i]][a.x] + a.x - 1 >= m)
stratum[a.y+move[i]][a.x] = m - a.x + 2;
c[a.y + move[i]][a.x][a.o + stratum[a.y + move[i]][a.x] - 1] = a.cost;
pq.push({ c[a.y + move[i]][a.x][a.o + stratum[a.y + move[i]][a.x] - 1], a.x, a.y + move[i], a.o + stratum[a.y + move[i]][a.x] - 1, 0 });
//for (int j = 1; j <= a.xh; j++)
// if (stratum[a.y][a.x + move[i]]>j)
// pq.push({ c[a.y][a.x + move[i]][a.o + stratum[a.y][a.x + move[i]] - 1], a.x + +move[i] + j, a.y, a.o + stratum[a.y][a.x + move[i]] - 1 - j, a.xh + move[i] });
//if (a.xh<0)
// for (int j = -1; j <= a.xh; j--)
// if (stratum[a.y][a.x + move[i]]>-j)
// pq.push({ c[a.y][a.x + move[i]][a.o + stratum[a.y][a.x + move[i]] - 1], a.x + +move[i] + j, a.y, a.o + stratum[a.y][a.x + move[i]] - 1 + j, a.xh + move[i] });
}
}
}
}
}
int main(){
while (cin >> w >> h&&w&&h){
cin >> f >> m >> o;
memset(stratum, sizeof(stratum), 0);
ans=INF2;
for (int i = 1; i <= 10; i++)
for (int j = 1; j <= 10; j++)
fill(c[i][j], c[i][j] + 51, INF);
for (int i = 1; i <= h; i++)
for (int j = 1; j <= w; j++)
cin >> stratum[i][j];
for (int i = 1; i <= w; i++){
c[1][i][o - 1] = stratum[1][i];
pq.push({ stratum[1][i], i, 1, o - 1 ,0});
}
dijkstra();
for (int i = 1; i <= m; i++)
for (int j = 1; j <= w; j++)
if (c[h][j][i] != INF)
ans = min(ans, -c[h][j][i]);
if (ans!=INF2)
cout << ans << endl;
else
cout << "NA" << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:79:17: error: 'memset' was not declared in this scope
79 | memset(stratum, sizeof(stratum), 0);
| ^~~~~~
a.cc:7:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
6 | #include<functional>
+++ |+#include <cstring>
7 | using namespace std;
|
s182846689 | p00234 | C++ | #include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
int c[11][11], d[11][11][51][1 << 10];
int dx[]{ 1,0,0 }, dy[]{ 0,1,-1 };
struct st { int x, y, p, v, c; };
bool operator<(st a, st b) { return a.c > b.c; }
int main() {
int w, h;
while (scanf("%d%d", &w, &h), w) {
int f, m, o; scanf("%d%d%d", &f, &m, &o);
if (o == 0) { puts("NA"); goto g; }
rep(i, h)rep(j, w)scanf("%d", &c[i + 1][j]);
priority_queue<st>que;
memset(d, 0x3f, sizeof(d));
rep(i, w) {
d[0][i][o][0] = 0; que.push({ 0,i,o,0,0 });
}
while (!que.empty()) {
st p = que.top(); que.pop();
if (d[p.x][p.y][p.p][p.v] != p.c)continue;
rep(i, 3) {
int nx = p.x + dx[i], ny = p.y + dy[i];
if (!(nx <= h && 0 <= ny&&ny < w))continue;
int a = (c[nx][ny] > 0 && (!i || !(p.v >> ny & 1)) ? p.p - 1 + c[nx][ny] : p.p - 1);
if (a <= 0)continue;
if (a > m)a = m;
int e = (c[nx][ny] > 0 ? (p.v | 1 << ny) : p.v);
if (!i)e = 0;
int b = (c[nx][ny] < 0 ? p.c - c[nx][ny] : p.c);
if (d[nx][ny][a][e] > b) {
d[nx][ny][a][e] = b; que.push({ nx,ny,a,e,b });
}
}
}
int Min = INF;
rep(i, w)rep(j, m + 1)rep(k, 1 << w)Min = min(Min, d[h][i][j][k]);
if (Min > f)puts("NA");
else printf("%d\n", Min);
g:;
}
} | a.cc: In function 'int main()':
a.cc:42:9: error: jump to label 'g'
42 | g:;
| ^
a.cc:14:48: note: from here
14 | if (o == 0) { puts("NA"); goto g; }
| ^
a.cc:38:21: note: crosses initialization of 'int Min'
38 | int Min = INF;
| ^~~
a.cc:16:35: note: crosses initialization of 'std::priority_queue<st> que'
16 | priority_queue<st>que;
| ^~~
|
s936818244 | p00234 | C++ | #include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<vector>
#include<sstream>
#include<set>
#include<map>
#include<algorithm>
#include<cassert>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define fr(i,c) for(__typeof(c.begin()) i=c.begin();i!=c.end();i++)
#define pb push_back
#define mp make_pair
const int inf=1<<29;
int w,h,f,m,o;
int c[10][10],dp[11][10][51][10][10];
int main(){
while(cin>>w>>h,w){
cin>>f>>m>>o;
rep(i,h)rep(j,w)cin>>c[i][j];
rep(i,h+1)rep(j,w)rep(k,m+1)rep(l,w)rep(r,w)dp[i][j][k][l][r]=inf;
rep(i,w)dp[0][i][o][i][i]=0;
int ans=inf;
rep(i,h)rep(range,w)for(int k=m;k>1;k--)
rep(it,2)rep(l,w-range)rep(x,range+1){
int r=l+range,j=it?l+x:r-x,cost=dp[i][j][k][l][r];
if(cost==inf)continue;
if(c[i][j]>0){
int sanso=min(m,k-1+c[i][j]);
dp[i+1][j][sanso][j][j]=min(dp[i+1][j][sanso][j][j],cost);
}
else{
dp[i+1][j][k-1][j][j]=min(dp[i+1][j][k-1][j][j],cost-c[i][j]);
}
if(i==0)continue;
if(j>0){
if(l<j)dp[i][j-1][k-1][l][r]=min(dp[i][j-1][k-1][l][r],cost);
else{
if(c[i-1][j-1]>0){
int sanso=min(m,k-1+c[i-1][j-1]);
dp[i][j-1][sanso][l-1][r]=min(dp[i][j-1][sanso][l-1][r],cost);
}
else{
dp[i][j-1][k-1][l-1][r]=
min(dp[i][j-1][k-1][l-1][r],cost-c[i-1][j-1]);
}
}
}
if(j<w-1){
if(j<r)dp[i][j+1][k-1][l][r]=min(dp[i][j+1][k-1][l][r],cost);
else{
if(c[i-1][j+1]>0){
int sanso=min(m,k-1+c[i-1][j+1]);
dp[i][j+1][sanso][l][r+1]=min(dp[i][j+1][sanso][l][r+1],cost);
}
else{
dp[i][j+1][k-1][l][r+1]=
min(dp[i][j+1][k-1][l][r+1],cost-c[i-1][j+1]);
}
}
}
}
int ans=inf;
rep(i,w)for(int j=1;j<=m;j++)rep(l,w)rep(r,w)ans=min(ans,dp[h][i][j][l][r]);
if(ans>f)cout<<"NA"<<endl;
else cout<<ans<<endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:73:21: error: redeclaration of 'int ans'
73 | int ans=inf;
| ^~~
a.cc:32:21: note: 'int ans' previously declared here
32 | int ans=inf;
| ^~~
|
s124908691 | p00234 | C++ | #include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;
class Data
{
public:
int y, x, left, right, o;
Data(int y0, int x0, int left0, int right0, int o0)
{
y = y0;
x = x0;
left = left0;
right = right0;
o = o0;
}
int toInt()
{
return (((y * w + x) * w + left) * w + right) * (m+1) + o;
}
};
int w, h, f, m, o;
vector<vector<int> > cell;
int solve()
{
vector<int> dp(5 * (h+1) * w * w * w * (m+1), INT_MAX);
multimap<int, Data> mm;
for(int i=0; i<w; ++i){
Data d(0, i, 0, w-1, o);
dp[d.toInt()] = 0;
mm.insert(make_pair(0, d));
}
while(!mm.empty()){
int cost = mm.begin()->first;
Data d = mm.begin()->second;
mm.erase(mm.begin());
if(cost > dp[d.toInt()])
continue;
if(d.y == h)
return cost;
for(int i=-1; i<=1; ++i){
int cost1 = cost;
Data d1 = d;
-- d1.o;
d1.x += i;
if(d1.x < 0 || d1.x >= w || d1.o == 0)
continue;
if(i == 0){
++ d1.y;
d1.left = d1.x;
d1.right = d1.x - 1;
}
if(d1.x < d1.left || d1.x > d1.right){
d1.left = min(d1.left, d1.x);
d1.right = max(d1.right, d1.x);
if(cell[d1.y][d1.x] < 0){
cost1 += -cell[d1.y][d1.x];
}else{
d1.o += cell[d1.y][d1.x];
d1.o = min(d1.o, m);
}
}
if(cost1 < dp[d1.toInt()]){
dp[d1.toInt()] = cost1;
mm.insert(make_pair(cost1, d1));
}
}
}
return INT_MAX;
}
int main()
{
for(;;){
cin >> w >> h >> f >> m >> o;
if(w == 0 && h == 0)
return 0;
cell.assign(5*h+1, vector<int>(5*w, 0));
for(int i=0; i<h; ++i){
for(int j=0; j<w; ++j){
cin >> cell[i+1][j];
}
}
int ret = solve();
if(ret > f)
cout << "NA" << endl;
else
cout << ret << endl;
}
} | a.cc: In member function 'int Data::toInt()':
a.cc:34:23: error: 'w' was not declared in this scope
34 | return (((y * w + x) * w + left) * w + right) * (m+1) + o;
| ^
a.cc:34:58: error: 'm' was not declared in this scope; did you mean 'tm'?
34 | return (((y * w + x) * w + left) * w + right) * (m+1) + o;
| ^
| tm
|
s741516467 | p00234 | C++ | Aizu Buried Treasure | a.cc:1:1: error: 'Aizu' does not name a type
1 | Aizu Buried Treasure
| ^~~~
|
s562130417 | p00234 | C++ | #include <cstdio>
#include <cstdlib>
#include <queue>
using namespace std;
#define inf (1<<27)
struct State {
int x,y,l,r,o,c;
State(int xx,int yy,int ll,int rr,int oo,int cc) {
x=xx,y=yy,l=ll,r=rr,o=oo,c=cc;
}
};
bool operator > (const State &left,const State &right) {
return left.c>right.c;
}
int map[10][10];
int cost[10][10][10][10][51];
int main() {
int W,H,f,m,o;
while(scanf("%d %d",&W,&H),W) {
memset(cost,0x10,sizeof(cost));
scanf("%d %d %d",&f,&m,&o);
for(int j=0;j<H;j++)for(int i=0;i<W;i++) {
scanf("%d",&map[i][j]);
}
if(o==1){printf("NA\n");continue;}
priority_queue<State,vector<State>,greater<State> > que;
for(int i=0;i<W;i++) {
int oo=o-1,cc=0;
if(map[i][0]<0) {
cc-=map[i][0];
}else {
oo+=map[i][0];
if(oo>m)oo=m;
}
que.push(State(i,0,i,i,oo,cc));
}
int res=inf;
while(!que.empty()) {
State s=que.top();
que.pop();
s.o--;
if(s.y==(H-1)){res=s.c;break;}
if(s.o==0){continue;}
if(cost[s.x][s.y][s.l][s.r][s.o]<s.c){continue;}
State ns=s;
ns.y++;ns.l=ns.r=ns.x;
if(ns.y<H) {
if(map[ns.x][ns.y]>0) {
ns.o+=map[ns.x][ns.y];
if(ns.o>m)ns.o=m;
}else {
ns.c-=map[ns.x][ns.y];
}
if(cost[ns.x][ns.y][ns.l][ns.r][ns.o]>ns.c) {
cost[ns.x][ns.y][ns.l][ns.r][ns.o]=ns.c;
que.push(ns);
}
}
ns=s;
ns.x++;
if(ns.x<W) {
if(ns.x>ns.r) {
ns.r=ns.x;
if(map[ns.x][ns.y]>0) {
ns.o+=map[ns.x][ns.y];
if(ns.o>m)ns.o=m;
}else {
ns.c-=map[ns.x][ns.y];
}
}
if(cost[ns.x][ns.y][ns.l][ns.r][ns.o]>ns.c) {
cost[ns.x][ns.y][ns.l][ns.r][ns.o]=ns.c;
que.push(ns);
}
}
ns=s;
ns.x--;
if(ns.x>=0) {
if(ns.l>ns.x) {
ns.l=ns.x;
if(map[ns.x][ns.y]>0) {
ns.o+=map[ns.x][ns.y];
if(ns.o>m)ns.o=m;
}else {
ns.c-=map[ns.x][ns.y];
}
}
if(cost[ns.x][ns.y][ns.l][ns.r][ns.o]>ns.c) {
cost[ns.x][ns.y][ns.l][ns.r][ns.o]=ns.c;
que.push(ns);
}
}
}
if(res<=f)printf("%d\n",res);
else printf("NA\n");
}
} | a.cc: In function 'int main()':
a.cc:26:17: error: 'memset' was not declared in this scope
26 | memset(cost,0x10,sizeof(cost));
| ^~~~~~
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 |
|
s697626378 | p00234 | C++ | #include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
#define INF 1<<25
typedef struct n
{
int w,h,m,o,g[11][11];
}n;
struct Order
{
bool operator ()(n const& a, n const& b) const
{
return a.m<b.m;
}
};
int W,H,F,M,O,G[11][11],mv[4]={0,1,0,-1},f;
n cr(int h,int w,int o,int m,int g[11][11])
{
n ins;
ins.h=h;ins.w=w;
ins.m=m+(g[h][w]<0?g[h][w]:0);
ins.o=min(M,o-1+(g[h][w]>0?g[h][w]:0));
memcpy(ins.g,g,sizeof(ins.g));
ins.g[h][w]=0;
return ins;
}
int main()
{
for(;~scanf("%d%d%d%d%d",&W,&H,&F,&M,&O),W;)
{
for(int i=0;i<H;i++)
for(int j=0;j<W;j++)
scanf("%d",&G[i][j]);
priority_queue<n,vector<n>,Order>Q;
for(int i=0;i<W;i++)
{
n ins=cr(0,i,O,F,G);
Q.push(ins);
}
for(f=0;!Q.empty();)
{
n tmp=Q.top();Q.pop();
if(tmp.h==H-1)
{
printf("%d\n",F-tmp.m);
f=1;
break;
}
for(int i=0;i<3;i++)
{
int nh=tmp.h+mv[i];
int nw=tmp.w+mv[i+1];
if(0<=nw&&nw<W&&tmp.o>1)
{
int nc=tmp.m+(G[nh][nw]<0?G[nh][nw]:0);
if(nc>0)
{
n ins=cr(nh,nw,tmp.o,tmp.m,tmp.g);
Q.push(ins);
}
}
}
}
if(!f)puts("NA");
}
return 0;
} | a.cc: In function 'n cr(int, int, int, int, int (*)[11])':
a.cc:29:9: error: 'memcpy' was not declared in this scope
29 | memcpy(ins.g,g,sizeof(ins.g));
| ^~~~~~
a.cc:4:1: note: 'memcpy' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include<algorithm>
+++ |+#include <cstring>
4 | using namespace std;
|
s342297657 | p00235 | Java | import java.util.Scanner;
public class SaveBrian {
static int [][] map;
static int N;
static int total;
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int x,y;
while(sc.hasNext()){
N=sc.nextInt();
if(N==0){
sc.close();
break;
}
initialise(N);
//値の更新 N-1個分のデータがくる
for(int i=0;i<N-1;i++){
x=sc.nextInt()-1;
y=sc.nextInt()-1;
map[x][y]=sc.nextInt();
map[y][x]=map[x][y];
}
total=0;
search(0,0,-1);
System.out.println(total);
}
}
public static void initialise(int N){
map=new int [N][N];
for(int x=0;x<N;x++){
for(int y=0;y<N;y++){
map[x][y]=0;
}
}
}
public static void search(int np,int cost,int pp){
int count=0;
for(int x=0;x<N;x++){
if(map[x][np]!=0 && x!=pp){
count++;
}
}
if(count==0){
return;
}
total+=cost*2;
for(int x=0;x<N;x++){
if(map[x][np]!=0 && x!=pp){
search(x,map[x][np],np);
}
}
}
} | Main.java:3: error: class SaveBrian is public, should be declared in a file named SaveBrian.java
public class SaveBrian {
^
1 error
|
s053927042 | p00235 | Java | int n;
int t[22][22];
int solve(int idx){
int res = 0;
rep(i,n){
if(t[idx][i] > 0){
t[i][idx] = 0;
res = max(res,t[idx][i]+solve(i));
}
}
return res;
}
int main(void){
while(cin>>n,n){
memset(t,0,sizeof(t));
int sum = 0;
rep(i,n-1){
int a,b,cost;
cin>>a>>b>>cost;
t[a-1][b-1] = t[b-1][a-1] = cost;
sum += cost * 2;
}
rep(i,n){
int cnt=0, idx;
rep(j,n){
if(t[i][j] > 0 || t[i][j] == -1){
cnt++;
idx = j;
}
}
if(i != 0 && cnt == 1){
sum -= 2 * t[i][idx];
t[i][idx] = t[idx][i]= -1;
}
}
cout<<sum-solve(0)<<endl;
}
return 0;
} | Main.java:1: error: unnamed classes are a preview feature and are disabled by default.
int n;
^
(use --enable-preview to enable unnamed classes)
Main.java:2: error: class, interface, enum, or record expected
int t[22][22];
^
Main.java:6: error: ';' expected
rep(i,n){
^
Main.java:16: error: not a statement
while(cin>>n,n){
^
Main.java:22: error: not a statement
cin>>a>>b>>cost;
^
Main.java:41: error: not a statement
cout<<sum-solve(0)<<endl;
^
Main.java:15: error: <identifier> expected
int main(void){
^
Main.java:16: error: ')' expected
while(cin>>n,n){
^
Main.java:16: error: ';' expected
while(cin>>n,n){
^
Main.java:20: error: ';' expected
rep(i,n-1){
^
Main.java:27: error: ';' expected
rep(i,n){
^
Main.java:29: error: ';' expected
rep(j,n){
^
12 errors
|
s434055542 | p00235 | C | #include<stdio.h>
#include<vector>
using namespace std;
#define INF 100000
int d[20][20];
vector<int> ch[20];
bool term[20];
bool nterm[20];
bool used[20];
int min(int a,int b){return a<b?a:b;}
int main(){
int n;
int i,j,k;
while(1){
scanf("%d",&n);
if(n==0)return 0;
for(i=0;i<n;i++)for(j=0;j<n;j++)d[i][j]=INF;
for(i=0;i<n;i++){
term[i]=false;
nterm[i]=false;
used[i]=false;
}
for(i=0;i<n-1;i++){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
d[a-1][b-1]=c;
d[b-1][a-1]=c;
ch[a-1].push_back(b-1);
ch[b-1].push_back(a-1);
}
for(i=0;i<n;i++){
if(ch[i].size()==1){
term[i]=true;
nterm[ch[i][0]]=true;
}
}
for(i=0;i<n;i++)for(j=0;j<n;j++)for(k=0;k<n;k++)if(i!=j)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
int p=0;
int v;
int ans=0;
while(1){
v=-1;
for(i=0;i<n;i++)if(nterm[i]&&(v==-1||d[p][i]<d[p][v]))v=i;
if(v==-1)break;
ans+=d[p][v];
p=v;
for(i=0;i<ch[p].size();i++){
if(term[ch[p][i]]){
ch[p].erase(ch[p].begin()+i);
i--;
}
}
if(ch[p].empty())break;
if(ch[p].size()<=1){
nterm[p]=false;
term[p]=true;
nterm[ch[p][0]]=true;
}
}
printf("%d\n",ans);
}
} | main.c:2:9: fatal error: vector: No such file or directory
2 | #include<vector>
| ^~~~~~~~
compilation terminated.
|
s787427198 | p00235 | C | int n;
int t[22][22];
int solve(int idx){
int res = 0;
rep(i,n){
if(t[idx][i] > 0){
t[i][idx] = 0;
res = max(res,t[idx][i]+solve(i));
}
}
return res;
}
int main(void){
while(cin>>n,n){
memset(t,0,sizeof(t));
int sum = 0;
rep(i,n-1){
int a,b,cost;
cin>>a>>b>>cost;
t[a-1][b-1] = t[b-1][a-1] = cost;
sum += cost * 2;
}
rep(i,n){
int cnt=0, idx;
rep(j,n){
if(t[i][j] > 0 || t[i][j] == -1){
cnt++;
idx = j;
}
}
if(i != 0 && cnt == 1){
sum -= 2 * t[i][idx];
t[i][idx] = t[idx][i]= -1;
}
}
cout<<sum-solve(0)<<endl;
}
return 0;
} | main.c: In function 'solve':
main.c:6:3: error: implicit declaration of function 'rep' [-Wimplicit-function-declaration]
6 | rep(i,n){
| ^~~
main.c:6:7: error: 'i' undeclared (first use in this function)
6 | rep(i,n){
| ^
main.c:6:7: note: each undeclared identifier is reported only once for each function it appears in
main.c:6:11: error: expected ';' before '{' token
6 | rep(i,n){
| ^
| ;
main.c: In function 'main':
main.c:16:9: error: 'cin' undeclared (first use in this function)
16 | while(cin>>n,n){
| ^~~
main.c:17:5: error: implicit declaration of function 'memset' [-Wimplicit-function-declaration]
17 | memset(t,0,sizeof(t));
| ^~~~~~
main.c:1:1: note: include '<string.h>' or provide a declaration of 'memset'
+++ |+#include <string.h>
1 | int n;
main.c:17:5: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch]
17 | memset(t,0,sizeof(t));
| ^~~~~~
main.c:17:5: note: include '<string.h>' or provide a declaration of 'memset'
main.c:20:9: error: 'i' undeclared (first use in this function)
20 | rep(i,n-1){
| ^
main.c:20:15: error: expected ';' before '{' token
20 | rep(i,n-1){
| ^
| ;
|
s655040573 | p00235 | C++ | #include <iostream>
using namespace std;
int n;
int t[22][22];
int solve(int idx){
int res = 0;
rep(i,n){
if(t[idx][i] > 0){
t[i][idx] = 0;
res = max(res,t[idx][i]+solve(i));
}
}
return res;
}
int main(void){
while(cin>>n,n){
memset(t,0,sizeof(t));
int sum = 0;
rep(i,n-1){
int a,b,cost;
cin>>a>>b>>cost;
t[a-1][b-1] = t[b-1][a-1] = cost;
sum += cost * 2;
}
rep(i,n){
int cnt=0, idx;
rep(j,n){
if(t[i][j] > 0 || t[i][j] == -1){
cnt++;
idx = j;
}
}
if(i != 0 && cnt == 1){
sum -= 2 * t[i][idx];
t[i][idx] = t[idx][i]= -1;
}
}
cout<<sum-solve(0)<<endl;
}
return 0;
} | a.cc: In function 'int solve(int)':
a.cc:9:7: error: 'i' was not declared in this scope
9 | rep(i,n){
| ^
a.cc:9:3: error: 'rep' was not declared in this scope; did you mean 'res'?
9 | rep(i,n){
| ^~~
| res
a.cc: In function 'int main()':
a.cc:20:5: error: 'memset' was not declared in this scope
20 | memset(t,0,sizeof(t));
| ^~~~~~
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 | using namespace std;
a.cc:23:9: error: 'i' was not declared in this scope
23 | rep(i,n-1){
| ^
a.cc:23:5: error: 'rep' was not declared in this scope
23 | rep(i,n-1){
| ^~~
|
s922249197 | p00235 | C++ | #include<iostream>
#include<algorithm>
using namespace std;
int n;
int cost[20][20];
int edgenum[20];
int dis[20];//?????????????????????????????§??????????????¢????????????????????????
void dfs(int idx,int totalcost,int parent) {
if (edgenum[idx] == 1) {
dis[idx] = -1;
return;
}
dis[idx] = totalcost;
for (int i = 0; i < n; i++) {
if (cost[idx][i] > 0 && i != parent) {
dfs(i, totalcost + cost[idx][i], idx);
}
}
}
int main() {
while (cin >> n, n) {
int ans = 0;
for (int i = 0; i < n - 1; i++) {
int a, b, c;
cin >> a >> b >> c;
cost[a - 1][b - 1] = cost[b - 1][a - 1] = c;
ans += (c * 2);
}
for (int i = 1; i < n; i++) {
int ct = 0, idx = 0;
for (int j = 0; j < n; j++) {
if (cost[i][j] > 0)ct++, idx = j;
}
edgenum[i] = ct;
if (ct == 1) {
ans -= (cost[i][idx] * 2);
}
}
dfs(0, 0, -1);
int biggest = 0;
for (int i = 0; i < n; i++) {
biggest = std::max(biggest, dis[i]);
}
std::cout << ans - biggest << std::endl;
memset(cost, 0, sizeof(cost));
memset(dis, 0, sizeof(dis));
memset(edgenum, 0, sizeof(edgenum));
}
return 0;
} | a.cc: In function 'int main()':
a.cc:49:17: error: 'memset' was not declared in this scope
49 | memset(cost, 0, sizeof(cost));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<algorithm>
+++ |+#include <cstring>
3 |
|
s266940748 | p00235 | C++ | #include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int n;
int cost[20][20];
int edgenum[20];
int dis[20];//?????????????????????????????§??????????????¢????????????????????????
void dfs(int idx,int totalcost,int parent) {
if (edgenum[idx] == 1) {
dis[idx] = -1;
return;
}
dis[idx] = totalcost;
for (int i = 0; i < n; i++) {
if (cost[idx][i] > 0 && i != parent) {
dfs(i, totalcost + cost[idx][i], idx);
}
}
}
int main() {
while (cin >> n, n) {
int ans = 0;
for (int i = 0; i < n - 1; i++) {
int a, b, c;
cin >> a >> b >> c;
cost[a - 1][b - 1] = cost[b - 1][a - 1] = c;
ans += (c * 2);
}
for (int i = 1; i < n; i++) {
int ct = 0, idx = 0;
for (int j = 0; j < n; j++) {
if (cost[i][j] > 0)ct++, idx = j;
}
edgenum[i] = ct;
if (ct == 1) {
ans -= (cost[i][idx] * 2);
}
}
dfs(0, 0, -1);
int biggest = 0;
for (int i = 0; i < n; i++) {
biggest = std::max(biggest, dis[i]);
}
std::cout << ans - biggest << std::endl;
memset(cost, 0, sizeof(cost));
memset(dis, 0, sizeof(dis));
memset(edgenum, 0, sizeof(edgenum));
}
return 0;
} | a.cc: In function 'int main()':
a.cc:50:17: error: 'memset' was not declared in this scope
50 | memset(cost, 0, sizeof(cost));
| ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
2 | #include<algorithm>
+++ |+#include <cstring>
3 | #include<string>
|
s732140393 | p00235 | C++ | #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int n;
int cost[50][50]={0};
vvi v(22);
ll maxi_cost=0,sum=0;
void dfs(int node){
rep(i,v[node].size()){
int to=v[node][i];
if(v[to].size()==0)continue;
if(v[node].size()==1)
sum+=cost[node][to];
else{
sum+=2*cost[node][to];
cmax(maxi_cost,cost[node][to]);
}
dfs(to);
}
}
int main(){
while(cin>>n,n){
memset(cost,0,sizeof(cost));
maxi_cost=0;
sum=0;
vvi ujimatu(n+1);
rep(i,n-1){
int to,from,val;
cin>>from>>to>>val;
ujimatu[from].push_back(to);
cost[to][from]=cost[from][to]=val;
}
v=ujimatu;
dfs(1);
cout<<sum-maxi_cost<<endl;
}
} | a.cc: In function 'int main()':
a.cc:63:9: error: 'memset' was not declared in this scope
63 | memset(cost,0,sizeof(cost));
| ^~~~~~
a.cc:23:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
22 | #include <stack>
+++ |+#include <cstring>
23 | #define vi vector<int>
|
s226981781 | p00235 | C++ | #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#include <stdlib.h>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int n;
int cost[50][50]={0};
vvi v(22);
ll maxi_cost=0,sum=0;
void dfs(int node){
rep(i,v[node].size()){
int to=v[node][i];
if(v[to].size()==0)continue;
if(v[node].size()==1)
sum+=cost[node][to];
else{
sum+=2*cost[node][to];
cmax(maxi_cost,cost[node][to]);
}
dfs(to);
}
}
int main(){
while(cin>>n,n){
memset(cost,0,sizeof(cost));
maxi_cost=0;
sum=0;
vvi ujimatu(n+1);
rep(i,n-1){
int to,from,val;
cin>>from>>to>>val;
ujimatu[from].push_back(to);
cost[to][from]=cost[from][to]=val;
}
v=ujimatu;
dfs(1);
cout<<sum-maxi_cost<<endl;
}
} | a.cc: In function 'int main()':
a.cc:64:9: error: 'memset' was not declared in this scope
64 | memset(cost,0,sizeof(cost));
| ^~~~~~
a.cc:24:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
23 | #include <stdlib.h>
+++ |+#include <cstring>
24 | #define vi vector<int>
|
s763964083 | p00235 | C++ | #include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#include <stdlib.h>
#include<cstdio>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int n;
int cost[50][50]={0};
vvi v(22);
ll maxi_cost=0,sum=0;
void dfs(int node){
rep(i,v[node].size()){
int to=v[node][i];
if(v[to].size()==0)continue;
if(v[node].size()==1)
sum+=cost[node][to];
else{
sum+=2*cost[node][to];
cmax(maxi_cost,cost[node][to]);
}
dfs(to);
}
}
int main(){
while(cin>>n,n){
memset(cost,0,sizeof(cost));
maxi_cost=0;
sum=0;
vvi ujimatu(n+1);
rep(i,n-1){
int to,from,val;
cin>>from>>to>>val;
ujimatu[from].push_back(to);
cost[to][from]=cost[from][to]=val;
}
v=ujimatu;
dfs(1);
cout<<sum-maxi_cost<<endl;
}
} | a.cc: In function 'int main()':
a.cc:65:9: error: 'memset' was not declared in this scope
65 | memset(cost,0,sizeof(cost));
| ^~~~~~
a.cc:25:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
24 | #include<cstdio>
+++ |+#include <cstring>
25 | #define vi vector<int>
|
s343765601 | p00235 | C++ | #include <bits/stdc++.h>
using namespace std;
int num;
int a[21][21]={0};
int retcost(int Island){
int x=0;
for(int i=1;i<=num;i++){
if(a[Island][i]){
a[i][Island]=0;
x=max(x,a[Island][i]+cost(i));
}
}
return x;
}
int main(void){
while(cin>>num,num){
int I1,I2,t,I[num+1]={0},Cost=0;
for(int i=1;i<num;i++){
cin>>I1>>I2>>t;
a[I1][I2]=a[I2][I1]=t;
I[I1]++,I[I2]++;
Cost+=t*2;
}
for(int i=2;i<=num;i++){
for(int j=2;j<=num;j++){
if(I[i]==1||I[j]==1){
Cost-=a[i][j]*2;
a[i][j]=a[j][i]=0;
}
}
}
cout<<Cost-retcost(1)<<endl;
}
return 0;
} | a.cc: In function 'int retcost(int)':
a.cc:12:46: error: 'cost' was not declared in this scope; did you mean 'cosl'?
12 | x=max(x,a[Island][i]+cost(i));
| ^~~~
| cosl
|
s205050569 | p00235 | C++ | #include <bits/stdc++.h>
using namespace std;
int num;
int a[21][21];
int retcost(int Island){
int x=0;
for(int i=1;i<=num;i++){
if(a[Island][i]){
a[i][Island]=0;
x=max(x,a[Island][i]+retcost(i));
}
}
return x;
}
int main(void){
while(cin>>num,num){
int I1,I2,t,ans,I[num+1],Cost=0;
memset(a,0,sizeof(a));
memset(I,0,sizeof(I));
for(int i=1;i<num;i++){
cin>>I1>>I2>>t;
a[I1][I2]=a[I2][I1]=t;
I[I1]++,I[I2]++;
Cost+=t*2;
}
for(int i=2;i<=num;i++){
for(int j=2;j<=num;j++){
if(I[i]==1||I[j]==1){
Cost-=a[i][j]*2;
a[i][j]=a[j][i]=0;
}
}
}
ans=Cost-retcost(1);
cout<<ans<<endl;
}
return 0; | a.cc: In function 'int main()':
a.cc:40:18: error: expected '}' at end of input
40 | return 0;
| ^
a.cc:18:15: note: to match this '{'
18 | int main(void){
| ^
|
s362368803 | p00235 | C++ | #include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <numeric>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P,P> P2;
const int INF = 1 << 30;
const double EPS = 1E-9;
int n;
int G[20][20];
int par[20];
bool dis[20];
vector<int> chil[20];
void make_tree(int v){
for(int i = 0; i < n; i++){
if(i != par[v] && G[i][v] >= 0){
par[i] = v;
chil[v].push_back(i);
make_tree(i);
}
}
}
int dfs(int v){
if(dis[v]){
return 0;
}
int res = 0;
int maxi = 0;
for(int i = 0; i < n; i++){
if(i != par[v] && G[i][v] >= 0){
int d = dfs(i) + G[i][v];
res += 2 * d;
maxi = max(maxi, d);
}
}
return res - maxi;
}
int main(){
while(cin >> n && n){
memset(G, -1, sizeof(G));
fill(par, par + 20, -1);
fill(dis, dis + 20, false);
for(int i = 0; i < n-1;i++){
int t, f, m;
cin >> t >> f >> m;
G[t-1][f-1] = G[f-1][t-1] = m;
}
make_tree(0);
for(int i = 0; i < n; i++){
if(chil[i].empty()) dis[par[i]] = true;
}
cout << dfs(0) << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:55:17: error: 'memset' was not declared in this scope
55 | memset(G, -1, sizeof(G));
| ^~~~~~
a.cc:12:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
11 | #include <algorithm>
+++ |+#include <cstring>
12 | using namespace std;
|
s021126187 | p00235 | C++ | #include<iostream>
#define MAXN 32
using namespace std;
const int infty = 1<<24;
int dfs(int now, int n, int par[MAXN], bool vis[MAXN], bool leaf[MAXN], int W[MAXN][MAXN]){
ÃÂ ÃÂ int ret = 0;
ÃÂ ÃÂ int cnt = 0;
ÃÂ ÃÂ vis[now]=true;
ÃÂ ÃÂ for(int i = 0; i < n; ++i){
ÃÂ ÃÂ ÃÂ if(W[now][i]>0 && !vis[i]){
ÃÂ ÃÂ ÃÂ ÃÂ ret += 2*W[now][i];
ÃÂ ÃÂ ÃÂ ÃÂ ++cnt;
ÃÂ ÃÂ ÃÂ ÃÂ par[i]=now;
ÃÂ ÃÂ ÃÂ ÃÂ ret += dfs(i,n,par,vis,leaf,W);
ÃÂ ÃÂ ÃÂ ÃÂ if(leaf[i])
ret -= 2*W[now][i];
ÃÂ ÃÂ ÃÂ }
ÃÂ ÃÂ }
ÃÂ ÃÂ if(cnt==0)leaf[now]=true;
ÃÂ ÃÂ return ret;
}
int solve(int n, int W[MAXN][MAXN]){
ÃÂ ÃÂ int ret = infty;
ÃÂ ÃÂ for(int i = 0; i < n; ++i){
ÃÂ ÃÂ ÃÂ bool leaf[MAXN]={false,};
ÃÂ ÃÂ ÃÂ bool vis[MAXN]={false,};
ÃÂ ÃÂ ÃÂ int par[MAXN];
ÃÂ ÃÂ ÃÂ int D = dfs(i,n,par,vis,leaf,W);
ÃÂ ÃÂ ÃÂ int maxD = 0;
ÃÂ ÃÂ ÃÂ for(int j = 0; j < n; ++j){
ÃÂ ÃÂ ÃÂ ÃÂ if( !leaf[j] && W[i][j] > 0 ){
maxD = max( maxD, W[i][j] );
ÃÂ ÃÂ ÃÂ ÃÂ }
ÃÂ ÃÂ ÃÂ }
ÃÂ ÃÂ ÃÂ //cout << i << ' ' << D << ' ' << maxD << endl; ÃÂ ÃÂ
ÃÂ ÃÂ ÃÂ if(i!=0){
ÃÂ ÃÂ ÃÂ ÃÂ int c = 0;
ÃÂ ÃÂ ÃÂ ÃÂ int p = par[c];
ÃÂ ÃÂ ÃÂ ÃÂ while(p!=i){
if(!leaf[c])
ÃÂ D -= W[c][p];
c = p;
p = par[c];
ÃÂ ÃÂ ÃÂ ÃÂ }
ÃÂ ÃÂ ÃÂ ÃÂ if(leaf[0]){
D += W[par[0]][0];
ÃÂ ÃÂ ÃÂ ÃÂ }
ÃÂ ÃÂ ÃÂ }
ÃÂ ÃÂ ÃÂ //cout << D << endl;
ÃÂ ÃÂ ÃÂ
ÃÂ ÃÂ ÃÂ ret = min( ret, D - maxD );
ÃÂ ÃÂ }
ÃÂ ÃÂ return ret;
}
int main()
{
ÃÂ ÃÂ while(true){
ÃÂ ÃÂ ÃÂ int n;
ÃÂ ÃÂ ÃÂ int W[MAXN][MAXN]={{0,},}; // 0 means unconnected
ÃÂ ÃÂ ÃÂ cin >> n;
ÃÂ ÃÂ ÃÂ //cout << n << endl;
ÃÂ ÃÂ ÃÂ if( n == 0 ) break;
ÃÂ ÃÂ ÃÂ for(int i = 0; i < n-1; ++i){
ÃÂ ÃÂ ÃÂ ÃÂ int a,b,t;
ÃÂ ÃÂ ÃÂ ÃÂ cin >> a >> b >> t;
ÃÂ ÃÂ ÃÂ ÃÂ --a;--b;
ÃÂ ÃÂ ÃÂ ÃÂ W[a][b] = W[b][a] = t;
ÃÂ ÃÂ ÃÂ }
ÃÂ ÃÂ ÃÂ cout << solve(n,W) << endl;
ÃÂ ÃÂ }
ÃÂ ÃÂ return 0;
} | a.cc:9:1: error: extended character is not valid in an identifier
9 | ÃÂ ÃÂ int ret = 0;
| ^
a.cc:9:1: error: extended character is not valid in an identifier
a.cc:9:1: error: extended character is not valid in an identifier
a.cc:9:1: error: extended character is not valid in an identifier
a.cc:10:1: error: extended character is not valid in an identifier
10 | ÃÂ ÃÂ int cnt = 0;
| ^
a.cc:10:1: error: extended character is not valid in an identifier
a.cc:10:1: error: extended character is not valid in an identifier
a.cc:10:1: error: extended character is not valid in an identifier
a.cc:11:1: error: extended character is not valid in an identifier
11 | ÃÂ ÃÂ vis[now]=true;
| ^
a.cc:11:1: error: extended character is not valid in an identifier
a.cc:11:1: error: extended character is not valid in an identifier
a.cc:11:1: error: extended character is not valid in an identifier
a.cc:12:1: error: extended character is not valid in an identifier
12 | ÃÂ ÃÂ for(int i = 0; i < n; ++i){
| ^
a.cc:12:1: error: extended character is not valid in an identifier
a.cc:12:1: error: extended character is not valid in an identifier
a.cc:12:1: error: extended character is not valid in an identifier
a.cc:13:1: error: extended character is not valid in an identifier
13 | ÃÂ ÃÂ ÃÂ if(W[now][i]>0 && !vis[i]){
| ^
a.cc:13:1: error: extended character is not valid in an identifier
a.cc:13:1: error: extended character is not valid in an identifier
a.cc:13:1: error: extended character is not valid in an identifier
a.cc:13:10: error: extended character is not valid in an identifier
13 | ÃÂ ÃÂ ÃÂ if(W[now][i]>0 && !vis[i]){
| ^
a.cc:13:10: error: extended character is not valid in an identifier
a.cc:14:1: error: extended character is not valid in an identifier
14 | ÃÂ ÃÂ ÃÂ ÃÂ ret += 2*W[now][i];
| ^
a.cc:14:1: error: extended character is not valid in an identifier
a.cc:14:1: error: extended character is not valid in an identifier
a.cc:14:1: error: extended character is not valid in an identifier
a.cc:14:10: error: extended character is not valid in an identifier
14 | ÃÂ ÃÂ ÃÂ ÃÂ ret += 2*W[now][i];
| ^
a.cc:14:10: error: extended character is not valid in an identifier
a.cc:14:15: error: extended character is not valid in an identifier
14 | ÃÂ ÃÂ ÃÂ ÃÂ ret += 2*W[now][i];
| ^
a.cc:14:15: error: extended character is not valid in an identifier
a.cc:15:1: error: extended character is not valid in an identifier
15 | ÃÂ ÃÂ ÃÂ ÃÂ ++cnt;
| ^
a.cc:15:1: error: extended character is not valid in an identifier
a.cc:15:1: error: extended character is not valid in an identifier
a.cc:15:1: error: extended character is not valid in an identifier
a.cc:15:10: error: extended character is not valid in an identifier
15 | ÃÂ ÃÂ ÃÂ ÃÂ ++cnt;
| ^
a.cc:15:10: error: extended character is not valid in an identifier
a.cc:15:15: error: extended character is not valid in an identifier
15 | ÃÂ ÃÂ ÃÂ ÃÂ ++cnt;
| ^
a.cc:15:15: error: extended character is not valid in an identifier
a.cc:16:1: error: extended character is not valid in an identifier
16 | ÃÂ ÃÂ ÃÂ ÃÂ par[i]=now;
| ^
a.cc:16:1: error: extended character is not valid in an identifier
a.cc:16:1: error: extended character is not valid in an identifier
a.cc:16:1: error: extended character is not valid in an identifier
a.cc:16:10: error: extended character is not valid in an identifier
16 | ÃÂ ÃÂ ÃÂ ÃÂ par[i]=now;
| ^
a.cc:16:10: error: extended character is not valid in an identifier
a.cc:16:15: error: extended character is not valid in an identifier
16 | ÃÂ ÃÂ ÃÂ ÃÂ par[i]=now;
| ^
a.cc:16:15: error: extended character is not valid in an identifier
a.cc:17:1: error: extended character is not valid in an identifier
17 | ÃÂ ÃÂ ÃÂ ÃÂ ret += dfs(i,n,par,vis,leaf,W);
| ^
a.cc:17:1: error: extended character is not valid in an identifier
a.cc:17:1: error: extended character is not valid in an identifier
a.cc:17:1: error: extended character is not valid in an identifier
a.cc:17:10: error: extended character is not valid in an identifier
17 | ÃÂ ÃÂ ÃÂ ÃÂ ret += dfs(i,n,par,vis,leaf,W);
| ^
a.cc:17:10: error: extended character is not valid in an identifier
a.cc:17:15: error: extended character is not valid in an identifier
17 | ÃÂ ÃÂ ÃÂ ÃÂ ret += dfs(i,n,par,vis,leaf,W);
| ^
a.cc:17:15: error: extended character is not valid in an identifier
a.cc:18:1: error: extended character is not valid in an identifier
18 | ÃÂ ÃÂ ÃÂ ÃÂ if(leaf[i])
| ^
a.cc:18:1: error: extended character is not valid in an identifier
a.cc:18:1: error: extended character is not valid in an identifier
a.cc:18:1: error: extended character is not valid in an identifier
a.cc:18:10: error: extended character is not valid in an identifier
18 | ÃÂ ÃÂ ÃÂ ÃÂ if(leaf[i])
| ^
a.cc:18:10: error: extended character is not valid in an identifier
a.cc:18:15: error: extended character is not valid in an identifier
18 | ÃÂ ÃÂ ÃÂ ÃÂ if(leaf[i])
| ^
a.cc:18:15: error: extended character is not valid in an identifier
a.cc:20:1: error: extended character is not valid in an identifier
20 | ÃÂ ÃÂ ÃÂ }
| ^
a.cc:20:1: error: extended character is not valid in an identifier
a.cc:20:1: error: extended character is not valid in an identifier
a.cc:20:1: error: extended character is not valid in an identifier
a.cc:20:10: error: extended character is not valid in an identifier
20 | ÃÂ ÃÂ ÃÂ }
| ^
a.cc:20:10: error: extended character is not valid in an identifier
a.cc:21:1: error: extended character is not valid in an identifier
21 | ÃÂ ÃÂ }
| ^
a.cc:21:1: error: extended character is not valid in an identifier
a.cc:21:1: error: extended character is not valid in an identifier
a.cc:21:1: error: extended character is not valid in an identifier
a.cc:22:1: error: extended character is not valid in an identifier
22 | ÃÂ ÃÂ if(cnt==0)leaf[now]=true;
| ^
a.cc:22:1: error: extended character is not valid in an identifier
a.cc:22:1: error: extended character is not valid in an identifier
a.cc:22:1: error: extended character is not valid in an identifier
a.cc:23:1: error: extended character is not valid in an identifier
23 | ÃÂ ÃÂ return ret;
| ^
a.cc:23:1: error: extended character is not valid in an identifier
a.cc:23:1: error: extended character is not valid in an identifier
a.cc:23:1: error: extended character is not valid in an identifier
a.cc:27:1: error: extended character is not valid in an identifier
27 | ÃÂ ÃÂ int ret = infty;
| ^
a.cc:27:1: error: extended character is not valid in an identifier
a.cc:27:1: error: extended character is not valid in an identifier
a.cc:27:1: error: extended character is not valid in an identifier
a.cc:28:1: error: extended character is not valid in an identifier
28 | ÃÂ ÃÂ for(int i = 0; i < n; ++i){
| ^
a.cc:28:1: error: extended character is not valid in an identifier
a.cc:28:1: error: extended character is not valid in an identifier
a.cc:28:1: error: extended character is not valid in an identifier
a.cc:29:1: error: extended character is not valid in an identifier
29 | ÃÂ ÃÂ ÃÂ bool leaf[MAXN]={false,};
| ^
a.cc:29:1: error: extended character is not valid in an identifier
a.cc:29:1: error: extended character is not valid in an identifier
a.cc:29:1: error: extended character is not valid in an identifier
a.cc:29:10: error: extended character is not valid in an identifier
29 | ÃÂ ÃÂ ÃÂ bool leaf[MAXN]={false,};
| ^
a.cc:29:10: error: extended character is not valid in an identifier
a.cc:30:1: error: extended character is not valid in an identifier
30 | ÃÂ ÃÂ ÃÂ bool vis[MAXN]={false,};
| ^
a.cc:30:1: error: extended character is not valid in an identifier
a.cc:30:1: error: extended character is not valid in an identifier
a.cc:30:1: error: extended character is not valid in an identifier
a.cc:30:10: error: extended character is not valid in an identifier
30 | ÃÂ ÃÂ ÃÂ bool vis[MAXN]={false,};
| ^
a.cc:30:10: error: extended character is not valid in an identifier
a.cc:31:1: error: extended character is not valid in an identifier
31 | ÃÂ ÃÂ ÃÂ int par[MAXN];
| ^
a.cc:31:1: error: extended character is not valid in an identifier
a.cc:31:1: error: extended character is not valid in an identifier
a.cc:31:1: error: extended character is not valid in an identifier
a.cc:31:10: error: extended character is not valid in an identifier
31 | ÃÂ ÃÂ ÃÂ int par[MAXN];
| ^
a.cc:31:10: error: extended character is not valid in an identifier
a.cc:32:1: error: extended character is not valid in an identifier
32 | ÃÂ ÃÂ ÃÂ int D = dfs(i,n,par,vis,leaf,W);
| ^
a.cc:32:1: error: extended character is not valid in an identifier
a.cc:32:1: error: extended character is not valid in an identifier
a.cc:32:1: error: extended character is not valid in an identifier
a.cc:32:10: error: extended character is not valid in an identifier
32 | ÃÂ ÃÂ ÃÂ int D = dfs(i,n,par,vis,leaf,W);
| ^
a.cc:32:10: |
s968040473 | p00235 | C++ | #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
struct edge{
int to,cost;
};
int n;
vector<edge> G[30];
const int INF=1000000000;
bool passed[30];
bool passed2[30];
// ÊÉÄAµÄRXgðvZ
int rec(int s){
passed[s]=true;
int sumCost=0;
bool f=false;
for(int i = 0; i < G[s].size(); i++){
edge e=G[s][i];
if(s==4){
//cout<<endl;
}
if(passed[e.to])
continue;
f=true;
int res=rec(e.to);
if(res!=-1)
sumCost+=res+e.cost*2;
}
if(!f)
return -1;
return sumCost;
}
int dfs(int s){
passed2[s]=true;
// e[gÅÄA
int maxCost=0;
int idx;
int tc=0;
int sumCost=0;
for(int i = 0; i < G[s].size(); i++){
int to=G[s][i].to;
int cost=G[s][i].cost;
if(passed2[to])
continue;
memset(passed,0,sizeof(passed));
passed[s]=true;
int res=rec(to);
int val=0;
if(res!=-1)
val+=cost*2;
if(maxCost<val){
sumCost+=maxCost;
maxCost=val;
idx=to;
tc=cost;
}
else
sumCost+=val;
}
if(tc==0)
return 0;
// àÁÆàlª¬³¢[gÖiÞ
return dfs(idx)+tc+sumCost;
}
int main(){
while(cin>>n&&n!=0){
memset(passed2,0,sizeof(passed2));
for(int i = 0; i < n; i++)
G[i].clear();
for(int i = 0; i < n-1; i++){
edge e;
int from,to;
cin>>from>>to>>e.cost;
from--;to--;
e.to=to;
G[from].push_back(e);
e.to=from;
G[to].push_back(e);
}
int res=dfs(0);
cout<<res<<endl;
}
return 0;
} | a.cc: In function 'int dfs(int)':
a.cc:51:9: error: 'memset' was not declared in this scope
51 | memset(passed,0,sizeof(passed));
| ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
3 | #include <algorithm>
+++ |+#include <cstring>
4 | #include <string>
a.cc: In function 'int main()':
a.cc:74:9: error: 'memset' was not declared in this scope
74 | memset(passed2,0,sizeof(passed2));
| ^~~~~~
a.cc:74:9: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s600021699 | p00235 | C++ | #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int maxn;
vector<int> to[21];
int cost[21][21];
int tree[21];//その木の種類を示す //0:tree,1:leaf,2:last
bool isgo[21];
int dfs(int t,int c)
{
int sum = 0;
isgo[t] = true;
bool go = false;
for(int i=0;i<to[t].size();++i){
int next = to[t][i];
if(isgo[next])
continue;
else{
go = true;
int num = dfs(next,cost[t][next]);
if(num == 0){
tree[next] = 1;
tree[t] = 2;
}
sum += num;
}
}
if(go)
return sum+c;
else//どこにも行くところがなかった
return 0;
}
int maxcost;
void check(int t,int sumc)//2回目のDFS・・・ムダー
{
bool b=false;
isgo[t] = true;
for(int i=0;i<to[t].size();++i){
int next = to[t][i];
if(tree[next] == 1 || isgo[next])
continue;
else{
b = true;
check(next,cost[t][next]+sumc);
}
}
if(!b){//行き先がない
if(maxcost < sumc)
maxcost = sumc;
}
}
int main(void)
{
while(1){
cin >> maxn;
if(maxn == 0)
return 0;
memset(isgo,false,sizeof(isgo));
memset(tree,0,sizeof(tree));
for(int i=0;i<maxn-1;++i){
int a,b,c;
cin >> a >> b >> c;
to[a].push_back(b);
to[b].push_back(a);
cost[a][b] = c;
cost[b][a] = c;
}
int sum = dfs(1,0)*2;
memset(isgo,false,sizeof(isgo));
maxcost = 0;
check(1,0);
cout << sum - maxcost << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:65:17: error: 'memset' was not declared in this scope
65 | memset(isgo,false,sizeof(isgo));
| ^~~~~~
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 | using namespace std;
|
s170604553 | p00235 | C++ | int n;
int t[22][22];
int solve(int idx){
int res = 0;
rep(i,n){
if(t[idx][i] > 0){
t[i][idx] = 0;
res = max(res,t[idx][i]+solve(i));
}
}
return res;
}
int main(void){
while(cin>>n,n){
memset(t,0,sizeof(t));
int sum = 0;
rep(i,n-1){
int a,b,cost;
cin>>a>>b>>cost;
t[a-1][b-1] = t[b-1][a-1] = cost;
sum += cost * 2;
}
rep(i,n){
int cnt=0, idx;
rep(j,n){
if(t[i][j] > 0 || t[i][j] == -1){
cnt++;
idx = j;
}
}
if(i != 0 && cnt == 1){
sum -= 2 * t[i][idx];
t[i][idx] = t[idx][i]= -1;
}
}
cout<<sum-solve(0)<<endl;
}
return 0;
} | a.cc: In function 'int solve(int)':
a.cc:6:7: error: 'i' was not declared in this scope
6 | rep(i,n){
| ^
a.cc:6:3: error: 'rep' was not declared in this scope; did you mean 'res'?
6 | rep(i,n){
| ^~~
| res
a.cc: In function 'int main()':
a.cc:16:9: error: 'cin' was not declared in this scope
16 | while(cin>>n,n){
| ^~~
a.cc:17:5: error: 'memset' was not declared in this scope
17 | memset(t,0,sizeof(t));
| ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
+++ |+#include <cstring>
1 | int n;
a.cc:20:9: error: 'i' was not declared in this scope
20 | rep(i,n-1){
| ^
a.cc:20:5: error: 'rep' was not declared in this scope
20 | rep(i,n-1){
| ^~~
a.cc:41:5: error: 'cout' was not declared in this scope
41 | cout<<sum-solve(0)<<endl;
| ^~~~
a.cc:41:25: error: 'endl' was not declared in this scope
41 | cout<<sum-solve(0)<<endl;
| ^~~~
|
s836684171 | p00235 | C++ | int n;
int t[22][22];
int solve(int idx){
int res = 0;
rep(i,n){
if(t[idx][i] > 0){
t[i][idx] = 0;
res = max(res,t[idx][i]+solve(i));
}
}
return res;
}
int main(void){
while(cin>>n,n){
memset(t,0,sizeof(t));
int sum = 0;
rep(i,n-1){
int a,b,cost;
cin>>a>>b>>cost;
t[a-1][b-1] = t[b-1][a-1] = cost;
sum += cost * 2;
}
rep(i,n){
int cnt=0, idx;
rep(j,n){
if(t[i][j] > 0 || t[i][j] == -1){
cnt++;
idx = j;
}
}
if(i != 0 && cnt == 1){
sum -= 2 * t[i][idx];
t[i][idx] = t[idx][i]= -1;
}
}
cout<<sum-solve(0)<<endl;
}
return 0;
} | a.cc: In function 'int solve(int)':
a.cc:6:7: error: 'i' was not declared in this scope
6 | rep(i,n){
| ^
a.cc:6:3: error: 'rep' was not declared in this scope; did you mean 'res'?
6 | rep(i,n){
| ^~~
| res
a.cc: In function 'int main()':
a.cc:16:9: error: 'cin' was not declared in this scope
16 | while(cin>>n,n){
| ^~~
a.cc:17:5: error: 'memset' was not declared in this scope
17 | memset(t,0,sizeof(t));
| ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
+++ |+#include <cstring>
1 | int n;
a.cc:20:9: error: 'i' was not declared in this scope
20 | rep(i,n-1){
| ^
a.cc:20:5: error: 'rep' was not declared in this scope
20 | rep(i,n-1){
| ^~~
a.cc:41:5: error: 'cout' was not declared in this scope
41 | cout<<sum-solve(0)<<endl;
| ^~~~
a.cc:41:25: error: 'endl' was not declared in this scope
41 | cout<<sum-solve(0)<<endl;
| ^~~~
|
s107817692 | p00235 | C++ | #include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <cstring>
using namespace std;
typedef long long int lli;
typedef pair<int,int> P;
const int INF=100000000;
const long long int INF_=1000000000000000000;
int N;
vector<int> T[20];
int Cost[20][20];
int Count[20];
bool Done[20];
/*
void dfs(int v,int cost,int count){
if(ANS<=cost) return;
if(count==N-1){
ANS=cost;
return;
}
for(int i=0; i<T[v].size(); ++i){
if(Cost[v][T[v][i]]!=INF){
int tmp=Cost[v][T[v][i]];
Cost[v][T[v][i]]=Cost[T[v][i]][v]=INF;
dfs(v,cost,count+1);
Cost[v][T[v][i]]=Cost[T[v][i]][v]=tmp;
if(!Done[v][T[v][i]]){
Done[v][T[v][i]]=true;
dfs(T[v][i],cost+Cost[v][T[v][i]],count);
Done[v][T[v][i]]=false;
}
}
}
}
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
while(cin >> N&&N!=0){
ANS=INF;
for(int i=0; i<N; ++i) T[i].clear();
memset(Done,0,sizeof(Done));
memset(Count,0,sizeof(Count));
fill_n((int*)Cost,20*20,INF);
for(int i=0; i<N-1; ++i){
int a,b,t;
cin >> a >> b >> t;
--a; --b;
T[a].push_back(b);
T[b].push_back(a);
Cost[a][b]=Cost[b][a]=t;
++Count[a];
++Count[b];
}
for(int i=1; i<N; ++i){
if(Count[i]<=1){
for(int j=0; j<T[i].size(); ++j){
Done[i][T[i][j]]=Done[T[i][j]][i]=true;
}
}
}
dfs(0,0,0);
cout << ANS << endl;
}
return 0;
}
*/
int dfs(int v){
int result=0;
Done[v]=true;
for(int i=0; i<T[v].size(); ++i){
if(Count[T[v][i]]>1&&!Done[T[v][i]]&&Cost[v][T[v][i]]!=INF){
result=max(result,Cost[v][T[v][i]]+dfs(T[v][i]));
}
}
return result;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(0);
while(cin >> N&&N){
for(int i=0; i<N; ++i) T[i].clear();
memset(Done,0,sizeof(Done));
memset(Count,0,sizeof(Count));
fill_n((int*)Cost,20*20,INF);
int sum=0;
for(int i=0; i<N-1; ++i){
int a,b,t;
cin >> a >> b >> t;
--a; --b;
T[a].push_back(b);
T[b].push_back(a);
Cost[a][b]=Cost[b][a]=t;
++Count[a];
++Count[b];
}
for(int i=1; i<N; ++i){
if(Count[i]>1){
//cout << i << endl;
for(int j=0; j<T[i].size(); ++j){
if(Count[T[i][j]]>1){
sum+=Cost[i][T[i][j]];
}
}
}
}
for(int i=0; i<T[0].size(); ++i){
//cout << Cost[0][T[0][i]] << endl;
if(Count[T[0][i]]>1) sum+=2*Cost[0][T[0][i]];
}
}
//cout << sum << endl;
//cout << dfs(0) << endl;
cout << sum-dfs(0) << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:122:17: error: 'sum' was not declared in this scope
122 | cout << sum-dfs(0) << endl;
| ^~~
a.cc: At global scope:
a.cc:124:5: error: expected unqualified-id before 'return'
124 | return 0;
| ^~~~~~
a.cc:125:1: error: expected declaration before '}' token
125 | }
| ^
|
s917117485 | p00236 | Java |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
new Main().run();
}
private void run() {
Scanner scanner = new Scanner(System.in);
loop: while (true) {
w = scanner.nextInt();
h = scanner.nextInt();
if ((w | h) == 0)
break;
count = 0;
visited = new boolean[h][w];
sx = -1;
sy = -1;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
int now = scanner.nextInt();
if (now == 0) {
count++;
if (sx == -1) {
sy = i;
sx = j;
}
} else {
visited[i][j] = true;
}
}
}
if(count%2==1){
System.out.println("No");
continue;
}
}
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (visited[i][j])
continue;
int count = 0;
for (int k = 0; k < 4; k++) {
int x = j + vx[k];
int y = i + vy[k];
if (!isOK(x, y))
continue;
if (!visited[y][x])
count++;
}
if (count < 2) {
System.out.println("No");
continue loop;
}
}
}
System.out.println(dfs(sx, sy, 0) ? "Yes" : "No");
}
}
private boolean dfs(int x, int y, int deep) {
if (count - deep < Math.abs(x - sx) + Math.abs(y - sy))
return false;
for (int i = 0; i < 4; i++) {
int nx = x + vx[i];
int ny = y + vy[i];
if (!isOK(nx, ny))
continue;
if (ny == sy && nx == sx && deep + 1 == count)
return true;
if (visited[ny][nx])
continue;
boolean res = check(nx, ny);
if (!res)
continue;
visited[ny][nx] = true;
if (dfs(nx, ny, deep + 1))
return true;
visited[ny][nx] = false;
}
return false;
}
private boolean check(int x, int y) {
loop: for (int i = 4; i < vx.length; i++) {
int nx = x + vx[i];
int ny = y + vy[i];
if (!isOK(nx, ny))
continue;
if (nx == sx && ny == sy)
continue;
if (visited[ny][nx])
continue;
int count = 0;
for (int j = 0; j < 4; j++) {
int nnx = nx + vx[j];
int nny = ny + vy[j];
if (!isOK(nnx, nny))
continue;
if (visited[nny][nnx])
continue;
count++;
if (count == 2)
continue loop;
}
return false;
}
return true;
}
private boolean isOK(int x, int y) {
if (0 <= x && x < w && 0 <= y && y < h)
return true;
return false;
}
boolean[][] visited;
boolean ans;
int count, w, h, sx, sy;
int[] vx = { 0, 1, 0, -1, 1, 1, -1, -1 };
int[] vy = { -1, 0, 1, 0, -1, 1, 1, -1 };
} | Main.java:66: error: unnamed classes are a preview feature and are disabled by default.
private boolean dfs(int x, int y, int deep) {
^
(use --enable-preview to enable unnamed classes)
Main.java:126: error: class, interface, enum, or record expected
int count, w, h, sx, sy;
^
Main.java:129: error: class, interface, enum, or record expected
}
^
3 errors
|
s769797853 | p00236 | Java |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
new Main().run();
}
private void run() {
Scanner scanner = new Scanner(System.in);
loop: while (true) {
w = scanner.nextInt();
h = scanner.nextInt();
if ((w | h) == 0)
break;
count = 0;
visited = new boolean[h][w];
sx = -1;
sy = -1;
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
int now = scanner.nextInt();
if (now == 0) {
count++;
if (sx == -1) {
sy = i;
sx = j;
}
} else {
visited[i][j] = true;
}
}
}
if(count%2==1){
System.out.println("No");
continue;
}
}
for (int i = 0; i < h; i++) {
for (int j = 0; j < w; j++) {
if (visited[i][j])
continue;
int count = 0;
for (int k = 0; k < 4; k++) {
int x = j + vx[k];
int y = i + vy[k];
if (!isOK(x, y))
continue;
if (!visited[y][x])
count++;
}
if (count < 2) {
System.out.println("No");
continue loop;
}
}
}
System.out.println(dfs(sx, sy, 0) ? "Yes" : "No");
}
}
private boolean dfs(int x, int y, int deep) {
if (count - deep < Math.abs(x - sx) + Math.abs(y - sy))
return false;
for (int i = 0; i < 4; i++) {
int nx = x + vx[i];
int ny = y + vy[i];
if (!isOK(nx, ny))
continue;
if (ny == sy && nx == sx && deep + 1 == count)
return true;
if (visited[ny][nx])
continue;
boolean res = check(nx, ny);
if (!res)
continue;
visited[ny][nx] = true;
if (dfs(nx, ny, deep + 1))
return true;
visited[ny][nx] = false;
}
return false;
}
private boolean check(int x, int y) {
loop: for (int i = 4; i < vx.length; i++) {
int nx = x + vx[i];
int ny = y + vy[i];
if (!isOK(nx, ny))
continue;
if (nx == sx && ny == sy)
continue;
if (visited[ny][nx])
continue;
int count = 0;
for (int j = 0; j < 4; j++) {
int nnx = nx + vx[j];
int nny = ny + vy[j];
if (!isOK(nnx, nny))
continue;
if (visited[nny][nnx])
continue;
count++;
if (count == 2)
continue loop;
}
return false;
}
return true;
}
private boolean isOK(int x, int y) {
if (0 <= x && x < w && 0 <= y && y < h)
return true;
return false;
}
boolean[][] visited;
boolean ans;
int count, w, h, sx, sy;
int[] vx = { 0, 1, 0, -1, 1, 1, -1, -1 };
int[] vy = { -1, 0, 1, 0, -1, 1, 1, -1 };
} | Main.java:66: error: unnamed classes are a preview feature and are disabled by default.
private boolean dfs(int x, int y, int deep) {
^
(use --enable-preview to enable unnamed classes)
Main.java:126: error: class, interface, enum, or record expected
int count, w, h, sx, sy;
^
Main.java:129: error: class, interface, enum, or record expected
}
^
3 errors
|
s091964619 | p00236 | Java | import java.util.*;
public class No11 {
/**
* @param args
*/
public static int[][] map;
static int W,H,sh = 0,sw = 0;
static boolean res = false;
static boolean first = true;
static int[][] d = {{0,1,0,-1},{1,0,-1,0}};
public static void main(String[] args) {
// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
Scanner sc = new Scanner(System.in);
while(sc.hasNextInt()){
W = sc.nextInt();
H = sc.nextInt();
sc.nextLine();
if(W == 0 && H == 0)break;
map = new int[H][W];
res = false;
for(int i =0;i<H;i++){
for(int j = 0;j<W;j++){
map[i][j] = sc.nextInt();
}
}
boolean invalid = true;
loop:for(int i = 0;i<H;i++){
for(int j = 0;j<W;j++){
if(map[i][j] == '0'){
sh = i;
sw = j;
invalid = false;
break loop;
}
}
}
if(invalid) break;
solve(sh,sw);
System.out.println(res);
}
}
public static void solve(int h,int w){
map[h][w] = 1;
if(res == true) return;
if(isInNear(sh,sw,h,w)){
if(filled()){
res = true;
return;
}
}
first = false;
for(int s = 0;s<4;s++){
int nh,nw;
nh = h + d[0][s];nw = w + d[1][s];
if(0<=nh && nh<H && 0 <= nw && nw < W){
if(map[nh][nw] == 0){
solve(nh,nw);
}
}
}
map[h][w] = 0;
}
public static boolean filled(){
boolean ans = true;
loop:for(int i = 0;i<H;i++){
for(int j = 0;j<W;j++){
if(map[i][j] == 0){
ans = false;
break loop;
}
}
}
return ans;
}
public static boolean isInNear(int sx,int sy, int tx, int ty){
for(int s = 0;s<4;s++){
int nx = sx,ny = sy;
nx += d[0][s];ny += d[1][s];
if(nx == tx && ny == ty) return true;
}
return false;
}
} | Main.java:2: error: class No11 is public, should be declared in a file named No11.java
public class No11 {
^
1 error
|
s087303183 | p00236 | C | int w,h;
int d[9][9],q[9][9];
int a[4]={-1,0,1,0};
int X,Y,C,t;
int b=0;
int chk(int x,int y){
int i=0,ans=1;
if(q[y][x])return 0;
q[y][x]=1;
if(d[y][x])return y==Y&&x==X;
for(;i<4;i++)ans+=chk(x+a[i],y+a[(i+1)%4]);
return ans;
}
int dfs(int x,int y,int c){
int i=0;
if(!c&&x==X&&y==Y)return 1;
memset(q,0,324),
if(d[y][x]||chk(x,y) != c+(x!=X||y!=Y))return 0;
if(b++ > 120000)return 2;
d[y][x]=1;
for(;i<4;i++)if(t=dfs(x+a[i],y+a[(i+1)%4],c-1))return t;
return d[y][x]=0;
}
int main(i,j){
for(;C=0,b=0,scanf("%d%d\n",&w,&h),h;puts(C>3&&dfs(X,Y,C)==1?"Yes":"No")){
memset(d,-1,324);
for(j=0;j++<h;)for(i=0;i++<w;i++)scanf("%d",&t),(d[j][i]=t)||(++C,X=i,Y=j);
}
return 0;
} | main.c: In function 'dfs':
main.c:17:9: error: implicit declaration of function 'memset' [-Wimplicit-function-declaration]
17 | memset(q,0,324),
| ^~~~~~
main.c:1:1: note: include '<string.h>' or provide a declaration of 'memset'
+++ |+#include <string.h>
1 | int w,h;
main.c:17:9: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch]
17 | memset(q,0,324),
| ^~~~~~
main.c:17:9: note: include '<string.h>' or provide a declaration of 'memset'
main.c:18:9: error: expected expression before 'if'
18 | if(d[y][x]||chk(x,y) != c+(x!=X||y!=Y))return 0;
| ^~
main.c: In function 'main':
main.c:24:5: error: type of 'i' defaults to 'int' [-Wimplicit-int]
24 | int main(i,j){
| ^~~~
main.c:24:5: error: type of 'j' defaults to 'int' [-Wimplicit-int]
main.c:25:22: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
25 | for(;C=0,b=0,scanf("%d%d\n",&w,&h),h;puts(C>3&&dfs(X,Y,C)==1?"Yes":"No")){
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | int w,h;
main.c:25:22: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
25 | for(;C=0,b=0,scanf("%d%d\n",&w,&h),h;puts(C>3&&dfs(X,Y,C)==1?"Yes":"No")){
| ^~~~~
main.c:25:22: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:25:46: error: implicit declaration of function 'puts' [-Wimplicit-function-declaration]
25 | for(;C=0,b=0,scanf("%d%d\n",&w,&h),h;puts(C>3&&dfs(X,Y,C)==1?"Yes":"No")){
| ^~~~
main.c:25:46: note: include '<stdio.h>' or provide a declaration of 'puts'
main.c:26:17: warning: incompatible implicit declaration of built-in function 'memset' [-Wbuiltin-declaration-mismatch]
26 | memset(d,-1,324);
| ^~~~~~
main.c:26:17: note: include '<string.h>' or provide a declaration of 'memset'
|
s215203787 | p00236 | C++ | #include<bits/stdc++.h>
using namespace std;
typedef long long int64;
const static int dy[4] = {0, -1, 0, 1}, dx[4] = {1, 0, -1, 0};
int W, H;
int c[7][7];
pair< int, int > first;
int64 used;
set< pair< int64, unsigned char > > sets;
#define getShift(x, y) (int64)(x + y * W)
inline bool dfs(int x, int y, int bit) {
if((used >> getShift(x, y)) & 1) return(false);
used |= 1LL << getShift(x, y);
for(int i = 0; i < 4; i++) {
int nx = x + dx[i], ny = y + dy[i];
if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
if((bit >> getShift(nx, ny)) & 1) dfs(nx, ny, bit);
}
return(true);
}
inline bool check(int64 bit, int x, int y)
{
if(sets.find(make_pair(bit, y * W + x)) != sets.end()) return(false);
if(bit == 0) return(make_pair(x, y) == first);
int ret = 0; used = 0LL;
for(int i = 0; i < H; i++) {
for(int j = 0; j < W; j++) {
if(!((bit >> getShift(j, i)) & 1)) continue;
ret += dfs(j, i, bit);
}
}
if(ret >= 2) {
if(rand() % 4 == 0) sets.insert(make_pair(bit, y * W + x));
return(false);
}
for(int i = 0; i < 4; i++) {
int nx = x + dx[i], ny = y + dy[i];
if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;
if(!(bit >> getShift(nx, ny) & 1)) continue;
if(check(bit&~(1LL << getShift(nx, ny)), nx, ny)) return(true);
}
if(rand() % 4 == 0) sets.insert(make_pair(bit, y * W + x));
return(false);
}
int main()
{
srand((int)"iky");
while(scanf("%d %d",&W, &H), W) {
for(int i = 0; i < H; ++i) {
for(int j = 0; j < W; ++j) {
scanf("%d", &c[i][j]);
}
}
int64 mask = 0LL;
int cost = 0;
first = make_pair(-1, -1);
for(int i = 0; i < H; i++) {
for(int j = 0; j < W; j++) {
mask |= (int64)!c[i][j] << getShift(j, i);
if(c[i][j] == 0) first = make_pair(j, i), cost++;
}
}
if(cost & 1 || first == make_pair(-1, -1)) puts("No");
else puts(check(mask, first.first, first.second) ? "Yes" : "No");
sets.clear();
}
} | a.cc: In function 'int main()':
a.cc:53:9: error: cast from 'const char*' to 'int' loses precision [-fpermissive]
53 | srand((int)"iky");
| ^~~~~~~~~~
|
s115510827 | p00236 | C++ | using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "Input2";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("5 4");
WillReturn.Add("0 0 0 0 0");
WillReturn.Add("0 1 1 0 0");
WillReturn.Add("0 0 1 0 1");
WillReturn.Add("1 0 0 0 1");
WillReturn.Add("5 4");
WillReturn.Add("0 0 0 0 0");
WillReturn.Add("0 1 1 0 0");
WillReturn.Add("0 0 0 0 1");
WillReturn.Add("1 0 0 0 1");
WillReturn.Add("0 0");
//Yes
//No
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
InputList.RemoveAt(InputList.Count - 1);
var InputIntArrList = new List<int[]>();
foreach (string EachStr in InputList) {
int[] WillAdd = EachStr.Split(' ').Select(X => int.Parse(X)).ToArray();
InputIntArrList.Add(WillAdd);
}
//碁盤の2次元配列のListを作成
//List<int[,]> BanArrList = CreateBanArrList(InputIntArrList);
//BanArrList.ForEach(X => Console.WriteLine(CanHeikyokusen(X) ? "Yes" : "No"));
}
//碁盤の2次元配列のListを作成
static List<int[,]> CreateBanArrList(List<int[]> pInputIntArrList)
{
var BanArrList = new List<int[,]>();
var wkLineIntList = new List<int[]>();
int RestHeight = 0;
foreach (int[] EachIntArr in pInputIntArrList) {
if (RestHeight == 0) {
RestHeight = EachIntArr[1];
continue;
}
wkLineIntList.Add(EachIntArr);
if (--RestHeight == 0) {
int[,] wkArr = new int[wkLineIntList[0].GetUpperBound(0) + 1,
wkLineIntList.Count];
for (int Y = 0; Y <= wkLineIntList.Count - 1; Y++) {
for (int X = 0; X <= wkLineIntList[Y].GetUpperBound(0); X++) {
wkArr[X, Y] = wkLineIntList[Y][X];
}
}
BanArrList.Add(wkArr);
wkLineIntList.Clear();
}
}
return BanArrList;
}
struct JyoutaiDef
{
internal int CurrX;
internal int CurrY;
internal List<string> VisitedList;
}
//閉曲線を描くことが可能な遺跡かを返す
static bool CanHeikyokusen(int[,] pBanArr)
{
//石像のないマスの数
int NonSekizouMasuCnt = pBanArr.Cast<int>().Count(X => X == 0);
if (NonSekizouMasuCnt == 0) return false;
int UB_X = pBanArr.GetUpperBound(0);
int UB_Y = pBanArr.GetUpperBound(1);
//石像のないマスから探索開始
int StaX = -1, StaY = -1;
Action wkAct = () =>
{
for (int X = 0; X <= UB_X; X++) {
for (int Y = 0; Y <= UB_Y; Y++) {
if (pBanArr[X, Y] == 0) {
StaX = X; StaY = Y;
return;
}
}
}
};
wkAct();
var stk = new Stack<JyoutaiDef>();
JyoutaiDef WillPush;
WillPush.CurrX = StaX;
WillPush.CurrY = StaY;
WillPush.VisitedList = new List<string>();
WillPush.VisitedList.Add(string.Format("({0},{1})", StaX, StaY));
stk.Push(WillPush);
while (stk.Count > 0) {
JyoutaiDef Popped = stk.Pop();
//クリア判定
if (Popped.VisitedList.Count == NonSekizouMasuCnt) {
//探索開始座標とのマンハッタン距離
int Kyori = Math.Abs(Popped.CurrX - StaX)
+ Math.Abs(Popped.CurrY - StaY);
if (Kyori > 1) continue;
return true;
}
//Push処理
Action<int, int> PushSyori = (pX, pY) =>
{
if (pX < 0 || UB_X < pX) return;
if (pY < 0 || UB_Y < pY) return;
//石像なら訪問不可
if (pBanArr[pX, pY] == 1) return;
//再訪不可
string VisitStr = string.Format("({0},{1})", pX, pY);
if (Popped.VisitedList.Contains(VisitStr)) return;
WillPush.CurrX = pX;
WillPush.CurrY = pY;
WillPush.VisitedList = new List<string>(Popped.VisitedList);
WillPush.VisitedList.Add(VisitStr);
stk.Push(WillPush);
};
PushSyori(Popped.CurrX, Popped.CurrY - 1);
PushSyori(Popped.CurrX, Popped.CurrY + 1);
PushSyori(Popped.CurrX - 1, Popped.CurrY);
PushSyori(Popped.CurrX + 1, Popped.CurrY);
}
return false;
}
} | a.cc:1:7: error: expected nested-name-specifier before 'System'
1 | using System;
| ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
2 | using System.Collections.Generic;
| ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
3 | using System.Linq;
| ^~~~~~
a.cc:7:12: error: 'string' does not name a type
7 | static string InputPattern = "Input2";
| ^~~~~~
a.cc:9:12: error: 'List' does not name a type
9 | static List<string> GetInputList()
| ^~~~
a.cc:53:12: error: 'List' does not name a type
53 | static List<int[,]> CreateBanArrList(List<int[]> pInputIntArrList)
| ^~~~
a.cc:84:9: error: 'internal' does not name a type
84 | internal int CurrX;
| ^~~~~~~~
a.cc:85:9: error: 'internal' does not name a type
85 | internal int CurrY;
| ^~~~~~~~
a.cc:86:9: error: 'internal' does not name a type
86 | internal List<string> VisitedList;
| ^~~~~~~~
a.cc:87:6: error: expected ';' after struct definition
87 | }
| ^
| ;
a.cc:90:36: error: expected primary-expression before ',' token
90 | static bool CanHeikyokusen(int[,] pBanArr)
| ^
a.cc:90:36: error: expected ']' before ',' token
90 | static bool CanHeikyokusen(int[,] pBanArr)
| ^
| ]
a.cc:90:36: error: expected ')' before ',' token
90 | static bool CanHeikyokusen(int[,] pBanArr)
| ~ ^
| )
a.cc:90:37: error: expected unqualified-id before ']' token
90 | static bool CanHeikyokusen(int[,] pBanArr)
| ^
a.cc:161:2: error: expected ';' after class definition
161 | }
| ^
| ;
a.cc: In static member function 'static void Program::Main()':
a.cc:37:9: error: 'List' was not declared in this scope
37 | List<string> InputList = GetInputList();
| ^~~~
a.cc:37:14: error: 'string' was not declared in this scope
37 | List<string> InputList = GetInputList();
| ^~~~~~
a.cc:37:22: error: 'InputList' was not declared in this scope
37 | List<string> InputList = GetInputList();
| ^~~~~~~~~
a.cc:37:34: error: 'GetInputList' was not declared in this scope
37 | List<string> InputList = GetInputList();
| ^~~~~~~~~~~~
a.cc:40:9: error: 'var' was not declared in this scope
40 | var InputIntArrList = new List<int[]>();
| ^~~
a.cc:41:25: error: expected ')' before 'EachStr'
41 | foreach (string EachStr in InputList) {
| ^~~~~~~
a.cc:41:17: note: to match this '('
41 | foreach (string EachStr in InputList) {
| ^
a.cc:41:9: error: 'foreach' was not declared in this scope
41 | foreach (string EachStr in InputList) {
| ^~~~~~~
|
s983132564 | p00236 | C++ | #include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<cassert>
#include<set>
#include<cassert>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define pb push_back
typedef long long ll;
bool vis[10][10];
char m[10][10];
int check[10][10];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
bool isout(int ney,int nex,int r,int c){
return nex==-1||ney==-1||nex==c||ney==r;
}
bool isok(int y,int x,int r,int c){
int all=0,cnt=0;
rep(i,4){
int nex=x+dx[i],ney=y+dy[i];
if (isout(ney,nex,r,c))continue;
all++;
if (m[ney][nex] == '0')cnt++;
}
if (cnt <= 1)return false;
return true;
}
bool vis2[10][10];
void canvisitall(int r,int c,int y,int x,
int &tmp){
if (vis2[y][x])return;
vis2[y][x]=true;
tmp--;
rep(i,4){
int nex=x+dx[i],ney=y+dy[i];
if (isout(ney,nex,r,c)||
m[ney][nex] == '1')continue;
canvisitall(r,c,ney,nex,tmp);
}
}
ll geta(int r,int c){
ll ret=0;
rep(i,r){
rep(j,c)ret=ret*2+vis[i][j];
}
return ret;
}
set<ll> S;
int ini;
bool search(int r,int c,int y,int x,int cnt,
int sy,int sx,int py,int px){
if (cnt==0){
return x==sx && y == sy;
}
if (vis[y][x])return false;
check[y][x]=cnt;
int tmp=cnt+1;
rep(i,r)rep(j,c)vis2[i][j]=vis[i][j];
vis2[sy][sx]=false;
canvisitall(r,c,y,x,tmp);
if ((x!=sx||y!=sy) && tmp != 0){
return false;
}
vis[y][x]=true;
/*
ll tmp2=geta(r,c);
if (S.find(tmp2) != S.end()){
vis[y][x]=false;
return false;
}
S.insert(tmp2);
*
rep(i,4){
int nex=x+dx[i],ney=y+dy[i];
if (isout(ney,nex,r,c)||
m[ney][nex] == '1')continue;
if (nex == px && ney == py)continue;
if (search(r,c,ney,nex,cnt-1,sy,sx,y,x))return true;
}
vis[y][x]=false;
return false;
}
main(){
int r,c;
while(cin>>c>>r && r){
S.clear();
int sx=0,sy=0;
int cnt=0;
bool haveans=true;
rep(i,r){
rep(j,c){
cin>>m[i][j];
if (m[i][j] == '0')sx=j,sy=i,cnt++;
vis[i][j]=false;
}
}
rep(i,r){
rep(j,c){
if (m[i][j]=='0'&&!isok(i,j,r,c))haveans=false;
}
}
ini=cnt;
if (ini == 1||ini == 0){
//cout <<"Yes" << endl;
cout <<"No" << endl;
continue;
}
if (ini > 1 && haveans && search(r,c,sy,sx,cnt,sy,sx,-1,-1))
cout << "Yes" << endl;
else cout <<"No" << endl;
}
return false;
} | a.cc:82:3: error: unterminated comment
82 | /*
| ^
a.cc: In function 'bool search(int, int, int, int, int, int, int, int, int)':
a.cc:80:18: error: expected '}' at end of input
80 | vis[y][x]=true;
| ^
a.cc:64:41: note: to match this '{'
64 | int sy,int sx,int py,int px){
| ^
a.cc:80:12: warning: control reaches end of non-void function [-Wreturn-type]
80 | vis[y][x]=true;
| ~~~~~~~~~^~~~~
|
s441953313 | p00236 | C++ | int w,h;
int d[9][9];
int a[4]={-1,0,1,0};
int X,Y,C,t;
int b=0;
int dfs(int x,int y,int c){
int i=0;
if(!c&&x==X&&y==Y)return 1;
if(d[y][x])return 0;
if(b++ > (1<<19))return 2;
d[y][x]=1;
for(;i<4;i++)if(t=dfs(x+a[i],y+a[(i+1)%4],c-1))return t;
return d[y][x]=0;
}
int main(i,j){
for(;C=0,b=0,scanf("%d%d\n",&w,&h),h;puts(C>3&&dfs(X,Y,C)==1?"Yes":"No")){
memset(d,-1,324);
for(j=1;j<=h;j++)for(i=1;i<=w;i++)scanf("%d",&t),(d[j][i]=t)||(++C,X=i,Y=j);
}
return 0;
} | a.cc:16:5: error: cannot declare '::main' to be a global variable
16 | int main(i,j){
| ^~~~
a.cc:16:10: error: 'i' was not declared in this scope
16 | int main(i,j){
| ^
a.cc:16:12: error: 'j' was not declared in this scope
16 | int main(i,j){
| ^
a.cc:16:13: error: expression list treated as compound expression in initializer [-fpermissive]
16 | int main(i,j){
| ^
|
s260237815 | p00236 | C++ | int w,h;
int d[9][9],q[9][9];
int a[4]={-1,0,1,0};
int X,Y,C,t;
int b=0;
int chk(int x,int y){
int i=0,ans=1;
if(q[y][x])return 0;
q[y][x]=1;
if(d[y][x])return y==Y&&x==X;
for(;i<4;i++)ans+=chk(x+a[i],y+a[(i+1)%4]);
return ans;
}
void output(int a[9][9]){
int i,j;
for(i=1;i<=h;i++){
for(j=1;j<=w;j++)printf("%d",!!a[i][j]);
puts("");
}
}
int dfs(int x,int y,int c){
int i=0;
if(!c&&x==X&&y==Y)return 1;
memset(q,0,324);
if(d[y][x]||chk(x,y) != c+(x!=X||y!=Y))return 0;
if(b++ > 190000)return 2;
d[y][x]=1;
for(;i<4;i++)if(t=dfs(x+a[i],y+a[(i+1)%4],c-1))return t;
return d[y][x]=0;
}
int main(i,j){
for(;C=0,b=0,scanf("%d%d\n",&w,&h),h;puts(C>3&&dfs(X,Y,C)==1?"Yes":"No")){
memset(d,-1,324);
for(j=1;j<=h;j++)for(i=1;i<=w;i++)scanf("%d",&t),(d[j][i]=t)||(++C,X=i,Y=j);
}
return 0;
} | a.cc: In function 'void output(int (*)[9])':
a.cc:18:34: error: 'printf' was not declared in this scope
18 | for(j=1;j<=w;j++)printf("%d",!!a[i][j]);
| ^~~~~~
a.cc:1:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
+++ |+#include <cstdio>
1 | int w,h;
a.cc:19:17: error: 'puts' was not declared in this scope
19 | puts("");
| ^~~~
a.cc: In function 'int dfs(int, int, int)':
a.cc:25:9: error: 'memset' was not declared in this scope
25 | memset(q,0,324);
| ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
+++ |+#include <cstring>
1 | int w,h;
a.cc: At global scope:
a.cc:32:5: error: cannot declare '::main' to be a global variable
32 | int main(i,j){
| ^~~~
a.cc:32:10: error: 'i' was not declared in this scope
32 | int main(i,j){
| ^
a.cc:32:12: error: 'j' was not declared in this scope
32 | int main(i,j){
| ^
a.cc:32:13: error: expression list treated as compound expression in initializer [-fpermissive]
32 | int main(i,j){
| ^
|
s406086427 | p00236 | C++ | int w,h;
int d[9][9],q[9][9];
int a[4]={-1,0,1,0};
int X,Y,C,t;
int b=0;
int chk(int x,int y){
int i=0,ans=1;
if(q[y][x])return 0;
q[y][x]=1;
if(d[y][x])return y==Y&&x==X;
for(;i<4;i++)ans+=chk(x+a[i],y+a[(i+1)%4]);
return ans;
}
int dfs(int x,int y,int c){
int i=0;
if(!c&&x==X&&y==Y)return 1;
memset(q,0,324),
if(d[y][x]||chk(x,y) != c+(x!=X||y!=Y))return 0;
if(b++ > 120000)return 2;
d[y][x]=1;
for(;i<4;i++)if(t=dfs(x+a[i],y+a[(i+1)%4],c-1))return t;
return d[y][x]=0;
}
int main(i,j){
for(;C=0,b=0,scanf("%d%d\n",&w,&h),h;puts(C>3&&dfs(X,Y,C)==1?"Yes":"No")){
memset(d,-1,324);
for(j=0;j++<h;)for(i=0;i++<w;i++)scanf("%d",&t),(d[j][i]=t)||(++C,X=i,Y=j);
}
return 0;
} | a.cc: In function 'int dfs(int, int, int)':
a.cc:17:9: error: 'memset' was not declared in this scope
17 | memset(q,0,324),
| ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
+++ |+#include <cstring>
1 | int w,h;
a.cc:18:9: error: expected primary-expression before 'if'
18 | if(d[y][x]||chk(x,y) != c+(x!=X||y!=Y))return 0;
| ^~
a.cc: At global scope:
a.cc:24:5: error: cannot declare '::main' to be a global variable
24 | int main(i,j){
| ^~~~
a.cc:24:10: error: 'i' was not declared in this scope
24 | int main(i,j){
| ^
a.cc:24:12: error: 'j' was not declared in this scope
24 | int main(i,j){
| ^
a.cc:24:13: error: expression list treated as compound expression in initializer [-fpermissive]
24 | int main(i,j){
| ^
|
s750112649 | p00236 | C++ |
#include<cstdio>
int table[7][7],a,b,l,m;
int solve(int x,int y,int z){
if(z==a*b)return (x==l&&y==m)?1:0;
if(x<0 || x>=b || y<0 || y>=a ||table[x][y]==1) return 0;
table[x][y]=1;
int res=0;
res=solve(x+xx[0],y+yy[0],z+1)||solve(x+xx[1],y+yy[1],z+1)||solve(x+xx[2],y+yy[2],z+1)||solve(x+xx[3],y+yy[3],z+1);
table[x][y]=0;
return res;
}
int main(){
while(scanf("%d%d",&a,&b),a,b){
int z=0;
for(int i=0;i<b;i++){
for(int j=0;j<a;j++){
scanf("%d",&table[j][i]);
z+=table[j][i];
if(table[j][i]==0)l=j,m=i;
}
}
puts(solve(l,m,z)?"Yes":"No");
}
} | a.cc: In function 'int solve(int, int, int)':
a.cc:10:21: error: 'xx' was not declared in this scope; did you mean 'x'?
10 | res=solve(x+xx[0],y+yy[0],z+1)||solve(x+xx[1],y+yy[1],z+1)||solve(x+xx[2],y+yy[2],z+1)||solve(x+xx[3],y+yy[3],z+1);
| ^~
| x
a.cc:10:29: error: 'yy' was not declared in this scope; did you mean 'y'?
10 | res=solve(x+xx[0],y+yy[0],z+1)||solve(x+xx[1],y+yy[1],z+1)||solve(x+xx[2],y+yy[2],z+1)||solve(x+xx[3],y+yy[3],z+1);
| ^~
| y
|
s187464281 | p00237 | C++ | 3 4
1 0 3 0 2 1
2 3 2 5 3 4
5 3 5 5 6 4
3 2
1 0 3 0 2 1
2 3 2 5 3 4
5 3 5 5 6 4
0 0 | a.cc:1:1: error: expected unqualified-id before numeric constant
1 | 3 4
| ^
|
s773571741 | p00237 | C++ | #include <bits/stdc++.h>
using namespace std;
namespace geometry {
// ???????????§??????
typedef complex<double> Point;
struct Segment {
Point p1, p2;
Segment(const Point &p1 = Point(), const Point &p2 = Point()): p1(p1), p2(p2){}
};
struct Circle {
Point p;
double r;
Circle(const Point &p = Point(), double r = 0.0): p(p), r(r){}
};
typedef Point Vector;
typedef Segment Line;
typedef vector<Point> Polygon;
// ??\??????
inline istream & operator >> (istream &is, Point &p){
double x, y;
is >> x >> y;
p.real(x), p.imag(y);
return is;
}
inline istream & operator >> (istream &is, Segment &s){
return is >> s.p1 >> s.p2;
}
inline istream & operator >> (istream &is, Circle &c){
return is >> c.p >> c.r;
}
inline ostream & operator << (ostream &os, Segment &s){
return os << "{" << s.p1 << ", " << s.p2 << "}";
}
inline ostream & operator << (ostream &os, Circle &c){
return os << "{" << c.p << ", " << c.r << "}";
}
inline ostream & operator << (ostream &os, Polygon &g){
os << "{";
for (int i = 0; i < g.size(); i++){
if (i) os << ", ";
os << g[i];
}
return os << "}";
}
// ?????°, ??????
const double PI = acos(-1);
const double EPS = 1e-2;
const double INF = 1e16;
const int COUNTER_CLOCKWISE = 1;
const int CLOCKWISE = -1;
const int ONLINE_BACK = 2;
const int ONLINE_FRONT = -2;
const int ON_SEGMENT = 0;
const int OUT = 0;
const int ON = 1;
const int IN = 2;
inline double square(double a){return a * a;}
inline bool equal(double a, double b){return abs(a - b) < EPS;}
inline bool equalVector(const Vector &a, const Vector &b){return equal(a.real(), b.real()) && equal(a.imag(), b.imag());}
inline double norm(const Point &a){return square(a.real()) + square(a.imag());}
inline double dot(const Point &a, const Point &b){return (conj(a) * b).real();}
inline double cross(const Point &a, const Point &b){return (conj(a) * b).imag();}
inline double toDeg(double t){return t / PI * 180;}
inline double toRad(double t){return t / 180 * PI;}
#define curr(v, i) v[i]
#define next(v, i) v[(i + 1) % v.size()]
#define prev(v, i) v[(i - 1 + v.size()) % v.size()]
// ????????¢??° (x ??§?¨?, y ??§?¨?, ????§?)
// ????§?????????????????????? Point rp ?????£??\????????????
bool cmpx(const Point &a, const Point &b){
if (!equal(a.real(), b.real())) return a.real() < b.real();
return b.imag() < b.imag();
}
bool cmpy(const Point &a, const Point &b){
if (!equal(a.imag(), b.imag())) return a.imag() < b.imag();
return a.real() < b.real();
}
Point rp;
bool cmparg(const Point &a, const Point &b){
double rada = arg(a - rp); if (rada < 0.0) rada += 2 * PI;
double radb = arg(b - rp); if (radb < 0.0) radb += 2 * PI;
if (!equal(rada, radb)) return rada < radb;
return norm(a) < norm(b);
}
// ??´???, ??????
bool orthgonal(const Vector &a, const Vector &b){
return equal(dot(a, b), 0.0);
}
bool parallel(const Vector &a, const Vector &b){
return equal(cross(a, b), 0.0);
}
// ????°?, ?°???±
Point project(const Segment &s, const Point &p){
Vector base = s.p2 - s.p1;
double r = dot(p - s.p1, base) / norm(base);
return s.p1 + base * r;
}
Point reflect(const Segment &s, const Point &p){
return p + (project(s, p) - p) * 2.0;
}
// ??????????????????
int ccw(const Point &p0, const Point &p1, const Point &p2){
Vector a = p1 - p0;
Vector b = p2 - p0;
if (cross(a, b) > EPS) return COUNTER_CLOCKWISE;
if (cross(a, b) < -EPS) return CLOCKWISE;
if (dot(a, b) < -EPS) return ONLINE_BACK;
if (norm(a) > norm(b)) return ONLINE_FRONT;
return ON_SEGMENT;
}
// ?????¢
double distanceLP(const Line &l, const Point &p){
return abs(cross(l.p2 - l.p1, p - l.p1) / abs(l.p2 - l.p1));
}
double distanceSP(const Segment &s, const Point &p){
if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return abs(p - s.p1);
if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return abs(p - s.p2);
return distanceLP(s, p);
}
bool intersect(const Segment &s1, const Segment &s2);
double distance(const Segment &s1, const Segment &s2){
if (intersect(s1, s2)) return 0.0;
return min(
min(distanceSP(s1, s2.p1), distance(s1, s2.p2)),
min(distanceSP(s2, s1.p1), distance(s2, s1.p2))
);
}
// ????????????
bool intersect(const Segment &s1, const Segment &s2){
return ccw(s1.p1, s1.p2, s2.p1) * ccw(s1.p1, s1.p2, s2.p2) <= 0 &&
ccw(s2.p1, s2.p2, s1.p1) * ccw(s2.p1, s2.p2, s1.p2) <= 0;
}
int intersect(const Circle &c, const Segment &s){
// ???????????° (0 ~ 2) ?????????
double dist = distanceSP(s, c.p) - c.r;
if (equal(dist, 0.0)) return 1;
if (dist < 0.0) return 2;
return 0;
}
int intersect(const Circle &c1, const Circle &c2){
// ???????????° (0 ~ 2) ?????????
double dist = abs(c1.p - c2.p) - (c1.r + c2.r);
if (equal(dist, 0.0)) return 1;
if (dist < 0.0) return 2;
return 0;
}
// ??????
Point crossPoint(const Segment &s1, const Segment &s2){
Vector base = s2.p2 - s2.p1;
double d1 = abs(cross(base, s1.p1 - s2.p1));
double d2 = abs(cross(base, s1.p2 - s2.p1));
// !! ????????´?????¶????????????????????\????????¨ 0 ?????? !!
assert(!equal(d1 + d2, 0.0));
double t = d1 / (d1 + d2);
return s1.p1 + (s1.p2 - s1.p1) * t;
}
vector<Point> crossPoints(const Circle &c, const Line &l){
vector<Point> res;
if (!intersect(c, l)) return res;
Vector pr = project(l, c.p);
Vector e = (l.p2 - l.p1) / abs(l.p2 - l.p1);
double base = sqrt(c.r * c.r - norm(pr - c.p));
res.push_back(pr + e * base);
res.push_back(pr - e * base);
if (equalVector(res[0], res[1])) res.pop_back();
return res;
}
vector<Point> crossPoints(const Circle &c1, const Circle &c2){
vector<Point> res;
if (!intersect(c1, c2)) return res;
double d = abs(c1.p - c2.p);
double a = acos(square(c1.r) + square(d) - square(c2.r) / (2 * c2.r * d));
double t = arg(c2.p - c1.p);
res.push_back(c1.p + polar(c1.r, t + a));
res.push_back(c1.p + polar(c1.r, t - a));
if (equalVector(res[0], res[1])) res.pop_back();
}
// ??????
int contains(const Polygon &g, const Point &p){
int n = g.size();
bool res = false;
for (int i = 0; i < n; i++){
Point a = g[i] - p;
Point b = g[(i + 1) % n] - p;
if (abs(cross(a, b)) < EPS && dot(a, b) < EPS) return ON;
if (a.imag() > b.imag()) swap(a, b);
if (a.imag() < EPS && EPS < b.imag() && cross(a, b) > EPS) res = !res;
}
return res ? IN : OUT;
}
// ??????
Polygon convexHull(vector<Point> s){
Polygon u, l;
if (s.size() < 3) return s;
sort(s.begin(), s.end());
u.push_back(s[0]);
u.push_back(s[1]);
l.push_back(s[s.size() - 1]);
l.push_back(s[s.size() - 2]);
for (int i = 2; i < s.size(); i++){
int n = u.size();
while (n >= 2 && ccw(u[n - 2], u[n - 1], s[i]) != CLOCKWISE){
u.pop_back();
n--;
}
u.push_back(s[i]);
}
for (int i = s.size() - 3; i >= 0; i--){
int n = l.size();
while (n >= 2 && ccw(l[n - 2], l[n - 1], s[i]) != CLOCKWISE){
l.pop_back();
n--;
}
l.push_back(s[i]);
}
reverse(l.begin(), l.end());
for (int i = u.size() - 2; i >= 1; i--){
l.push_back(u[i]);
}
return l;
}
// ???????§???¢??????
Polygon convexCut(const Polygon &g, const Line &l){
Polygon res;
for (int i = 0; i < g.size(); i++){
const Point &a = curr(g, i);
const Point &b = next(g, i);
if (ccw(l.p1, l.p2, a) != CLOCKWISE){
res.push_back(a);
}
if (ccw(l.p1, l.p2, a) * ccw(l.p1, l.p2, b) < 0){
res.push_back(crossPoint(Line(a, b), l));
}
}
return res;
}
}
namespace std {
bool operator < (const geometry::Point &a, const geometry::Point &b){
return geometry::cmpx(a, b);
}
}
using namespace geometry;
bool intersect(const Polygon &g, const Polygon &h)
{
for (int i = 0; i < g.size(); i++){
for (int j = 0; j < h.size(); j++){
Segment u(curr(g, i), next(g, i));
Segment v(curr(h, j), next(h, j));
if (intersect(u, v)) return true;
}
}
for (int i = 0; i < g.size(); i++){
if (contain(h, g[i])) return true;
}
for (int i = 0; i < h.size(); i++){
if (contain(g, h[i])) return true;
}
return false;
}
int n;
double d;
Polygon tri[100];
Polygon sqr[100];
vector<int> graph[100];
vector<int> rgraph[100];
void dfs(int v, vector<int> &vs, vector<bool> &used)
{
used[v] = true;
for (int to : graph[v]){
if (!used[to]) dfs(to, vs, used);
}
vs.push_back(v);
}
void rdfs(int v, int k, vector<bool> &used, vector<int> &cmp)
{
used[v] = true;
cmp[v] = k;
for (int to : rgraph[v]){
if (!used[to]) rdfs(to, k, used, cmp);
}
}
vector<vector<int>> scc()
{
vector<int> vs;
vector<bool> used(n, false);
vector<int> cmp(n);
for (int i = 0; i < n; i++){
if (!used[i]) dfs(i, vs, used);
}
used.assign(n, false);
int k = 0;
for (int i = vs.size() - 1; i >= 0; i--){
if (!used[vs[i]]) rdfs(vs[i], k++, used, cmp);
}
vector<vector<int>> res(k);
for (int i = 0; i < n; i++){
for (int to : graph[i]){
if (cmp[i] == cmp[to]) continue;
res[cmp[i]].push_back(cmp[to]);
}
}
return res;
}
int solve()
{
for (int i = 0; i < n; i++){
for (int j = 0; j < 3; j++){
Point &a = curr(tri[i], j);
Point &b = prev(tri[i], j);
Point &c = next(tri[i], j);
if (equal(abs(b - a), abs(c - a))){
swap(a, tri[i][2]);
break;
}
}
//cout << abs(tri[i][2] - tri[i][0]) << " " << abs(tri[i][2] - tri[i][1]) << endl;
assert(equal(abs(tri[i][2] - tri[i][0]), abs(tri[i][2] - tri[i][1])));
}
for (int i = 0; i < n; i++){
sqr[i].resize(4);
vector<Vector> V = {{0, 1}, {0, -1}};
bool f = false;
for (auto &v : V){
Vector a = tri[i][1] - tri[i][0];
Vector nv = a / abs(a) * v * d;
if (dot(tri[i][2] - tri[i][0], nv) < 0.0) continue;
sqr[i][0] = tri[i][0];
sqr[i][1] = tri[i][1];
sqr[i][2] = tri[i][1] + nv;
sqr[i][3] = tri[i][0] + nv;
f = true;
}
assert(f);
}
for (int i = 0; i < n; i++){
graph[i].clear();
rgraph[i].clear();
}
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
if (i == j) continue;
if (intersect(sqr[i], tri[j])){
graph[i].push_back(j);
rgraph[j].push_back(i);
}
}
}
vector<vector<int>> sccgraph = scc();
vector<int> indeg(sccgraph.size(), 0);
for (int i = 0; i < sccgraph.size(); i++){
for (int to : sccgraph[i]){
if (i == to) continue;
indeg[to]++;
}
}
int res = 0;
for (int i = 0; i < sccgraph.size(); i++){
if (indeg[i] == 0) res++;
}
return res;
}
int main()
{
while (cin >> n >> d, n){
for (int i = 0; i < n; i++){
tri[i].resize(3);
for (int j = 0; j < 3; j++){
cin >> tri[i][j];
}
}
cout << solve() << endl;
}
return 0;
} | a.cc: In function 'bool intersect(const geometry::Polygon&, const geometry::Polygon&)':
a.cc:326:21: error: 'contain' was not declared in this scope
326 | if (contain(h, g[i])) return true;
| ^~~~~~~
a.cc:329:21: error: 'contain' was not declared in this scope
329 | if (contain(g, h[i])) return true;
| ^~~~~~~
a.cc: In function 'std::vector<std::complex<double> > geometry::crossPoints(const Circle&, const Circle&)':
a.cc:230:9: warning: control reaches end of non-void function [-Wreturn-type]
230 | }
| ^
|
s009355442 | p00237 | C++ | #include <bits/stdc++.h>
using namespace std;
namespace geometry {
// ???????????§??????
typedef complex<double> Point;
struct Segment {
Point p1, p2;
Segment(const Point &p1 = Point(), const Point &p2 = Point()): p1(p1), p2(p2){}
};
struct Circle {
Point p;
double r;
Circle(const Point &p = Point(), double r = 0.0): p(p), r(r){}
};
typedef Point Vector;
typedef Segment Line;
typedef vector<Point> Polygon;
// ??\??????
inline istream & operator >> (istream &is, Point &p){
double x, y;
is >> x >> y;
p.real(x), p.imag(y);
return is;
}
inline istream & operator >> (istream &is, Segment &s){
return is >> s.p1 >> s.p2;
}
inline istream & operator >> (istream &is, Circle &c){
return is >> c.p >> c.r;
}
inline ostream & operator << (ostream &os, Segment &s){
return os << "{" << s.p1 << ", " << s.p2 << "}";
}
inline ostream & operator << (ostream &os, Circle &c){
return os << "{" << c.p << ", " << c.r << "}";
}
inline ostream & operator << (ostream &os, Polygon &g){
os << "{";
for (int i = 0; i < g.size(); i++){
if (i) os << ", ";
os << g[i];
}
return os << "}";
}
// ?????°, ??????
const double PI = acos(-1);
const double EPS = 1e-2;
const double INF = 1e16;
const int COUNTER_CLOCKWISE = 1;
const int CLOCKWISE = -1;
const int ONLINE_BACK = 2;
const int ONLINE_FRONT = -2;
const int ON_SEGMENT = 0;
const int OUT = 0;
const int ON = 1;
const int IN = 2;
inline double square(double a){return a * a;}
inline bool equal(double a, double b){return abs(a - b) < EPS;}
inline bool equalVector(const Vector &a, const Vector &b){return equal(a.real(), b.real()) && equal(a.imag(), b.imag());}
inline double norm(const Point &a){return square(a.real()) + square(a.imag());}
inline double dot(const Point &a, const Point &b){return (conj(a) * b).real();}
inline double cross(const Point &a, const Point &b){return (conj(a) * b).imag();}
inline double toDeg(double t){return t / PI * 180;}
inline double toRad(double t){return t / 180 * PI;}
#define curr(v, i) v[i]
#define next(v, i) v[(i + 1) % v.size()]
#define prev(v, i) v[(i - 1 + v.size()) % v.size()]
// ????????¢??° (x ??§?¨?, y ??§?¨?, ????§?)
// ????§?????????????????????? Point rp ?????£??\????????????
bool cmpx(const Point &a, const Point &b){
if (!equal(a.real(), b.real())) return a.real() < b.real();
return b.imag() < b.imag();
}
bool cmpy(const Point &a, const Point &b){
if (!equal(a.imag(), b.imag())) return a.imag() < b.imag();
return a.real() < b.real();
}
Point rp;
bool cmparg(const Point &a, const Point &b){
double rada = arg(a - rp); if (rada < 0.0) rada += 2 * PI;
double radb = arg(b - rp); if (radb < 0.0) radb += 2 * PI;
if (!equal(rada, radb)) return rada < radb;
return norm(a) < norm(b);
}
// ??´???, ??????
bool orthgonal(const Vector &a, const Vector &b){
return equal(dot(a, b), 0.0);
}
bool parallel(const Vector &a, const Vector &b){
return equal(cross(a, b), 0.0);
}
// ????°?, ?°???±
Point project(const Segment &s, const Point &p){
Vector base = s.p2 - s.p1;
double r = dot(p - s.p1, base) / norm(base);
return s.p1 + base * r;
}
Point reflect(const Segment &s, const Point &p){
return p + (project(s, p) - p) * 2.0;
}
// ??????????????????
int ccw(const Point &p0, const Point &p1, const Point &p2){
Vector a = p1 - p0;
Vector b = p2 - p0;
if (cross(a, b) > EPS) return COUNTER_CLOCKWISE;
if (cross(a, b) < -EPS) return CLOCKWISE;
if (dot(a, b) < -EPS) return ONLINE_BACK;
if (norm(a) > norm(b)) return ONLINE_FRONT;
return ON_SEGMENT;
}
// ?????¢
double distanceLP(const Line &l, const Point &p){
return abs(cross(l.p2 - l.p1, p - l.p1) / abs(l.p2 - l.p1));
}
double distanceSP(const Segment &s, const Point &p){
if (dot(s.p2 - s.p1, p - s.p1) < 0.0) return abs(p - s.p1);
if (dot(s.p1 - s.p2, p - s.p2) < 0.0) return abs(p - s.p2);
return distanceLP(s, p);
}
bool intersect(const Segment &s1, const Segment &s2);
double distance(const Segment &s1, const Segment &s2){
if (intersect(s1, s2)) return 0.0;
return min(
min(distanceSP(s1, s2.p1), distance(s1, s2.p2)),
min(distanceSP(s2, s1.p1), distance(s2, s1.p2))
);
}
// ????????????
bool intersect(const Segment &s1, const Segment &s2){
return ccw(s1.p1, s1.p2, s2.p1) * ccw(s1.p1, s1.p2, s2.p2) <= 0 &&
ccw(s2.p1, s2.p2, s1.p1) * ccw(s2.p1, s2.p2, s1.p2) <= 0;
}
int intersect(const Circle &c, const Segment &s){
// ???????????° (0 ~ 2) ?????????
double dist = distanceSP(s, c.p) - c.r;
if (equal(dist, 0.0)) return 1;
if (dist < 0.0) return 2;
return 0;
}
int intersect(const Circle &c1, const Circle &c2){
// ???????????° (0 ~ 2) ?????????
double dist = abs(c1.p - c2.p) - (c1.r + c2.r);
if (equal(dist, 0.0)) return 1;
if (dist < 0.0) return 2;
return 0;
}
// ??????
Point crossPoint(const Segment &s1, const Segment &s2){
Vector base = s2.p2 - s2.p1;
double d1 = abs(cross(base, s1.p1 - s2.p1));
double d2 = abs(cross(base, s1.p2 - s2.p1));
// !! ????????´?????¶????????????????????\????????¨ 0 ?????? !!
assert(!equal(d1 + d2, 0.0));
double t = d1 / (d1 + d2);
return s1.p1 + (s1.p2 - s1.p1) * t;
}
vector<Point> crossPoints(const Circle &c, const Line &l){
vector<Point> res;
if (!intersect(c, l)) return res;
Vector pr = project(l, c.p);
Vector e = (l.p2 - l.p1) / abs(l.p2 - l.p1);
double base = sqrt(c.r * c.r - norm(pr - c.p));
res.push_back(pr + e * base);
res.push_back(pr - e * base);
if (equalVector(res[0], res[1])) res.pop_back();
return res;
}
vector<Point> crossPoints(const Circle &c1, const Circle &c2){
vector<Point> res;
if (!intersect(c1, c2)) return res;
double d = abs(c1.p - c2.p);
double a = acos(square(c1.r) + square(d) - square(c2.r) / (2 * c2.r * d));
double t = arg(c2.p - c1.p);
res.push_back(c1.p + polar(c1.r, t + a));
res.push_back(c1.p + polar(c1.r, t - a));
if (equalVector(res[0], res[1])) res.pop_back();
}
// ??????
int contains(const Polygon &g, const Point &p){
int n = g.size();
bool res = false;
for (int i = 0; i < n; i++){
Point a = g[i] - p;
Point b = g[(i + 1) % n] - p;
if (abs(cross(a, b)) < EPS && dot(a, b) < EPS) return ON;
if (a.imag() > b.imag()) swap(a, b);
if (a.imag() < EPS && EPS < b.imag() && cross(a, b) > EPS) res = !res;
}
return res ? IN : OUT;
}
// ??????
Polygon convexHull(vector<Point> s){
Polygon u, l;
if (s.size() < 3) return s;
sort(s.begin(), s.end());
u.push_back(s[0]);
u.push_back(s[1]);
l.push_back(s[s.size() - 1]);
l.push_back(s[s.size() - 2]);
for (int i = 2; i < s.size(); i++){
int n = u.size();
while (n >= 2 && ccw(u[n - 2], u[n - 1], s[i]) != CLOCKWISE){
u.pop_back();
n--;
}
u.push_back(s[i]);
}
for (int i = s.size() - 3; i >= 0; i--){
int n = l.size();
while (n >= 2 && ccw(l[n - 2], l[n - 1], s[i]) != CLOCKWISE){
l.pop_back();
n--;
}
l.push_back(s[i]);
}
reverse(l.begin(), l.end());
for (int i = u.size() - 2; i >= 1; i--){
l.push_back(u[i]);
}
return l;
}
// ???????§???¢??????
Polygon convexCut(const Polygon &g, const Line &l){
Polygon res;
for (int i = 0; i < g.size(); i++){
const Point &a = curr(g, i);
const Point &b = next(g, i);
if (ccw(l.p1, l.p2, a) != CLOCKWISE){
res.push_back(a);
}
if (ccw(l.p1, l.p2, a) * ccw(l.p1, l.p2, b) < 0){
res.push_back(crossPoint(Line(a, b), l));
}
}
return res;
}
}
namespace std {
bool operator < (const geometry::Point &a, const geometry::Point &b){
return geometry::cmpx(a, b);
}
}
using namespace geometry;
bool intersect(const Polygon &g, const Polygon &h)
{
for (int i = 0; i < g.size(); i++){
for (int j = 0; j < h.size(); j++){
Segment u(curr(g, i), next(g, i));
Segment v(curr(h, j), next(h, j));
if (intersect(u, v)) return true;
}
}
for (int i = 0; i < g.size(); i++){
if (contains(h, g[i])) return true;
}
for (int i = 0; i < h.size(); i++){
if (contains(g, h[i])) return true;
}
return false;
}
int n;
double d;
Polygon tri[100];
Polygon sqr[100];
vector<int> graph[100];
vector<int> rgraph[100];
void dfs(int v, vector<int> &vs, vector<bool> &used)
{
used[v] = true;
for (int to : graph[v]){
if (!used[to]) dfs(to, vs, used);
}
vs.push_back(v);
}
void rdfs(int v, int k, vector<bool> &used, vector<int> &cmp)
{
used[v] = true;
cmp[v] = k;
for (int to : rgraph[v]){
if (!used[to]) rdfs(to, k, used, cmp);
}
}
vector<vector<int>> scc()
{
vector<int> vs;
vector<bool> used(n, false);
vector<int> cmp(n);
for (int i = 0; i < n; i++){
if (!used[i]) dfs(i, vs, used);
}
used.assign(n, false);
int k = 0;
for (int i = vs.size() - 1; i >= 0; i--){
if (!used[vs[i]]) rdfs(vs[i], k++, used, cmp);
}
vector<vector<int>> res(k);
for (int i = 0; i < n; i++){
for (int to : graph[i]){
if (cmp[i] == cmp[to]) continue;
res[cmp[i]].push_back(cmp[to]);
}
}
return res;
}
int solve()
{
for (int i = 0; i < n; i++){
for (int j = 0; j < 3; j++){
Point &a = curr(tri[i], j);
Point &b = prev(tri[i], j);
Point &c = next(tri[i], j);
if (equal(abs(b - a), abs(c - a))){
swap(a, tri[i][2]);
break;
}
}
//cout << abs(tri[i][2] - tri[i][0]) << " " << abs(tri[i][2] - tri[i][1]) << endl;
assert(equal(abs(tri[i][2] - tri[i][0]), abs(tri[i][2] - tri[i][1])));
}
for (int i = 0; i < n; i++){
sqr[i].resize(4);
vector<Vector> V = {{0, 1}, {0, -1}};
bool f = false;
for (auto &v : V){
Vector a = tri[i][1] - tri[i][0];
Vector nv = a / abs(a) * v * d;
if (dot(tri[i][2] - tri[i][0], nv) < 0.0) continue;
sqr[i][0] = tri[i][0];
sqr[i][1] = tri[i][1];
sqr[i][2] = tri[i][1] + nv;
sqr[i][3] = tri[i][0] + nv;
f = true;
}
assert(f);
}
for (int i = 0; i < n; i++){
graph[i].clear();
rgraph[i].clear();
}
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
if (i == j) continue;
if (intersect(sqr[i], tri[j])){
graph[i].push_back(j);
rgraph[j].push_back(i);
}
}
}
vector<vector<int>> sccgraph = scc();
vector<int> indeg(sccgraph.size(), 0);
for (int i = 0; i < sccgraph.size(); i++){
for (int to : sccgraph[i]){
if (i == to) continue;
indeg[to]++;
}
}
int res = 0;
for (int i = 0; i < n; i++){
if (indeg[cmp[i]] == 0) res++;
}
return res;
}
int main()
{
while (cin >> n >> d, n){
for (int i = 0; i < n; i++){
tri[i].resize(3);
for (int j = 0; j < 3; j++){
cin >> tri[i][j];
}
}
cout << solve() << endl;
}
return 0;
} | a.cc: In function 'int solve()':
a.cc:454:27: error: 'cmp' was not declared in this scope; did you mean 'bcmp'?
454 | if (indeg[cmp[i]] == 0) res++;
| ^~~
| bcmp
a.cc: In function 'std::vector<std::complex<double> > geometry::crossPoints(const Circle&, const Circle&)':
a.cc:230:9: warning: control reaches end of non-void function [-Wreturn-type]
230 | }
| ^
|
s508680802 | p00237 | C++ | #include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#define MAX_N (128)
#define EPS (0.01)
#define SQ(X) ((X) * (X))
using namespace std;
class Triangle {
public:
double x[3], y[3];
int no;
};
class Point {
public:
double x, y;
Point Point::operator - (Point &a){
Point ret;
ret.x = x - a.x;
ret.y = y - a.y;
return (ret);
}
};
vector<int> G[MAX_N];
vector<int> rG[MAX_N];
vector<int> compress[MAX_N];
vector<int> vs;
bool used[MAX_N];
bool group[MAX_N];
int cmp[MAX_N];
int N;
void addEdge(int from, int to)
{
G[from].push_back(to);
rG[to].push_back(from);
}
void dfs(int v)
{
used[v] = true;
for (int i = 0; i < G[v].size(); i++){
if (!used[G[v][i]]){
dfs(G[v][i]);
}
}
vs.push_back(v);
}
void revDfs(int v, int k)
{
used[v] = true;
cmp[v] = k;
for (int i = 0; i < rG[v].size(); i++){
if (!used[rG[v][i]]){
revDfs(rG[v][i], k);
}
}
}
int scc()
{
int ret;
memset(used, 0, sizeof(used));
vs.clear();
for (int i = 0; i < N; i++){
if (!used[i]){
dfs(i);
}
}
memset(used, 0, sizeof(used));
ret = 0;
for (int i = vs.size() - 1; i >= 0; i--){
if (!used[vs[i]]){
revDfs(vs[i], ret++);
}
}
for (int i = 0; i < N; i++){
for (int j = 0; j < G[i].size(); j++){
if (cmp[i] != cmp[G[i][j]]){
compress[cmp[G[i][j]]].push_back(cmp[i]);
}
}
}
return (ret);
}
double inProduct(Point a, Point b)
{
return (a.x * b.x + a.y * b.y);
}
double getSize(Point a)
{
return (sqrt(SQ(a.x) + SQ(a.y)));
}
bool checkCross(Point p1, Point p2, Point p3, Point p4)
{
double check1 = (p2.x - p1.x) * (p4.y - p3.y) - (p2.y - p1.y) * (p4.x - p3.x);
Point pq = p3 - p1;
double check2 = (p4.y - p3.y) * pq.x - (p4.x - p3.x) * pq.y;
double check3 = (p2.y - p1.y) * pq.x - (p2.x - p1.x) * pq.y;
if (check1 > EPS){
return (0 <= check3 / check1 && check3 / check1 <= 1 && 0 <= check2 / check1 && check2 / check1 <= 1);
}
return (fabs(check2) <= EPS && fabs(check3) <= EPS);
}
void judgeAdj(Triangle a, Triangle b, double dist)
{
double len;
Point p[4];
len = 0.0;
for (int i = 0; i < 3; i++){
for (int j = i + 1; j < 3; j++){
if (len < SQ(a.x[i] - a.x[j]) + SQ(a.y[i] - a.y[j])){
len = SQ(a.x[i] - a.x[j]) + SQ(a.y[i] - a.y[j]);
p[0].x = a.x[i], p[0].y = a.y[i];
p[1].x = a.x[j], p[1].y = a.y[j];
}
}
}
//printf("%lf %lf %lf %lf\n", p[0].x, p[0].y, p[1].x, p[1].y);
Point e, sa;
e.x = 0, e.y = 1;
sa = p[0] - p[1];
double theta = acos(inProduct(e, sa) / (getSize(e) * getSize(sa)));
theta = min(theta, M_PI - theta);
//printf("theta = %lf\n", theta);
p[2].x = p[0].x + dist * cos(theta), p[2].y = p[0].y + dist * sin(theta);
p[3].x = p[1].x + dist * cos(theta), p[3].y = p[1].y + dist * sin(theta);
bool cross = false;
for (int i = 0; i < 3; i++){
for (int j = i + 1; j < 3; j++){
Point k[2];
k[0].x = b.x[i], k[0].y = b.y[i];
k[1].x = b.x[j], k[1].y = b.y[j];
cross |= checkCross(k[0], k[1], p[0], p[1]);
cross |= checkCross(k[0], k[1], p[0], p[2]);
cross |= checkCross(k[0], k[1], p[1], p[3]);
cross |= checkCross(k[0], k[1], p[2], p[3]);
}
}
if (cross == true){
//printf("hoge, %d, %d\n", a.no, b.no);
addEdge(a.no, b.no);
}
}
int main()
{
int n, d;
Triangle data[128];
while (1){
scanf("%d %d", &n, &d);
N = n;
if (n + d == 0){
break;
}
for (int i = 0; i < n; i++){
data[i].no = i;
for (int j = 0; j < 3; j++){
scanf("%lf%lf", &data[i].x[j], &data[i].y[j]);
}
}
for (int i = 0; i < n; i++){
G[i].clear();
rG[i].clear();
compress[i].clear();
}
for (int i = 0; i < n; i++){
for (int j = 0; j < n; j++){
if (i != j){
judgeAdj(data[i], data[j], d);
}
}
}
int k = scc();
int ans = 0;
memset(used, 0, sizeof(used));
for (int i = 0; i < k; i++){
if (compress[i].size() == 0){
ans++;
}
}
printf("%d\n", ans);
}
return (0);
} | a.cc:22:19: error: extra qualification 'Point::' on member 'operator-' [-fpermissive]
22 | Point Point::operator - (Point &a){
| ^~~~~
a.cc: In function 'int scc()':
a.cc:70:5: error: 'memset' was not declared in this scope
70 | memset(used, 0, sizeof(used));
| ^~~~~~
a.cc:5:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
4 | #include <algorithm>
+++ |+#include <cstring>
5 |
a.cc: In function 'int main()':
a.cc:212:9: error: 'memset' was not declared in this scope
212 | memset(used, 0, sizeof(used));
| ^~~~~~
a.cc:212:9: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
|
s815038956 | p00237 | C++ | #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <cassert>
#include <memory>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
const double EPS = 0.01;
typedef complex<double> P,point;
typedef vector<P> G,polygon;
namespace std {bool operator < (const P& a, const P& b) {return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);} }
double cross(const P& a, const P& b) {return imag(conj(a)*b);}
double dot(const P& a, const P& b) {return real(conj(a)*b);}
struct L : public vector<P> {L(const P &a, const P &b) {push_back(a); push_back(b);} };
int ccw(P a, P b, P c) {
b -= a; c -= a;
if (cross(b, c) > 0) return +1;
if (cross(b, c) < 0) return -1;
if (dot(b, c) < 0) return +2;
if (norm(b) < norm(c)) return -2;
return 0;
}
bool intersectSS(const L &s, const L &t) {return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 && ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;}
#define curr(P, i) P[i]
#define next(P, i) P[(i+1)%P.size()]
double area(vector<P> p){
double S = 0 ;
p.push_back(p[0]);
/* 多角形の面積公式 (反時計回りの場合) */
for(int i = 0 ; i < p.size()-1 ; i++){
S += (p[i].real() - p[i+1].real()) * (p[i].imag()+p[i+1].imag());
}
S /= 2.0;
return S;
}
bool contains(vector<P> &a,P b){
//b = (-10000,-10000);
double ans = 0;
for(int i = 0 ; i < a.size() ; i++){
vector<P> w;
w.push_back(a[i]);
w.push_back(a[(i+1)%a.size()]);
w.push_back(b);
ans += abs(area(w));
}
ans = abs(ans);
//cout << a[0] << " " << a[1] << " " << a[2] << " " << a[3] << " " << b << " " << (fabs(abs(area(a)) - ans ) < EPS) << endl;
//cout << ans << " " << abs(area(a)) << " " << a.size() << endl;
return fabs(abs(area(a)) - ans ) < EPS;
}
/*
幾何:
・凸多角形の点包含判定
・凸多角形同士の線分交差判定
グラフ:
・強連結成分分解
・入次数数える
*/
int n;
bool eq(double a,double b){
return fabs(a-b) < EPS;
}
int wf[100][100]={};
int main(){
double d;
while(cin >> n >> d && n ){
memset(wf,0,sizeof(wf));
for(int i = 0 ; i < n ; i++)
wf[i][i] = 1;
vector<G> g(n);
vector<G> g2(n);
for(int i = 0 ; i < n ; i++){
double x1,x2,x3,y1,y2,y3;
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
g[i].push_back(P(x1,y1));
g[i].push_back(P(x2,y2));
g[i].push_back(P(x3,y3));
double A = abs( P(x2,y2) - P(x1,y1) );
double B = abs( P(x2,y2) - P(x3,y3) );
double C = abs( P(x3,y3) - P(x1,y1) );
L l(P(-1,-1),P(-1,-1));
if( eq(A,B) ) l = L( P(x3,y3) , P(x1,y1) );
else if( eq(A,C) ) l = L( P(x2,y2) , P(x3,y3) );
else if( eq(B,C) ) l = L( P(x2,y2) , P(x1,y1) );
else while(1){}
assert( !( eq(A,B) && eq(B,C) ) );
P r = l[1] - l[0];
r = P(-r.imag(),r.real());
r /= abs(r);
//cout << A << " " << B << " " << C << " " << l[0] << "-" << l[1] << " " << r << endl;
for(int coef = -1 ; coef <= 1 ; coef += 2 ){
vector<P> XX;
XX.push_back(l[0]);
XX.push_back(l[0] + coef * d * r );
XX.push_back(l[1] + coef * d * r );
XX.push_back(l[1]);
int ok = 1;
for(int j = 0 ; j < 3 ; j++){
if( !contains(XX,g[i][j]) ){
ok = 0;
}
}
if( ok ) {
if( g2[i].size() ) assert(0);
g2[i] = XX;
}
}
}
for(int i = 0 ; i < n ; i++){
for(int j = 0 ; j < n ; j++){
if( i != j ) {
int ok = 0;
for(int l = 0 ; l < 3 ; l++){
if( contains(g2[i],g[j][l]) ){
ok = 1;
}
}
for(int k = 0 ; k < 4 ; k++){
for(int l = k+1 ; l < 4 ; l++){
for(int m = 0 ; m < 3 ; m++){
for(int o = m+1 ; o < 3 ; o++){
if( intersectSS(L(g2[i][k],g2[i][l]),L(g[j][m],g[j][o])) ){
ok = 1;
}
}
}
}
}
if( ok ) {
wf[i][j] = 1;
}
}
}
}
for(int i = 0 ; i < n ; i++)
for(int j = 0 ; j < n ; j++)
for(int k = 0 ; k < n ; k++)
wf[j][k] |= wf[j][i] & wf[i][k];
int in[100] = {} , id[100] = {} , cur = 0;
for(int i = 0 ; i < n ; i++)
id[i] = -1;
for(int i = 0 ; i < n ; i++){
if( id[i] == -1 ){
for(int j = 0 ; j < n ; j++){
if( wf[i][j] & wf[j][i] ){
id[j] = cur;
}
}
cur++;
}
for(int i = 0 ; i < n ; i++){
for(int j = 0 ; j < n ; j++){
if(wf[i][j] && id[i] != id[j]) in[j]++;
}
}
int ans = 0;
for(int i = 0 ; i < n ; i++){
if( !in[i] ){
ans++;
}
}
cout << ans << endl;
}
} | a.cc: In function 'int main()':
a.cc:197:2: error: expected '}' at end of input
197 | }
| ^
a.cc:90:11: note: to match this '{'
90 | int main(){
| ^
|
s767316890 | p00238 | Java | import java.util.Scanner;
public class main {
Scanner sc = new Scanner(System.in);
int m,k,s,t;
int kei;
public void kei(){
m = sc.nextInt();
while(m!=0){
k = sc.nextInt();
for(int i=0;i<=k-1;i++){
s = sc.nextInt();
t = sc.nextInt();
kei = kei+t-s;
}
if(kei>m){
System.out.println("OK");
}else{
System.out.println(m-kei);
}
kei = 0;
m =sc.nextInt();
}
}
public static void main(String[] args) {
Main t = new Main();
t.kei(); | Main.java:29: error: reached end of file while parsing
t.kei();
^
1 error
|
s511015376 | p00238 | Java | import java.util.*;
public class v02_0238_sano{
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
while(true){
int t=scan.nextInt();
if(t==0){
break;
}
int n=scan.nextInt();
for(int i=0;i<n;i++){
int from=scan.nextInt();
int to=scan.nextInt();
t-=to-from;
}
if(t<=0){
System.out.println("OK");
}else{
System.out.println(t);
}
}
}
} | Main.java:3: error: class v02_0238_sano is public, should be declared in a file named v02_0238_sano.java
public class v02_0238_sano{
^
1 error
|
s001897780 | p00238 | Java | import java.io.*;
public class TimeToStudy{
public static void main(String[] args){
try{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String tmp = br.readLine();
while(tmp != null && Integer.parseInt(tmp) != 0){
int norma = Integer.parseInt(tmp);
int times = Integer.parseInt(br.readLine());
int actual = 0;
for(int i = 0; i < times; i++){
//args[++index] ??§???????????????????£??????§????????§??????????????????????????§????????§???nt?????§?????¶???
String[] values = br.readLine().split(" " , 2);
actual += Integer.parseInt(values[1])- Integer.parseInt(values[0]);
}
if(actual >= norma){
System.out.println("OK");
}else{
System.out.println(norma - actual);
}
tmp = br.readLine();
}
}catch(IOException e){
System.out.println(e);
}
}
} | Main.java:3: error: class TimeToStudy is public, should be declared in a file named TimeToStudy.java
public class TimeToStudy{
^
1 error
|
s422695669 | p00238 | C | #include <stdio.h>
int main(void){
while(1){
int t, n, s, f, sum=0, i;
scanf("%d", &t);
if(t==0) break;
scanf(" %d", &n);
for(i=0; i<n; i++){
scanf(" %d %d", &s, &f);
sum += f-s;
}
if(sum >= t) printf("OK\n");
else printf("%d\n", t-sum);1
}
return 0;
} | main.c: In function 'main':
main.c:17:48: error: expected ';' before '}' token
17 | else printf("%d\n", t-sum);1
| ^
| ;
18 |
19 | }
| ~
|
s468454629 | p00238 | C | #include<stdio>
int main(void){
int t,n,s,f,i;
while(scanf("%d",&t)&&t!=0){
for(i=0;i<t;i++){
scanf("%d",&n);
for(j=0;j<n;j++){
scanf("%d%d",&s,&f);
t=t-s+f;
}
if(t>0)
printf("%d\n",t);
else
printf("OK\n");
}
}
return 0;
} | main.c:1:9: fatal error: stdio: No such file or directory
1 | #include<stdio>
| ^~~~~~~
compilation terminated.
|
s802089197 | p00238 | C | #include<stdio>
int main(void){
int t,n,s,f,i,j;
while(scanf("%d",&t)&&t!=0){
for(i=0;i<t;i++){
scanf("%d",&n);
for(j=0;j<n;j++){
scanf("%d%d",&s,&f);
t=t-s+f;
}
if(t>0)
printf("%d\n",t);
else
printf("OK\n");
}
}
return 0;
} | main.c:1:9: fatal error: stdio: No such file or directory
1 | #include<stdio>
| ^~~~~~~
compilation terminated.
|
s418650199 | p00238 | C | #include<stdio>
int main(void){
int t,n,s,f,i,j;
while(scanf("%d",&t)&&t!=0){
for(i=0;i<t;i++){
scanf("%d",&n);
for(j=0;j<n;j++){
scanf("%d%d",&s,&f);
t=t-s+f;
}
if(t>0){
printf("%d\n",t);}
else{
printf("OK\n");}
}
}
return 0;
} | main.c:1:9: fatal error: stdio: No such file or directory
1 | #include<stdio>
| ^~~~~~~
compilation terminated.
|
s673841477 | p00238 | C | #include<stdio>
int main(void){
int t,n,s,f,i,j;
while(scanf("%d",&t)&&t!=0){
for(i=0;i<t;i++){
scanf("%d",&n);
for(j=0;j<n;j++){
scanf("%d%d",&s,&f);
t=t-s+f;
}
if(t>0){
printf("%d\n",t);}
else{
printf("OK\n");}
}
}
return 0;
} | main.c:1:9: fatal error: stdio: No such file or directory
1 | #include<stdio>
| ^~~~~~~
compilation terminated.
|
s608245145 | p00238 | C | #include<stdio.h>
int main(void) {
int t, n=0, s, f, z=0,i;
scanf("%d", &t);
while (1) {
if (n == 0)break;
scanf("%d", &n);
for (i = 0;i < n;i++) {
scanf_s("%d %d", &s, &f);
z += f - s;
}
if (z >= t) {
printf("OK\n");
}
else {
printf("%d\n",t - z);
}
}return 0;
} | main.c: In function 'main':
main.c:9:25: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
9 | scanf_s("%d %d", &s, &f);
| ^~~~~~~
| scanf
|
s847747344 | p00238 | C | #include<stdio.h>
int main(void) {
int t, n=0, s, f, z=0,i;
scanf_s("%d", &t);
while (1) {
if (n == 0)break;
scanf("%d", &n);
for (i = 0;i < n;i++) {
scanf("%d %d", &s, &f);
z += f - s;
}
if (z >= t) {
printf("OK\n");
}
else {
printf("%d\n",t - z);
}
}
return 0;
} | main.c: In function 'main':
main.c:4:9: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
4 | scanf_s("%d", &t);
| ^~~~~~~
| scanf
|
s052211279 | p00238 | C | #include<stdio.h>
int main(void)
{
int a, b, d, e, f = 0, i;
while (scanf("%d", &a))
{
if (a == 0)break;
scanf("%d", &b);
for (i = 0;i < b;i++)
{
scanf_s("%d %d", &d, &e);
f = f + (e - d);
}
if(f > a)
{
printf("OK\n");
}
else
{
f = a - f;
printf("%d\n", f);
}
f = 0;
}
return 0;
} | main.c: In function 'main':
main.c:12:25: error: implicit declaration of function 'scanf_s'; did you mean 'scanf'? [-Wimplicit-function-declaration]
12 | scanf_s("%d %d", &d, &e);
| ^~~~~~~
| scanf
|
s834471489 | p00238 | C | #include<stdio.h>
int main(void)
{
int t, n, s, f,a,b,c=0,d;
scanf("%d", &t);
scanf("%d", &n);
for (a = 1;a <= n;a++)
{
scanf("%d %d", &s, &f);
b = f - s;
c = c + b;
}
d = t - c;
if (d > 0)
{
printf("%d??????????¶?\n",d);
}
else
{
printf("OK!!\n");
}
return 0; | main.c: In function 'main':
main.c:22:1: error: expected declaration or statement at end of input
22 | return 0;
| ^~~~~~
|
s791799354 | p00238 | C | #include<stdio.h>
int main(void)
{
int t, n, s, f, a, b, c = 0, d;
while (1)
{
scanf("%d", &t);
if (t != 0)
{
break;
}
scanf("%d", &n);
for (a = 1;a <= n;a++)
{
scanf("%d %d", &s, &f);
b = f - s;
c = c + b;
}
d = t - c;
if (d > 0)
{
printf("%d\n", d);
} | main.c: In function 'main':
main.c:23:17: error: expected declaration or statement at end of input
23 | }
| ^
main.c:23:17: error: expected declaration or statement at end of input
|
s813551290 | p00238 | C | #include <stdio.h>
int main(void)
{
int benkyou;
int kaisuu;
int benkyou_s;
int benkyou_e;
int sum;
int i;
while (1){
scanf("%d", &benkyou);
if (benkyou == 0){
break;
}
scanf("%d", &kaisuu);
sum = 0;
for (i = 0; i < kaisuu; i++){
scanf("%d%d", &benkyou_s, &benkyou_e);
sum += benkyou_e - benkyou_s;
}
if (benkyou - sum <= 0){
printf("OK\n");
}
else {
printf("%d
\n", benkyou - sum);
}
}
return (0);
} | main.c: In function 'main':
main.c:33:32: warning: missing terminating " character
33 | printf("%d
| ^
main.c:33:32: error: missing terminating " character
33 | printf("%d
| ^~~
main.c:34:1: error: stray '\' in program
34 | \n", benkyou - sum);
| ^
main.c:34:3: warning: missing terminating " character
34 | \n", benkyou - sum);
| ^
main.c:34:3: error: missing terminating " character
34 | \n", benkyou - sum);
| ^~~~~~~~~~~~~~~~~~
main.c:34:2: error: 'n' undeclared (first use in this function)
34 | \n", benkyou - sum);
| ^
main.c:34:2: note: each undeclared identifier is reported only once for each function it appears in
main.c:34:3: error: expected ')' before '}' token
34 | \n", benkyou - sum);
| ^
| )
35 | }
| ~
main.c:33:31: note: to match this '('
33 | printf("%d
| ^
main.c:34:3: error: expected ';' before '}' token
34 | \n", benkyou - sum);
| ^
| ;
35 | }
| ~
|
s133360025 | p00238 | C | #include <stdio.h>
int main(void) {
int target;
int num,i;
int start,end;
while(1) {
scanf("%d",&target);
if(target==0)break;
scanf("%d",&num);
for(i=0;i<num;i++) {
scanf("%d%d",&start,&end);
target-=end-start;
}
if(target<=0)puts("OK"); else printf("%d\n",target);
}
return 0; | main.c: In function 'main':
main.c:17:9: error: expected declaration or statement at end of input
17 | return 0;
| ^~~~~~
|
s727174754 | p00238 | C | t,n,s;main(f){for(;scanf("%d%d",&t,&n)/2;printf(t>0?"%d\n":"OK\n",t))for(;n--;t-=f-s)scanf("%d%d",&s,&f);} | main.c:1:1: warning: data definition has no type or storage class
1 | t,n,s;main(f){for(;scanf("%d%d",&t,&n)/2;printf(t>0?"%d\n":"OK\n",t))for(;n--;t-=f-s)scanf("%d%d",&s,&f);}
| ^
main.c:1:1: error: type defaults to 'int' in declaration of 't' [-Wimplicit-int]
main.c:1:3: error: type defaults to 'int' in declaration of 'n' [-Wimplicit-int]
1 | t,n,s;main(f){for(;scanf("%d%d",&t,&n)/2;printf(t>0?"%d\n":"OK\n",t))for(;n--;t-=f-s)scanf("%d%d",&s,&f);}
| ^
main.c:1:5: error: type defaults to 'int' in declaration of 's' [-Wimplicit-int]
1 | t,n,s;main(f){for(;scanf("%d%d",&t,&n)/2;printf(t>0?"%d\n":"OK\n",t))for(;n--;t-=f-s)scanf("%d%d",&s,&f);}
| ^
main.c:1:7: error: return type defaults to 'int' [-Wimplicit-int]
1 | t,n,s;main(f){for(;scanf("%d%d",&t,&n)/2;printf(t>0?"%d\n":"OK\n",t))for(;n--;t-=f-s)scanf("%d%d",&s,&f);}
| ^~~~
main.c: In function 'main':
main.c:1:7: error: type of 'f' defaults to 'int' [-Wimplicit-int]
main.c:1:20: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
1 | t,n,s;main(f){for(;scanf("%d%d",&t,&n)/2;printf(t>0?"%d\n":"OK\n",t))for(;n--;t-=f-s)scanf("%d%d",&s,&f);}
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | t,n,s;main(f){for(;scanf("%d%d",&t,&n)/2;printf(t>0?"%d\n":"OK\n",t))for(;n--;t-=f-s)scanf("%d%d",&s,&f);}
main.c:1:20: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
1 | t,n,s;main(f){for(;scanf("%d%d",&t,&n)/2;printf(t>0?"%d\n":"OK\n",t))for(;n--;t-=f-s)scanf("%d%d",&s,&f);}
| ^~~~~
main.c:1:20: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:1:42: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
1 | t,n,s;main(f){for(;scanf("%d%d",&t,&n)/2;printf(t>0?"%d\n":"OK\n",t))for(;n--;t-=f-s)scanf("%d%d",&s,&f);}
| ^~~~~~
main.c:1:42: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:1:42: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:1:42: note: include '<stdio.h>' or provide a declaration of 'printf'
|
s746615964 | p00238 | C | #include<stdio.h>
t,n,s;main(f){for(;scanf("%d%d",&t,&n)/2;printf(t>0?"%d\n":"OK\n",t))for(;n--;t-=f-s)scanf("%d%d",&s,&f);} | main.c:2:1: warning: data definition has no type or storage class
2 | t,n,s;main(f){for(;scanf("%d%d",&t,&n)/2;printf(t>0?"%d\n":"OK\n",t))for(;n--;t-=f-s)scanf("%d%d",&s,&f);}
| ^
main.c:2:1: error: type defaults to 'int' in declaration of 't' [-Wimplicit-int]
main.c:2:3: error: type defaults to 'int' in declaration of 'n' [-Wimplicit-int]
2 | t,n,s;main(f){for(;scanf("%d%d",&t,&n)/2;printf(t>0?"%d\n":"OK\n",t))for(;n--;t-=f-s)scanf("%d%d",&s,&f);}
| ^
main.c:2:5: error: type defaults to 'int' in declaration of 's' [-Wimplicit-int]
2 | t,n,s;main(f){for(;scanf("%d%d",&t,&n)/2;printf(t>0?"%d\n":"OK\n",t))for(;n--;t-=f-s)scanf("%d%d",&s,&f);}
| ^
main.c:2:7: error: return type defaults to 'int' [-Wimplicit-int]
2 | t,n,s;main(f){for(;scanf("%d%d",&t,&n)/2;printf(t>0?"%d\n":"OK\n",t))for(;n--;t-=f-s)scanf("%d%d",&s,&f);}
| ^~~~
main.c: In function 'main':
main.c:2:7: error: type of 'f' defaults to 'int' [-Wimplicit-int]
|
s425397250 | p00238 | C++ | #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <map>
using namespace std;
const int MAX= 10000100;
int main(void){
int t,n;
while(cin>>t,t){
int ans = 0;
cin>>n;
for(int i = 0 ; i < n ; i ++){
int s,e;
cin>>s>>e;
ans+=e-s;
}
cout<<(ans>t?"OK":t-ans)<<endl;
}
} | a.cc: In function 'int main()':
a.cc:22:17: error: operands to '?:' have different types 'const char*' and 'int'
22 | cout<<(ans>t?"OK":t-ans)<<endl;
| ~~~~~^~~~~~~~~~~
|
s134640504 | p00238 | C++ | #include<stdio.h>
int main(){
int G,N;
while(1){
scanf("%d",&G);if(G==0)break;
scanf("%d",&N);
int s,f;
for(int i=0;i<N;i++)
{
scanf("%d %d",&s,&f)
f-=s;
G-=f;
if(G<=0)break;
}
if(G<=0)printf("OK\n");
else printf("%d\n",G);
}
return 0;
} | a.cc: In function 'int main()':
a.cc:13:21: error: expected ';' before 'f'
13 | scanf("%d %d",&s,&f)
| ^
| ;
14 | f-=s;
| ~
|
s673583615 | p00238 | C++ | #include<iostream>
using namespace std;
int main(){
int t,i,k,n,s[n],f[n];
while(cin>>t){
cin>>s>>f>>n;
for(i=0;i<n;i++){
k=k+f[i]-s[i];
}
if(k>=t){cout<<"OK"<<endl;
}
else{cout<<t-k<<endl;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:7:12: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'int [n]')
7 | cin>>s>>f>>n;
| ~~~^~~
| | |
| | int [n]
| std::istream {aka std::basic_istream<char>}
In file included from /usr/include/c++/14/iostream:42,
from a.cc:1:
/usr/include/c++/14/istream:170:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(bool&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' (near match)
170 | operator>>(bool& __n)
| ^~~~~~~~
/usr/include/c++/14/istream:170:7: note: conversion of argument 1 would be ill-formed:
a.cc:7:14: error: cannot bind non-const lvalue reference of type 'bool&' to a value of type 'int*'
7 | cin>>s>>f>>n;
| ^
/usr/include/c++/14/istream:174:7: note: candidate: 'std::basic_istream<_CharT, _Traits>& std::basic_istream<_CharT, _Traits>::operator>>(short int&) [with _CharT = char; _Traits = std::char_traits<char>]' (near match)
174 | operator>>(short& __n);
| ^~~~~~~~
/usr/include/c++/14/istream:174:7: note: conversion of argument 1 would be ill-formed:
a.cc:7:14: error: invalid conversion from 'int*' to 'short int' [-fpermissive]
7 | cin>>s>>f>>n;
| ^
| |
| int*
a.cc:7:14: error: cannot bind rvalue '(short int)((int*)(& s))' 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:7:14: error: invalid conversion from 'int*' to 'short unsigned int' [-fpermissive]
7 | cin>>s>>f>>n;
| ^
| |
| int*
a.cc:7:14: error: cannot bind rvalue '(short unsigned int)((int*)(& s))' 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:7:14: error: invalid conversion from 'int*' to 'int' [-fpermissive]
7 | cin>>s>>f>>n;
| ^
| |
| int*
a.cc:7:14: error: cannot bind rvalue '(int)((int*)(& s))' 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:7:14: error: invalid conversion from 'int*' to 'unsigned int' [-fpermissive]
7 | cin>>s>>f>>n;
| ^
| |
| int*
a.cc:7:14: error: cannot bind rvalue '(unsigned int)((int*)(& s))' 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:7:14: error: invalid conversion from 'int*' to 'long int' [-fpermissive]
7 | cin>>s>>f>>n;
| ^
| |
| int*
a.cc:7:14: error: cannot bind rvalue '(long int)((int*)(& s))' 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:7:14: error: invalid conversion from 'int*' to 'long unsigned int' [-fpermissive]
7 | cin>>s>>f>>n;
| ^
| |
| int*
a.cc:7:14: error: cannot bind rvalue '(long unsigned int)((int*)(& s))' 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:7:14: error: invalid conversion from 'int*' to 'long long int' [-fpermissive]
7 | cin>>s>>f>>n;
| ^
| |
| int*
a.cc:7:14: error: cannot bind rvalue '(long long int)((int*)(& s))' 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:7:14: error: invalid conversion from 'int*' to 'long long unsigned int' [-fpermissive]
7 | cin>>s>>f>>n;
| ^
| |
| int*
a.cc:7:14: error: cannot bind rvalue '(long long unsigned int)((int*)(& s))' 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:7:14: error: cannot bind non-const lvalue reference of type 'void*&' to an rvalue of type 'void*'
7 | cin>>s>>f>>n;
| ^
/usr/include/c++/14/istream:219:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(float&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
219 | operator>>(float& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:219:25: note: no known conversion for argument 1 from 'int [n]' to 'float&'
219 | operator>>(float& __f)
| ~~~~~~~^~~
/usr/include/c++/14/istream:223:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
223 | operator>>(double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:223:26: note: no known conversion for argument 1 from 'int [n]' to 'double&'
223 | operator>>(double& __f)
| ~~~~~~~~^~~
/usr/include/c++/14/istream:227:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(long double&) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
227 | operator>>(long double& __f)
| ^~~~~~~~
/usr/include/c++/14/istream:227:31: note: no known conversion for argument 1 from 'int [n]' to 'long double&'
227 | operator>>(long double& __f)
| ~~~~~~~~~~~~~^~~
/usr/include/c++/14/istream:122:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]'
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:122:36: note: no known conversion for argument 1 from 'int [n]' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'}
122 | operator>>(__istream_type& (*__pf)(__istream_type&))
| ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:126:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std::basic_ios<char>]'
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ^~~~~~~~
/usr/include/c++/14/istream:126:32: note: no known conversion for argument 1 from 'int [n]' to 'std::basic_istream<char>::__ios_type& (*)(std::basic_istream<char>::__ios_type&)' {aka 'std::basic_ios<char>& (*)(std::basic_ios<char>&)'}
126 | operator>>(__ios_type& (*__pf)(__ios_type&))
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~
/usr/include/c++/14/istream:133:7: note: candidate: 'std::basic_istream<_CharT, |
s700589230 | p00238 | C++ | #include <stdio.h>
int main(void){
int t,n,s,f;
for (scanf("%d", &t), t){
scanf("%d", &n);
for (; n>=0; n--){
scanf("%d %d", &s, &f);
t -= (f-s);
}
if (t<0) puts("OK");
else printf("%d\n", t);
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:6:32: error: expected ';' before ')' token
6 | for (scanf("%d", &t), t){
| ^
| ;
a.cc:15:9: error: expected primary-expression before 'return'
15 | return 0;
| ^~~~~~
a.cc:14:10: error: expected ';' before 'return'
14 | }
| ^
| ;
15 | return 0;
| ~~~~~~
a.cc:15:9: error: expected primary-expression before 'return'
15 | return 0;
| ^~~~~~
a.cc:14:10: error: expected ')' before 'return'
14 | }
| ^
| )
15 | return 0;
| ~~~~~~
a.cc:6:13: note: to match this '('
6 | for (scanf("%d", &t), t){
| ^
|
s497275748 | p00238 | C++ | #include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (a); v < (b); ++v)
#define REP(v, n) FOR(v, 0, n);
using namespace std;
int main(){
int t, n, s, f, sum;
while(cin >> t, t){
cin >> n;
sum = 0;
REP(i, n){
cin >> s >> f;
sum += (f - s);
}
if(sum >= t) cout << "OK" << endl;
else cout << t - sum << endl;
return 0;
} | a.cc: In function 'int main()':
a.cc:20:2: error: expected '}' at end of input
20 | }
| ^
a.cc:6:11: note: to match this '{'
6 | int main(){
| ^
|
s722703214 | p00238 | C++ | ?°??\???§?????? | a.cc:1:2: error: extended character ° is not valid in an identifier
1 | ?°??\???§??????
| ^
a.cc:1:5: error: stray '\' in program
1 | ?°??\???§??????
| ^
a.cc:1:9: error: extended character § is not valid in an identifier
1 | ?°??\???§??????
| ^
a.cc:1:1: error: expected unqualified-id before '?' token
1 | ?°??\???§??????
| ^
|
s045406633 | p00238 | C++ | using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
static void Main(string[] args)
{
while(true){
int t,n;
t=int.Parse(Console.ReadLine());
n=int.Parse(Console.ReadLine());
int sum=0;
for(int i=0;i<n;++i){
int s,f;
string[] input = Console.ReadLine().Split(' ');
s=int.Parse(input[0]);
f=int.Parse(input[1]);
sum+=f-s;
}
if(sum>=t){
Console.WriteLine("OK");
}else{
Console.WriteLine(t-sum);
}
}
}
} | a.cc:1:7: error: expected nested-name-specifier before 'System'
1 | using System;
| ^~~~~~
a.cc:2:7: error: expected nested-name-specifier before 'System'
2 | using System.Collections.Generic;
| ^~~~~~
a.cc:3:7: error: expected nested-name-specifier before 'System'
3 | using System.Linq;
| ^~~~~~
a.cc:4:7: error: expected nested-name-specifier before 'System'
4 | using System.Text;
| ^~~~~~
a.cc:9:22: error: 'string' has not been declared
9 | static void Main(string[] args)
| ^~~~~~
a.cc:9:31: error: expected ',' or '...' before 'args'
9 | static void Main(string[] args)
| ^~~~
a.cc:30:2: error: expected ';' after class definition
30 | }
| ^
| ;
a.cc: In static member function 'static void Program::Main(int*)':
a.cc:13:15: error: expected primary-expression before 'int'
13 | t=int.Parse(Console.ReadLine());
| ^~~
a.cc:14:15: error: expected primary-expression before 'int'
14 | n=int.Parse(Console.ReadLine());
| ^~~
a.cc:18:17: error: 'string' was not declared in this scope
18 | string[] input = Console.ReadLine().Split(' ');
| ^~~~~~
a.cc:18:24: error: expected primary-expression before ']' token
18 | string[] input = Console.ReadLine().Split(' ');
| ^
a.cc:19:19: error: expected primary-expression before 'int'
19 | s=int.Parse(input[0]);
| ^~~
a.cc:20:19: error: expected primary-expression before 'int'
20 | f=int.Parse(input[1]);
| ^~~
a.cc:24:17: error: 'Console' was not declared in this scope
24 | Console.WriteLine("OK");
| ^~~~~~~
a.cc:26:17: error: 'Console' was not declared in this scope
26 | Console.WriteLine(t-sum);
| ^~~~~~~
|
s097133149 | p00238 | C++ | using System;
class Program
{
static void Main(string[] args)
{
while(true){
int t=int.Parse(Console.ReadLine());
int n=int.Parse(Console.ReadLine());
int sum=0;
for(int i=0;i<n;++i){
string[] input = Console.ReadLine().Split(' ');
int s=int.Parse(input[0]);
int f=int.Parse(input[1]);
sum+=f-s;
}
if(sum>=t){
Console.WriteLine("OK");
}else{
Console.WriteLine(t-sum);
}
}
}
} | a.cc:1:7: error: expected nested-name-specifier before 'System'
1 | using System;
| ^~~~~~
a.cc:5:22: error: 'string' has not been declared
5 | static void Main(string[] args)
| ^~~~~~
a.cc:5:31: error: expected ',' or '...' before 'args'
5 | static void Main(string[] args)
| ^~~~
a.cc:25:2: error: expected ';' after class definition
25 | }
| ^
| ;
a.cc: In static member function 'static void Program::Main(int*)':
a.cc:8:19: error: expected primary-expression before 'int'
8 | int t=int.Parse(Console.ReadLine());
| ^~~
a.cc:9:19: error: expected primary-expression before 'int'
9 | int n=int.Parse(Console.ReadLine());
| ^~~
a.cc:13:17: error: 'string' was not declared in this scope
13 | string[] input = Console.ReadLine().Split(' ');
| ^~~~~~
a.cc:13:24: error: expected primary-expression before ']' token
13 | string[] input = Console.ReadLine().Split(' ');
| ^
a.cc:14:23: error: expected primary-expression before 'int'
14 | int s=int.Parse(input[0]);
| ^~~
a.cc:15:23: error: expected primary-expression before 'int'
15 | int f=int.Parse(input[1]);
| ^~~
a.cc:19:17: error: 'Console' was not declared in this scope
19 | Console.WriteLine("OK");
| ^~~~~~~
a.cc:21:17: error: 'Console' was not declared in this scope
21 | Console.WriteLine(t-sum);
| ^~~~~~~
|
s428192579 | p00238 | C++ | using System;
namespace a{
class Program
{
static void Main(string[] args)
{
while(true){
int t=int.Parse(Console.ReadLine());
int n=int.Parse(Console.ReadLine());
int sum=0;
for(int i=0;i<n;++i){
string[] input = Console.ReadLine().Split(' ');
int s=int.Parse(input[0]);
int f=int.Parse(input[1]);
sum+=f-s;
}
if(sum>=t){
Console.WriteLine("OK");
}else{
Console.WriteLine(t-sum);
}
}
}
}
} | a.cc:1:7: error: expected nested-name-specifier before 'System'
1 | using System;
| ^~~~~~
a.cc:6:22: error: 'string' has not been declared
6 | static void Main(string[] args)
| ^~~~~~
a.cc:6:31: error: expected ',' or '...' before 'args'
6 | static void Main(string[] args)
| ^~~~
a.cc:26:2: error: expected ';' after class definition
26 | }
| ^
| ;
a.cc: In static member function 'static void a::Program::Main(int*)':
a.cc:9:19: error: expected primary-expression before 'int'
9 | int t=int.Parse(Console.ReadLine());
| ^~~
a.cc:10:19: error: expected primary-expression before 'int'
10 | int n=int.Parse(Console.ReadLine());
| ^~~
a.cc:14:17: error: 'string' was not declared in this scope
14 | string[] input = Console.ReadLine().Split(' ');
| ^~~~~~
a.cc:14:24: error: expected primary-expression before ']' token
14 | string[] input = Console.ReadLine().Split(' ');
| ^
a.cc:15:23: error: expected primary-expression before 'int'
15 | int s=int.Parse(input[0]);
| ^~~
a.cc:16:23: error: expected primary-expression before 'int'
16 | int f=int.Parse(input[1]);
| ^~~
a.cc:20:17: error: 'Console' was not declared in this scope
20 | Console.WriteLine("OK");
| ^~~~~~~
a.cc:22:17: error: 'Console' was not declared in this scope
22 | Console.WriteLine(t-sum);
| ^~~~~~~
|
s109061891 | p00238 | C++ | #include<stdio.h>
int main(void)
{
int n,t,i,k,h,x,w;
w=0;
while(1){
scanf("%d",&n);
if(n==0) break;
scanf("%d",&t);
for(i=0;i<t;i++){
scanf("%d %d",&k,&h);
w+=h-k;
}
if(n=<w){
printf("OK\n");
}
else{
x=n-w;
printf("%d\n",x);
}
w=0;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:14:14: error: expected primary-expression before '<' token
14 | if(n=<w){
| ^
|
s909508378 | p00238 | C++ | #include <iostream>
using namespace std;
int main(){
int t,n,s,f;
cin>>t>>n>>s>>f;
for(int i=0;i<n;i++){
if(f[i]-s[i]>=t)
cout<<"OK"<<endl;
else{ A=f[i]-s[i];
cout<<t-A<<endl;
}
}
return 0;
}
| a.cc: In function 'int main()':
a.cc:7:21: error: invalid types 'int[int]' for array subscript
7 | if(f[i]-s[i]>=t)
| ^
a.cc:7:26: error: invalid types 'int[int]' for array subscript
7 | if(f[i]-s[i]>=t)
| ^
a.cc:9:25: error: 'A' was not declared in this scope
9 | else{ A=f[i]-s[i];
| ^
a.cc:9:28: error: invalid types 'int[int]' for array subscript
9 | else{ A=f[i]-s[i];
| ^
a.cc:9:33: error: invalid types 'int[int]' for array subscript
9 | else{ A=f[i]-s[i];
| ^
|
s043029960 | p00238 | C++ | #include <iostream>
using namespace std;
int main(){
int t,n,s,f;
cin>>t;
if(t==0)
break;
cin>>n;
for(int i=0;i<n;i++){
cin>>s>>f;
t-=f-s;
}
if(t>0)
cout<<m<<endl;
else
cout<<"OK"<<endl;
return 0;
}
| a.cc: In function 'int main()':
a.cc:7:9: error: break statement not within loop or switch
7 | break;
| ^~~~~
a.cc:14:15: error: 'm' was not declared in this scope
14 | cout<<m<<endl;
| ^
|
s028888589 | p00238 | C++ | #include <iostream>
using namespace std;
int main(){
int t,n,s,f;
while(true){
cin>>t;
if(t==0)
break;
cin>>n;
for(int i=0;i<n;i++){
cin>>s>>f;
t-=f-s;
}
if(t>0)
cout<<m<<endl;
else
cout<<"OK"<<endl;
return 0;
}
} | a.cc: In function 'int main()':
a.cc:15:15: error: 'm' was not declared in this scope
15 | cout<<m<<endl;
| ^
|
s105209729 | p00238 | C++ | #include<stdio.h>
int main(void)
{
int t,n,i,s,f;
scanf("%d %d",&t,&n);
for(i=0;i<n;i++){
scanf("%d %d",&s,&f);
t=t-(f-s);
}
if(t<=0){
printf("OK\n");
}
else printf("%d\n",t);
}
} | a.cc:15:1: error: expected declaration before '}' token
15 | }
| ^
|
s158626138 | p00238 | C++ | #include<stdio.h>
int main(void)
{
int t,n,i,s,f;
scanf("%d %d",&t,&n);
while (1){
if (n=0) break;
for(i=0;i<n;i++){
scanf("%d %d",&s,&f);
t=t-(f-s);
}
if(t<=0){
printf("OK\n");
}
else printf("%d\n",t);
}
return 0;
}
} | a.cc:19:1: error: expected declaration before '}' token
19 | }
| ^
|
s083779011 | p00238 | C++ | #include<iostream>
using namespace std;
int main(){
while(true){
int t;cin>>t;
if(t == 0)return 0;
int n; cin >> n;
int result= 0;
for(int i = 0; i < n; i++){
int time[2] = {};
cin >>time[0] >> time[1];
result += time[1]-time[0];
}
(result > t)?(cout << "OK"<<endl):(cout<<t-result<<endl);
return 0;
} | a.cc: In function 'int main()':
a.cc:17:2: error: expected '}' at end of input
17 | }
| ^
a.cc:3:11: note: to match this '{'
3 | int main(){
| ^
|
s537950709 | p00238 | C++ | f | a.cc:1:1: error: 'f' does not name a type
1 | f
| ^
|
s281043713 | p00238 | C++ | #include <iostream>
using namespace std;
int main (void)
{
while(true)
{
int n, m, p;
p = 0;
cin >> n;
if(n == 0)
{
break;
}
cin >> m;
while(m > 0)
{
int s, q;
cin >> s >>q;
p += q-s;
m--;
}
if(p >= n)
{
cout << "OK"<< endl;
}
else
{
cout << n - p;
}
}
return 0;
}
int s, q;
cin >> s >>q;
p += q-s;
m--;
}
if(p >= n)
{
cout << "OK"<< endl;
}
else
{
cout << n - p;
}
}
return 0;
} | a.cc:34:25: error: 'cin' does not name a type
34 | cin >> s >>q;
| ^~~
a.cc:35:25: error: 'p' does not name a type
35 | p += q-s;
| ^
a.cc:36:25: error: 'm' does not name a type; did you mean 'tm'?
36 | m--;
| ^
| tm
a.cc:37:17: error: expected declaration before '}' token
37 | }
| ^
a.cc:38:17: error: expected unqualified-id before 'if'
38 | if(p >= n)
| ^~
a.cc:42:17: error: expected unqualified-id before 'else'
42 | else
| ^~~~
a.cc:46:9: error: expected declaration before '}' token
46 | }
| ^
a.cc:47:9: error: expected unqualified-id before 'return'
47 | return 0;
| ^~~~~~
a.cc:48:1: error: expected declaration before '}' token
48 | }
| ^
|
s026607198 | p00238 | C++ | #include<iostream>
using namespace std;
int main(){
int t,n,s,f,cnt;
while(true){
cin>> t;
if(t==0)break;
cn >> n;
for(int i=0;i<n;i++){
cin >> s >> f;
cnt+= f-s;
}
if(cnt >= t)cout<< "OK" << endl;
else cout << t-fe << endl;
}
return 0;
} | a.cc: In function 'int main()':
a.cc:10:5: error: 'cn' was not declared in this scope; did you mean 'cnt'?
10 | cn >> n;
| ^~
| cnt
a.cc:16:20: error: 'fe' was not declared in this scope; did you mean 'f'?
16 | else cout << t-fe << endl;
| ^~
| f
|
s396531241 | p00238 | C++ | include<iostream>
using namespace std;
int main(){
int t,n,s,f,cnt;
while(true){
cin>> t;
cnt = 0;
if(t==0)break;
cin >> n;
for(int i=0;i<n;i++){
cin >> s >> f;
cnt+= f-s;
}
if(cnt >= t)cout<< "OK" << endl;
else cout << t-cnt << endl;
}
return 0;
} | a.cc:1:1: error: 'include' does not name a type
1 | include<iostream>
| ^~~~~~~
a.cc: In function 'int main()':
a.cc:7:5: error: 'cin' was not declared in this scope
7 | cin>> t;
| ^~~
a.cc:15:17: error: 'cout' was not declared in this scope
15 | if(cnt >= t)cout<< "OK" << endl;
| ^~~~
a.cc:15:32: error: 'endl' was not declared in this scope
15 | if(cnt >= t)cout<< "OK" << endl;
| ^~~~
a.cc:16:10: error: 'cout' was not declared in this scope
16 | else cout << t-cnt << endl;
| ^~~~
a.cc:16:27: error: 'endl' was not declared in this scope
16 | else cout << t-cnt << endl;
| ^~~~
|
s419788599 | p00238 | C++ | include <iostream>
using namespace std;
int d, n, s, t, sum;
int main() {
while(cin>>d>>n, d) {
for(int i=0; i<n; i++) {
cin >> s >> t;
sum += t-s;
}
if(sum<d) cout << sum-d << endl;
else cout << "OK" << endl;
}
return 0;
} | a.cc:1:1: error: 'include' does not name a type
1 | include <iostream>
| ^~~~~~~
a.cc: In function 'int main()':
a.cc:6:9: error: 'cin' was not declared in this scope
6 | while(cin>>d>>n, d) {
| ^~~
a.cc:11:15: error: 'cout' was not declared in this scope
11 | if(sum<d) cout << sum-d << endl;
| ^~~~
a.cc:11:32: error: 'endl' was not declared in this scope
11 | if(sum<d) cout << sum-d << endl;
| ^~~~
a.cc:12:10: error: 'cout' was not declared in this scope
12 | else cout << "OK" << endl;
| ^~~~
a.cc:12:26: error: 'endl' was not declared in this scope
12 | else cout << "OK" << endl;
| ^~~~
|
s460945139 | p00238 | C++ | #include <iostream>
using namespace std;
int main (){
int a;
while(cin>>a){
if(a==0)break;
int N;
cin>>n;
int ans=0;
for(int i=0;i<N;i++){
int c,d;
cin>>c>>d;
ans+=d-c;
}
if(ans>a){
cout<<"OK"<<endl;
}
else{ cout<<"NO"<<endl;
}
}
return 0;
} | a.cc: In function 'int main()':
a.cc:8:18: error: 'n' was not declared in this scope
8 | cin>>n;
| ^
|
s061730735 | p00238 | C++ | #include<iostream>
using namespace std;
int main(){
int sum;
int a,b;
int m,n;
while(cin>>m,m!=0){
cin>>n;
sum=0;
for(int i=0;i<n;i++){
cin>>a>>b;
sum+=b-a;
}
if(m<sum)cout<<"OK"<<endl;A
else cout<<m-sum<<endl;
}
} | a.cc: In function 'int main()':
a.cc:15:43: error: 'A' was not declared in this scope
15 | if(m<sum)cout<<"OK"<<endl;A
| ^
|
s327838180 | p00238 | C++ | #include<iostream>
using namespace std;
int main(){
int sum;
int a,b;
int m,n;
while(cin>>m,m!=0){
cin>>n;
sum=0;
for(int i=0;i<n;i++){
cin>>a>>b;
sum+=b-a;
}
if(m<sum)cout<<"OK"<<endl;A
else cout<<m-sum<<endl;
}
} | a.cc: In function 'int main()':
a.cc:15:43: error: 'A' was not declared in this scope
15 | if(m<sum)cout<<"OK"<<endl;A
| ^
|
s747818315 | p00238 | C++ | #include<iostream>
using namespace std;
int main(){
int sum;
int a,b;
int m,n;
while(cin>>m,m!=0){
cin>>n;
sum=0;
for(int i=0;i<n;i++){
cin>>a>>b;
sum+=b-a;
}
if(m<sum)cout<<"OK"<<endl;A
else cout<<m-sum<<endl;
}
} | a.cc: In function 'int main()':
a.cc:15:43: error: 'A' was not declared in this scope
15 | if(m<sum)cout<<"OK"<<endl;A
| ^
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.