Submission #374554

# Submission time Handle Problem Language Result Execution time Memory
374554 2021-03-07T12:47:22 Z Alex_tz307 Zagrade (COI20_zagrade) C++17
71 / 100
999 ms 800 KB
#include <bits/stdc++.h>

using namespace std;

bool query(const int &i, const int &j) {
    cout << "? " << i + 1 << ' ' << j + 1 << endl;
    bool ans;
    cin >> ans;
    return ans;
}

int main() {
    int N, Q;
    cin >> N >> Q;
    string sol;
    sol.resize(N);
    stack<int> S;
    for(int i = 0; i < N; ++i) {
        if(S.empty()) {
            S.emplace(i);
            sol[i] = '(';
            continue;
        }
        bool ans = query(S.top(), i);
        if(ans) {
            sol[i] = ')';
            S.pop();
        }
        else {
            sol[i] = '(';
            S.emplace(i);
        }
    }
    cout << "! " << sol << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 7 ms 364 KB Output is correct
3 Correct 9 ms 364 KB Output is correct
4 Correct 8 ms 364 KB Output is correct
5 Correct 11 ms 364 KB Output is correct
6 Correct 9 ms 364 KB Output is correct
7 Correct 10 ms 364 KB Output is correct
8 Correct 10 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 423 ms 492 KB Output is correct
3 Correct 943 ms 476 KB Output is correct
4 Correct 953 ms 476 KB Output is correct
5 Correct 770 ms 476 KB Output is correct
6 Correct 963 ms 492 KB Output is correct
7 Correct 743 ms 800 KB Output is correct
8 Correct 999 ms 476 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 364 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -