Submission #412926

# Submission time Handle Problem Language Result Execution time Memory
412926 2021-05-27T19:31:57 Z couplefire Zagrade (COI20_zagrade) C++17
100 / 100
1191 ms 1100 KB
#include <bits/stdc++.h>
using namespace std;

string ans = "(";

int query(int a, int b){
    cout << "? " << a+1 << " " << b+1 << endl;
    int x; cin >> x;
    return x;
}

int main(){
    cin.tie(0)->sync_with_stdio(false);
    int n, q; cin >> n >> q;
    vector<int> pos; pos.push_back(0);
    for(int i = 1; i<n; i++)
        if(pos.empty() || !query(pos.back(), i)) 
            pos.push_back(i), ans += '(';
        else pos.pop_back(), ans += ')';
    for(int i = 0; i<(int)pos.size()/2; i++)
        ans[pos[i]] = ')';
    cout << "! " << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 5 ms 200 KB Output is correct
3 Correct 8 ms 200 KB Output is correct
4 Correct 13 ms 200 KB Output is correct
5 Correct 9 ms 304 KB Output is correct
6 Correct 12 ms 308 KB Output is correct
7 Correct 14 ms 312 KB Output is correct
8 Correct 15 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 9 ms 308 KB Output is correct
3 Correct 9 ms 200 KB Output is correct
4 Correct 8 ms 200 KB Output is correct
5 Correct 10 ms 308 KB Output is correct
6 Correct 13 ms 200 KB Output is correct
7 Correct 12 ms 328 KB Output is correct
8 Correct 8 ms 200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 517 ms 916 KB Output is correct
3 Correct 838 ms 620 KB Output is correct
4 Correct 816 ms 560 KB Output is correct
5 Correct 888 ms 528 KB Output is correct
6 Correct 925 ms 840 KB Output is correct
7 Correct 859 ms 828 KB Output is correct
8 Correct 561 ms 808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1041 ms 1100 KB Output is correct
3 Correct 1010 ms 556 KB Output is correct
4 Correct 1136 ms 788 KB Output is correct
5 Correct 1191 ms 564 KB Output is correct
6 Correct 786 ms 1064 KB Output is correct
7 Correct 888 ms 688 KB Output is correct
8 Correct 1059 ms 544 KB Output is correct