답안 #641574

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
641574 2022-09-17T04:35:35 Z kebine Zagrade (COI20_zagrade) C++17
71 / 100
842 ms 3052 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);
    set<int> s;
    s.insert(0);
    for(int i = 1; i < n; i++) {
        if(ans[i] != -1) continue;
        // cout << "Masuk " << i << '\n';
        while(!s.empty()) {
            int l = *s.rbegin(), r = i;
            if(l >= 0 && r < n) {
                cout << "? " << l + 1 << " " << r + 1 << endl;
                int x; cin >> x;
                if(x) {
                    ans[l] = 1;
                    ans[r] = 0;
                    s.erase(l);
                    i++;
                } else {
                    s.insert(r);
                    break;
                }
            } else {
                break;
            }
        }
        if(s.empty() && ans[i] == -1) s.insert(i);
    }

    cout << "! ";
    for(int i = 0; i < n; i++) {
        assert(ans[i] != -1);
        if(ans[i]) cout << '('; 
        else cout << ')';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 2 ms 208 KB Output is correct
3 Correct 10 ms 208 KB Output is correct
4 Correct 7 ms 208 KB Output is correct
5 Correct 9 ms 208 KB Output is correct
6 Correct 7 ms 320 KB Output is correct
7 Correct 10 ms 328 KB Output is correct
8 Correct 7 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 356 ms 700 KB Output is correct
3 Correct 696 ms 696 KB Output is correct
4 Correct 828 ms 712 KB Output is correct
5 Correct 739 ms 720 KB Output is correct
6 Correct 626 ms 720 KB Output is correct
7 Correct 605 ms 3052 KB Output is correct
8 Correct 842 ms 704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 464 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -