Submission #702862

# Submission time Handle Problem Language Result Execution time Memory
702862 2023-02-25T09:11:53 Z Halogen popa (BOI18_popa) C++14
100 / 100
99 ms 424 KB
#include <bits/stdc++.h>
#include "popa.h"

using namespace std;

int rl[1005], rr[1005];

int solve(int N, int*l, int *r) {
    memset(rl, -1, sizeof(rl));
    memset(rr, -1, sizeof(rr));

    stack<int> s; s.push(-1);

    for (int i = 0; i < N; i++) {
        int last = -1;
        while (s.size() > 1) {
            int cur = s.top(); s.pop();

            if (!query(s.top() + 1, cur, cur, i)) {
                last = cur;
                continue;
            }

            s.push(cur);
            rr[cur] = i;
            break;
        }

        if (s.size() > 1) rr[s.top()] = i;
        rl[i] = last;
        s.push(i);
    }

    for (int i = 0; i < N; i++) {
        l[i] = rl[i];
        r[i] = rr[i];
    }


    while(s.size() > 2) s.pop();
    return s.top();
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 208 KB Output is correct
2 Correct 10 ms 208 KB Output is correct
3 Correct 8 ms 208 KB Output is correct
4 Correct 10 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 300 KB Output is correct
2 Correct 92 ms 300 KB Output is correct
3 Correct 49 ms 424 KB Output is correct
4 Correct 96 ms 296 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 85 ms 296 KB Output is correct
2 Correct 96 ms 296 KB Output is correct
3 Correct 99 ms 296 KB Output is correct
4 Correct 81 ms 296 KB Output is correct