Submission #925224

#TimeUsernameProblemLanguageResultExecution timeMemory
925224irmuunLand of the Rainbow Gold (APIO17_rainbow)C++17
0 / 100
1 ms648 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])==false||(water[2][r]|water[2][r+1]))==false){ 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])==false){ 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])==false){ 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){ int x,y; if(ar==1&&br==1){ x=upper_bound(all(v[1]),bc)-v[1].begin(); y=lower_bound(all(u[1]),ac)-u[1].begin(); } if(ar==2&&br==2){ x=upper_bound(all(v[2]),bc)-v[2].begin(); y=lower_bound(all(u[2]),ac)-u[2].begin(); } if(ar==1&&br==2){ x=upper_bound(all(v[0]),bc)-v[0].begin(); y=lower_bound(all(u[0]),ac)-u[0].begin(); } return x-y; }

Compilation message (stderr)

rainbow.cpp: In function 'int colour(int, int, int, int)':
rainbow.cpp:85:14: warning: 'y' may be used uninitialized in this function [-Wmaybe-uninitialized]
   85 |     return x-y;
      |              ^
rainbow.cpp:85:14: warning: 'x' may be used uninitialized in this function [-Wmaybe-uninitialized]
#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...