답안 #609368

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
609368 2022-07-27T14:26:23 Z 1bin Lollipop (POI11_liz) C++14
100 / 100
352 ms 42476 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 = 0;
        for(int i = r; i; i--){
            s += a[i];
            ans[s] = {i, r};
            ans[s - a[r]] = {i, r - 1};
        }
        s = 0;
        for(int i = l; 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:45:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   45 |         auto& [a, b] = ans[x];
      |               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 5 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 468 KB Output is correct
2 Correct 3 ms 596 KB Output is correct
3 Correct 4 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 980 KB Output is correct
2 Correct 6 ms 984 KB Output is correct
3 Correct 24 ms 2284 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 2772 KB Output is correct
2 Correct 89 ms 7360 KB Output is correct
3 Correct 43 ms 4808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 3028 KB Output is correct
2 Correct 18 ms 2596 KB Output is correct
3 Correct 42 ms 5452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 89 ms 7112 KB Output is correct
2 Correct 68 ms 6808 KB Output is correct
3 Correct 107 ms 10572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 183 ms 18220 KB Output is correct
2 Correct 176 ms 17416 KB Output is correct
3 Correct 174 ms 22088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 154 ms 19744 KB Output is correct
2 Correct 186 ms 20856 KB Output is correct
3 Correct 215 ms 27604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 352 ms 38980 KB Output is correct
2 Correct 252 ms 35312 KB Output is correct
3 Correct 294 ms 37196 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 330 ms 41096 KB Output is correct
2 Correct 313 ms 34888 KB Output is correct
3 Correct 303 ms 42476 KB Output is correct