Submission #562633

#TimeUsernameProblemLanguageResultExecution timeMemory
562633SSRSLand of the Rainbow Gold (APIO17_rainbow)C++14
0 / 100
448 ms1048576 KiB
#include <bits/stdc++.h> #include "rainbow.h" using namespace std; vector<vector<bool>> land; vector<int> S1, S2, S12; void init(int R, int C, int sr, int sc, int M, char *S){ sr--; sc--; land = vector<vector<bool>>(R, vector<bool>(C, true)); int x = sr, y = sc; land[x][y] = false; for (int i = 0; i < M; i++){ if (S[i] == 'N'){ x--; } if (S[i] == 'S'){ x++; } if (S[i] == 'E'){ y++; } if (S[i] == 'W'){ y--; } land[x][y] = false; } S1 = vector<int>(C); S1[0] = 0; for (int i = 0; i < C - 1; i++){ S1[i + 1] = S1[i]; if (land[0][i] && !land[0][i + 1]){ S1[i + 1]++; } } S2 = vector<int>(C); S2[0] = 0; for (int i = 0; i < C - 1; i++){ S2[i + 1] = S2[i]; if (land[0][i] && !land[0][i + 1]){ S2[i + 1]++; } } S12 = vector<int>(C); S12[0] = 0; for (int i = 0; i < C - 1; i++){ S12[i + 1] = S12[i]; if ((land[0][i] || land[1][i]) && !land[0][i + 1] && !land[1][i + 1]){ S12[i + 1]++; } if (land[0][i] && !land[1][i] && !land[0][i + 1] && land[1][i + 1]){ S12[i + 1]++; } if (!land[0][i] && land[1][i] && land[0][i + 1] && !land[1][i + 1]){ S12[i + 1]++; } } } int colour(int ar, int ac, int br, int bc){ ar--; ac--; if (ar == 0 && br == 1){ int ans = S1[bc - 1] - S1[ac]; if (land[0][ac]){ ans++; } return ans; } else if (ar == 1 && br == 2){ int ans = S2[bc - 1] - S2[ac]; if (land[1][ac]){ ans++; } return ans; } else { int ans = S12[bc - 1] - S12[ac]; if (land[0][ac] || land[1][ac]){ ans++; } 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...