Submission #781274

# Submission time Handle Problem Language Result Execution time Memory
781274 2023-07-13T01:44:48 Z christinelynn Zagrade (COI20_zagrade) C++17
71 / 100
719 ms 808 KB
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define pii pair<int,int>
#define fr first
#define sc second
#define query(l, r) cout << "? " << l << " " << r << endl; cin >> res;
using namespace std;

const int N = 1e5+5;

string ans; bool res;

signed main() {
    ios_base::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(NULL);
    int n, q; cin >> n >> q;
    ans.assign(n, ' ');
    stack<int> s;
    s.push(1);
    for (int i = 2; i <= n; i++) {
    if (s.empty()) {
      s.push(i);
      continue;
    }
        int cur = s.top();
        query(cur, i);
        if (res) {
            ans[cur-1] = '(';
            ans[i-1] = ')';
            s.pop();
        } else s.push(i);
    }
    cout << "! " << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
3 Correct 5 ms 208 KB Output is correct
4 Correct 6 ms 320 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 5 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
8 Correct 5 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 363 ms 412 KB Output is correct
3 Correct 580 ms 396 KB Output is correct
4 Correct 619 ms 396 KB Output is correct
5 Correct 609 ms 400 KB Output is correct
6 Correct 600 ms 396 KB Output is correct
7 Correct 709 ms 808 KB Output is correct
8 Correct 719 ms 396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 208 KB Unexpected end of file - token expected
2 Halted 0 ms 0 KB -