Submission #1117161

#TimeUsernameProblemLanguageResultExecution timeMemory
1117161SofiatpcLand of the Rainbow Gold (APIO17_rainbow)C++14
0 / 100
2 ms2384 KiB
#include <bits/stdc++.h> #include "rainbow.h" using namespace std; int marc[5][200005], sum[5][200005], f, fl, fr, le, ld; void init(int r, int c, int sr, int sc, int m, char *s) { marc[sr][sc] = 1; le = sc; ld = sc; for(int i = 0; i < m; i++){ if(s[i] == 'N')sr--; else if(s[i] == 'S')sr++; else if(s[i] == 'W')sc--; else sc++; le = min(le,sc); ld = max(ld,sc); marc[sr][sc] = 1; } marc[1][0] = 1; marc[2][0] = 1; for(int i = 1; i <= r; i++){ for(int j = 1; j <= c; j++){ sum[i][j] = sum[i][j-1]; if(marc[i][j-1] == 1 && marc[i][j] == 0)sum[i][j]++; } } if(sum[1][c] == 0 || sum[2][c] == 0){ if(sum[1][c] != 0)f = 1; else f = 2; int l = 0; for(int j = 1; j <= c; j++){ if(marc[f][j] == 1 && l == 0)l = j; if(marc[f][j] == 0 && l == 1){ fl = l; fr = j-1; l = 0; } } if(l != 0){ fl = l; fr = c; } } } int colour(int ar, int ac, int br, int bc) { if(f){ if(ar != br)return 1; if(ar != f)return 1; if(ac < fl && fr < bc)return 2; return 1; } int ans = 0; if(ar == 1){ ans += sum[1][bc] - sum[1][ac-1]; if(marc[1][ac-1] == 0 && marc[1][ac] == 0)ans++; } if(br == 2){ ans += sum[2][bc] - sum[2][ac-1]; if(marc[2][ac-1] == 0 && marc[2][ac] == 0)ans++; } if(ar != br && ac < le)ans--; if(ar != br && bc > ld)ans--; if(ans < 0){ int teste = 0; for(int i = 1; i <= 2000000000; i++)teste += i; } return ans; }
#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...