Submission #603309

# Submission time Handle Problem Language Result Execution time Memory
603309 2022-07-24T00:10:12 Z 1bin Lollipop (POI11_liz) C++14
100 / 100
350 ms 42632 KB
#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

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 time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 332 KB Output is correct
3 Correct 0 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 4 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 3 ms 724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 980 KB Output is correct
2 Correct 6 ms 980 KB Output is correct
3 Correct 22 ms 2284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 2772 KB Output is correct
2 Correct 89 ms 7372 KB Output is correct
3 Correct 45 ms 4812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 18 ms 3028 KB Output is correct
2 Correct 17 ms 2512 KB Output is correct
3 Correct 41 ms 5436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 7012 KB Output is correct
2 Correct 69 ms 6724 KB Output is correct
3 Correct 96 ms 10568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 179 ms 18276 KB Output is correct
2 Correct 165 ms 17384 KB Output is correct
3 Correct 168 ms 22112 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 153 ms 19692 KB Output is correct
2 Correct 175 ms 20916 KB Output is correct
3 Correct 212 ms 27556 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 329 ms 38892 KB Output is correct
2 Correct 306 ms 35328 KB Output is correct
3 Correct 290 ms 37160 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 350 ms 41060 KB Output is correct
2 Correct 304 ms 34892 KB Output is correct
3 Correct 268 ms 42632 KB Output is correct