Submission #904545

#TimeUsernameProblemLanguageResultExecution timeMemory
904545vjudge1Land of the Rainbow Gold (APIO17_rainbow)C++17
Compilation error
0 ms0 KiB
#include<stdio.h> static int R, C, M, Q; static int sr, sc; static char S[100000 + 5]; using namespace std; #include<bitset> int 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]|=(1<<px); 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]|=(1<<px); } for(int j=2;j<=c;j++){ pref12[j]=pref12[j-1]; if((was[j]==0 and was[j-1]==0) or (was[j]|was[j-1])>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)&1 and (was[j-1]>>1)&1){ pref1[j]++; } if((was[j]>>2)&1 and (was[j-1]>>2)&1){ 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; }

Compilation message (stderr)

rainbow.cpp: In function 'int main()':
rainbow.cpp:58:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |     scanf("%d %d %d %d", &R, &C, &M, &Q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
rainbow.cpp:59:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   59 |     scanf("%d %d", &sr, &sc);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~
rainbow.cpp:61:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   61 |         scanf(" %s ", S);
      |         ~~~~~^~~~~~~~~~~
rainbow.cpp:69:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   69 |         scanf("%d %d %d %d", &ar, &ac, &br, &bc);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccW5feEZ.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccBl5Bj2.o:rainbow.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status