| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 250546 | waynetuinfor | Lollipop (POI11_liz) | C++17 | 869 ms | 112532 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e6 + 1;
int s[maxn / 2], fr[2], ql[maxn], qr[maxn];
vector<int> qry[maxn];
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, m; cin >> n >> m;
    string t; cin >> t;
    for (int i = 1; i <= n; ++i) {
        int a = (t[i - 1] == 'T' ? 2 : 1);
        s[i] = a + s[i - 1];
    }
    // for (int i = 1; i <= n; ++i) cout << s[i] << ' '; cout << endl;
    for (int i = 0; i < m; ++i) {
        int k; cin >> k;
        qry[k].push_back(i);
    } 
    for (int i = 0; i < 2; ++i) {
        int prv = -1, l = -1, r = -1;
        fr[0] = 0; fr[1] = -1;
        for (int j = 1; j <= n; ++j) {
            if (fr[(s[j] & 1) ^ i] != -1) {
                if (prv < s[j] - s[fr[(s[j] & 1) ^ i]]) {
                    prv = s[j] - s[fr[(s[j] & 1) ^ i]];
                    l = fr[(s[j] & 1) ^ i] + 1; r = j;
                }
            }
            if (fr[s[j] & 1] == -1 || fr[s[j] & 1] > s[j]) fr[s[j] & 1] = j;
        }
        if (l == -1) {
            for (int j = i; j < maxn; j += 2) {
                for (int k = 0; k < qry[j].size(); ++k) ql[qry[j][k]] = qr[qry[j][k]] = -1;
            }
            continue;
        }
        // cout << "prv = " << prv << " l = " << l << " r = " << r << endl;
        for (int j = prv + 2; j < maxn; j += 2) {
            for (int k = 0; k < qry[j].size(); ++k) ql[qry[j][k]] = qr[qry[j][k]] = -1;
        } 
        for (int j = prv; j >= 1; j -= 2) {
            for (int k = 0; k < qry[j].size(); ++k) ql[qry[j][k]] = l, qr[qry[j][k]] = r;
            if (t[l - 1] == 'T') ++l;
            else if (t[r - 1] == 'T') --r;
            else ++l, --r;
        } 
    }
    for (int i = 0; i < m; ++i) {
        if (ql[i] == -1) cout << "NIE" << '\n';
        else cout << ql[i] << ' ' << qr[i] << '\n';
    }
    return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
