Submission #805713

#TimeUsernameProblemLanguageResultExecution timeMemory
805713handlewastakenLinear Garden (IOI08_linear_garden)C++17
80 / 100
40 ms3148 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) { s += po[n / 2]; if (y) s--; } if (y) s += po[(n + 1) / 2]; s %= m; } else df--; x = a; y = b; z = c; if (df < 0) c = false; if (df > 0) a = false; if (df == 2 || df == -2) b = false; } cout << s; return 0; }

Compilation message (stderr)

linear_garden.cpp: In function 'int main()':
linear_garden.cpp:41:13: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   41 |             if (y)
      |             ^~
linear_garden.cpp:43:17: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   43 |                 s %= m;
      |                 ^
#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...