Submission #394272

#TimeUsernameProblemLanguageResultExecution timeMemory
394272iulia13Lollipop (POI11_liz)C++17
82 / 100
2083 ms38176 KiB
#include <iostream> using namespace std; ///nu ai format x, dar ai format x-1=> pot x + 1 ///ai format x si ai 1 langa dar n ai format x-1 => ? ///NU ai format x + 1 => NU ai 1[x-1]1 sau [x-1]2 => nu ai format x-1?????? sau e izolat la un capat 1[x-1] aaaa poti sa faci cu sufix ca sa scapi ///OK deci ca sa fie posibil sa ai x-1 tb sa ai x+1; iei sufix/prefix separat ///ai x + 1 => ca sa ai x- 1 tb sa ai un 1[x-1]1 sau [x-1]2 pai cam ai mereu const int nmax = 2e6 + 5; struct ura{ int x, y; }; ura sol[nmax]; int v[nmax]; char car[nmax]; int main() { int n, q, i, s = 0; cin >> n >> q; cin >> car + 1; for (i = 1; i <= n; i++) { if (car[i] == 'T') v[i] = 2; else v[i] = 1; sol[v[i]] = {i, i}; s += v[i]; sol[s] = {1, i}; } s = 0; for (i = n; i; i--) { s += v[i]; sol[s] = {i, n}; } for (i = 2 * n; i; i--) { if (sol[i].x) continue; if (!sol[i + 2].x) continue; int x = sol[i + 2].x; int y = sol[i + 2].y; if (v[x] == 2) sol[i] = {x + 1, y}; else if (v[y] == 2) sol[i] = {x, y - 1}; else sol[i] = {x + 1, y - 1}; } while(q--) { cin >> i; if (!sol[i].x) cout << "NIE"; else cout << sol[i].x << " " << sol[i].y; cout << '\n'; } return 0; }

Compilation message (stderr)

liz.cpp: In function 'int main()':
liz.cpp:20:16: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   20 |     cin >> car + 1;
      |            ~~~~^~~
#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...