제출 #904535

#제출 시각아이디문제언어결과실행 시간메모리
904535vjudge1Land of the Rainbow Gold (APIO17_rainbow)C++17
컴파일 에러
0 ms0 KiB
#include<bitset> bitset<3> was[200001]; int pref1[200005]; int pref2[200005]; int pref12[200005]; void init(int r,int c,int sr,int sc,int m,char* s){ int px=sr,py=sc; was[py][px]=1; for(int i=0;i<m;i++){ char u=s[i]; if(u=='S'){ px++; }else if(u=='N'){ px--; }else if(u=='E'){ py++; }else{ py--; } // cout<<px<<' '<<py<<endl; was[py][px]=1; } for(int j=2;j<=c;j++){ pref12[j]=pref12[j-1]; if((was[j].count()==0 and was[j-1].count()==0) or (was[j]|was[j-1]).count()>0){ }else{ pref12[j]++; } } for(int j=2;j<=c;j++){ pref1[j]=pref1[j-1]; pref2[j]=pref2[j-1]; if(was[j][1] and was[j-1][1]){ pref1[j]++; } if(was[j][2] and was[j-1][2]){ pref2[j]++; } } } int colour(int lx,int ly,int rx,int ry){ if(lx<rx){ return pref12[ry]-pref12[ly]; }else if(lx==1){ return pref1[ry]-pref1[ly]; }else{ return pref2[ry]-pref2[ly]; } } int main() { scanf("%d %d %d %d", &R, &C, &M, &Q); scanf("%d %d", &sr, &sc); if (M > 0) { scanf(" %s ", S); } init(R, C, sr, sc, M, S); int query; for (query = 0; query < Q; query++) { int ar, ac, br, bc; scanf("%d %d %d %d", &ar, &ac, &br, &bc); printf("%d\n", colour(ar, ac, br, bc)); } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

rainbow.cpp:3:1: error: 'bitset' does not name a type
    3 | bitset<3> was[200001];
      | ^~~~~~
rainbow.cpp: In function 'void init(int, int, int, int, int, char*)':
rainbow.cpp:9:5: error: 'was' was not declared in this scope
    9 |     was[py][px]=1;
      |     ^~~
rainbow.cpp: In function 'int main()':
rainbow.cpp:52:27: error: 'R' was not declared in this scope
   52 |     scanf("%d %d %d %d", &R, &C, &M, &Q);
      |                           ^
rainbow.cpp:52:31: error: 'C' was not declared in this scope
   52 |     scanf("%d %d %d %d", &R, &C, &M, &Q);
      |                               ^
rainbow.cpp:52:35: error: 'M' was not declared in this scope
   52 |     scanf("%d %d %d %d", &R, &C, &M, &Q);
      |                                   ^
rainbow.cpp:52:39: error: 'Q' was not declared in this scope
   52 |     scanf("%d %d %d %d", &R, &C, &M, &Q);
      |                                       ^
rainbow.cpp:53:21: error: 'sr' was not declared in this scope
   53 |     scanf("%d %d", &sr, &sc);
      |                     ^~
rainbow.cpp:53:26: error: 'sc' was not declared in this scope
   53 |     scanf("%d %d", &sr, &sc);
      |                          ^~
rainbow.cpp:55:23: error: 'S' was not declared in this scope
   55 |         scanf(" %s ", S);
      |                       ^
rainbow.cpp:58:27: error: 'S' was not declared in this scope
   58 |     init(R, C, sr, sc, M, S);
      |                           ^
rainbow.cpp:63:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         scanf("%d %d %d %d", &ar, &ac, &br, &bc);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~