Submission #603309

#TimeUsernameProblemLanguageResultExecution timeMemory
6033091binLollipop (POI11_liz)C++14
100 / 100
350 ms42632 KiB
#include <bits/stdc++.h> using namespace std; #define all(v) v.begin(), v.end() typedef long long ll; const int NMAX = 1e6 + 5; int n, m, a[NMAX], l, r; pair<int, int> ans[NMAX * 2]; string s; int main(void){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n >> m >> s; for(int i = 1; i <= n; i++) a[i] = (s[i -1] == 'T') ? 2 : 1; l = 1; r = n; while(a[l] == 2) l++; while(a[r] == 2) r--; if(l <= r){ int s, sum = 0; for(int i = l; i <= r; i++) sum += a[i]; s = sum; ans[s] = {l, r}; for(int i = r; i > l; i--){ ans[s - a[i]] = {l, i - 1}; ans[s - a[l]] = {l + 1, i}; s -= a[i]; } s = sum; for(int i = l - 1; i; i--){ s += a[i]; ans[s] = {i, r}; ans[s - a[r]] = {i, r - 1}; } s = sum; for(int i = r + 1; i <= n; i++){ s += a[i]; ans[s] = {l, i}; ans[s - a[l]] = {l + 1, i}; } for(int i = l - 1; i; i--){ s += a[i]; ans[s] = {i, n}; } } else{ for(int i = 1; i <= n; i++) ans[2 * i] = {1, i}; } while(m--){ int x; cin >> x; auto& [a, b] = ans[x]; if(!a) cout << "NIE\n"; else cout << a << ' ' << b << '\n'; } return 0; }

Compilation message (stderr)

liz.cpp: In function 'int main()':
liz.cpp:54:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   54 |         auto& [a, b] = ans[x];
      |               ^
#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...