# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
73490 | 2018-08-28T10:34:30 Z | FedericoS | Land of the Rainbow Gold (APIO17_rainbow) | C++14 | 171 ms | 48844 KB |
#include <iostream> #include "rainbow.h" #include <assert.h> using namespace std; bool B[3][200005]; bool V[3][200005]; int R,C; int A[3][200005]; int P[3][2][200005]; void init(int R_, int C_, int sr, int sc, int M, char *W) { R=R_; C=C_; B[1][0]=B[2][0]=true; B[1][C+1]=B[2][C+1]=false; B[1][C+2]=B[2][C+2]=true; for(int k=0;k<3;k++){ A[k][0]=-1; P[k][0][0]=-1; P[k][0][C+2]=-1; P[k][1][0]=-1; P[k][1][C+2]=-1; } B[sr][sc]=true; int cont=0; for(int i=0;i<M;i++){ if(W[i]=='S') sr++; if(W[i]=='N') sr--; if(W[i]=='E') sc++; if(W[i]=='W') sc--; B[sr][sc]=true; } for(int r=1;r<R+1;r++) for(int i=1;i<C+3;i++) if(B[r][i] and !B[r][i-1]) A[r-1][i]=-1; else if(!B[r][i] and B[r][i-1]) A[r-1][i]=++cont; else A[r-1][i]=A[r-1][i-1]; for(int i=1;i<C+3;i++) if((B[2][i]&B[1][i]) and !(B[2][i-1]&B[1][i-1])) A[2][i]=-1; else if(!(B[2][i]&B[1][i]) and (B[2][i-1]&B[1][i-1])) A[2][i]=++cont; else A[2][i]=A[2][i-1]; for(int k=0;k<3;k++){ for(int i=1;i<C+3;i++) P[k][0][i]=(A[k][i]==-1)?P[k][0][i-1]:A[k][i]; for(int i=C+1;i>=0;i--) P[k][1][i]=(A[k][i]==-1)?P[k][1][i+1]:A[k][i]; } for(int k=0;k<3;k++){ int res; for(int i=C+1;i>=0;i--) if(P[k][0][i]==-1 and P[k][0][i+1]!=-1) res=P[k][0][i+1]-1; for(int i=C+1;i>=0;i--) if(P[k][0][i]==-1) P[k][0][i]=res; } /* for(int k=0;k<3;k++){ for(int i=0;i<C+3;i++) cout<<A[k][i]<<" "; cout<<endl; } for(int k=0;k<3;k++){ for(int i=0;i<C+3;i++) cout<<P[k][0][i]<<" "; cout<<endl; } for(int k=0;k<3;k++){ for(int i=0;i<C+3;i++) cout<<P[k][1][i]<<" "; cout<<endl; }*/ } int colour(int ar, int ac, int br, int bc) { int k; if(ar==1 and br==1) k=0; else if(ar==2 and br==2) k=1; else if(ar==1 and br==2) k=2; else assert(false); return P[k][0][bc]-P[k][1][ac]+1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 652 KB | Output is correct |
2 | Correct | 3 ms | 652 KB | Output is correct |
3 | Correct | 171 ms | 11088 KB | Output is correct |
4 | Correct | 102 ms | 14204 KB | Output is correct |
5 | Correct | 108 ms | 16992 KB | Output is correct |
6 | Correct | 103 ms | 19816 KB | Output is correct |
7 | Correct | 100 ms | 22824 KB | Output is correct |
8 | Correct | 101 ms | 25776 KB | Output is correct |
9 | Correct | 97 ms | 28796 KB | Output is correct |
10 | Correct | 110 ms | 31712 KB | Output is correct |
11 | Correct | 140 ms | 34476 KB | Output is correct |
12 | Correct | 105 ms | 37348 KB | Output is correct |
13 | Correct | 92 ms | 40160 KB | Output is correct |
14 | Correct | 89 ms | 43068 KB | Output is correct |
15 | Correct | 80 ms | 45860 KB | Output is correct |
16 | Correct | 93 ms | 48844 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 48844 KB | Output is correct |
2 | Runtime error | 4 ms | 48844 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 3 ms | 504 KB | Execution killed with signal 11 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |