Submission #805732

#TimeUsernameProblemLanguageResultExecution timeMemory
805732handlewastakenLinear Garden (IOI08_linear_garden)C++17
100 / 100
53 ms3156 KiB
#include <iostream> #include <vector> using namespace std; typedef long long ll; int main() { int n, m, i, s = 1, df = 0, odf; cin >> n >> m; char ch; bool a, b, c, x, y, z; a = b = c = true; vector<int> po(n / 2 + 1); po[0] = 1; for (i = 1; i <= n / 2; i++) po[i] = 2 * po[i - 1] % m; while (n--) { cin >> ch; odf = df; if (ch == 'P') { odf--; df++; x = a; y = b; z = c; if (odf < -2 || odf > 2) continue; if (odf < 0) z = false; if (odf > 0) x = false; if (odf == 2 || odf == -2) y = false; if (x || z) { if (df % 2 == 0) s += po[n / 2]; else s += po[(n + 1) / 2]; if (y) s--; } if (y) { if (df % 2 == 0) s += po[(n + 1) / 2]; else s += po[n / 2]; } s %= m; } else df--; if (df < 0) c = false; if (df > 0) a = false; if (df == 2 || df == -2) b = false; } cout << s; return 0; }
#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...
#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...
#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...
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...