Submission #925222

#TimeUsernameProblemLanguageResultExecution timeMemory
925222irmuunLand of the Rainbow Gold (APIO17_rainbow)C++17
0 / 100
1 ms860 KiB
#include<bits/stdc++.h> #include "rainbow.h" using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() bool water[3][200005],sub2=false; vector<int>v[3],u[3]; void init(int R,int C,int sr,int sc,int M,char *S){ water[sr][sc]=true; for(int i=0;i<M;i++){ if(S[i]=='N') sr--; if(S[i]=='S') sr++; if(S[i]=='W') sc--; if(S[i]=='E') sc++; water[sr][sc]=true; } if(R==2){ for(int i=0;i<3;i++){ v[i].pb(-1); u[i].pb(-1); } for(int j=1;j<=C;j++){ if(water[1][j]==false||water[2][j]==false){ int r=j; while(r<C&&(water[1][r]&water[1][r+1])==true||(water[2][r]&water[2][r+1])==true){ r++; } v[0].pb(j); u[0].pb(r); j=r+1; } } for(int j=1;j<=C;j++){ if(water[1][j]==false){ int r=j; while(r<C&&(water[1][r]&water[1][r+1])==true){ r++; } v[1].pb(j); u[1].pb(r); j=r+1; } } for(int j=1;j<=C;j++){ if(water[2][j]==false){ int r=j; while(r<C&&(water[2][r]&water[2][r+1])==true){ r++; } v[2].pb(j); u[2].pb(r); j=r+1; } } for(int i=0;i<3;i++){ v[i].pb(C+1); u[i].pb(C+1); } } } int colour(int ar,int ac,int br,int bc){ if(ar==1&&br==1){ ll x=lower_bound(all(v[1]),bc)-v[1].begin(); ll y=lower_bound(all(u[1]),bc)-u[1].begin(); return x-y; } if(ar==2&&br==2){ ll x=lower_bound(all(v[2]),bc)-v[2].begin(); ll y=lower_bound(all(u[2]),bc)-u[2].begin(); return x-y; } if(ar==1&&br==2){ ll x=lower_bound(all(v[0]),bc)-v[0].begin(); ll y=lower_bound(all(u[0]),bc)-u[0].begin(); return x-y; } return 0; }

Compilation message (stderr)

rainbow.cpp: In function 'void init(int, int, int, int, int, char*)':
rainbow.cpp:33:26: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
   33 |                 while(r<C&&(water[1][r]&water[1][r+1])==true||(water[2][r]&water[2][r+1])==true){
      |                       ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...