답안 #314773

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
314773 2020-10-21T07:02:19 Z apostoldaniel854 Zagrade (COI20_zagrade) C++14
71 / 100
1033 ms 1040 KB
#include <bits/stdc++.h>

using namespace std;

bool ask (int a, int b) {
    cout << "? " << a << " " << b << endl;
    int ans;
    cin >> ans;
    return ans;
}

int main () {
    int n, Q;
    cin >> n >> Q;
    vector <int> unpaired (1, 1);
    vector <char> sol (n + 1);
    for (int i = 2; i <= n; i++) {
        if (unpaired.size () && ask (unpaired.back (), i)) {
            sol[unpaired.back ()] = '(';
            sol[i] = ')';
            unpaired.pop_back ();
        }
        else {
            unpaired.push_back (i);
        }
    }
    int sz = unpaired.size ();
    for (int i = sz / 2 + 1; i < sz; i++)
        sol[unpaired[i]] = ')';
    for (int i = 0; i < sz / 2; i++)
        sol[unpaired[i]] = '(';
    cout << "! ";
    for (int i = 1; i <= n; i++)
        cout << sol[i];
    cout << endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 3 ms 256 KB Output is correct
3 Correct 9 ms 256 KB Output is correct
4 Correct 10 ms 256 KB Output is correct
5 Correct 7 ms 256 KB Output is correct
6 Correct 9 ms 256 KB Output is correct
7 Correct 10 ms 256 KB Output is correct
8 Correct 9 ms 256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 256 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 256 KB Output is correct
2 Correct 439 ms 384 KB Output is correct
3 Correct 748 ms 384 KB Output is correct
4 Correct 786 ms 384 KB Output is correct
5 Correct 670 ms 472 KB Output is correct
6 Correct 787 ms 504 KB Output is correct
7 Correct 1033 ms 1040 KB Output is correct
8 Correct 895 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 256 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -