Submission #641568

# Submission time Handle Problem Language Result Execution time Memory
641568 2022-09-17T04:03:56 Z devariaota Zagrade (COI20_zagrade) C++17
0 / 100
670 ms 700 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() 
{
    cin.tie(0); ios_base::sync_with_stdio(0);

    int n, q;
    cin >> n >> q;

    vector<int> ans(n, -1);
    for(int i = 0; i < n - 1; i++) {
        cout << "? " << i + 1 << " " << i + 2 << endl;
        int x; cin >> x;
        if(x) {
            ans[i] = 1;
            ans[i + 1] = 0;
            i++;
        }
    }

    cout << "! ";
    for(int i = 0; i < n; i++) {
        if(ans[i] == -1) {
            int cnt = 0;
            int j = i;
            for(; ans[j] == -1; j++) {
                ans[j] = 1;
                cnt++;
            }
            j += 2;
            for(; cnt > 0; j++, cnt--) {
                ans[j] = 0;
            }
        }
        cout << (ans[i] ? '(' : ')');
    }
    cout << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Incorrect 8 ms 208 KB Mismatch at position 12. Expected (, found )
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 426 ms 700 KB Output is correct
3 Incorrect 670 ms 700 KB Mismatch at position 17. Expected (, found )
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -