답안 #1003811

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1003811 2024-06-20T18:10:18 Z vjudge1 Zagrade (COI20_zagrade) C++17
100 / 100
552 ms 1416 KB
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 1e5+5;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pb push_back
#define fr first
#define sc second

int n, q;
string ans;
int main() {

    cin >> n >> q;

    for(int i = 1; i <= n; i++) ans += '.';

    stack<int> fila;

    for(int i = 1; i <= n; i++) {
        if(fila.empty()) {
            fila.push(i);
            continue;
        }
        
        int x = fila.top(), aux;
        assert(1 <= x and x <= n);
        cout << "? " << x << " " << i << endl;
        cout.flush();
        cin >> aux;
        
        if(aux) {
            fila.pop();
            ans[x-1] = '(';
            ans[i-1] = ')';
            continue;
        }

        fila.push(i);
    }

    int s = sz(fila);
    for(int i = 1; i <= s; i++) {
        assert(fila.top() >= 1 and fila.top() <= n);
        if(i <= s/2) ans[fila.top()-1] = '(';
        else ans[fila.top()-1] = ')';
        fila.pop();
    }

    cout << "! " << ans << endl;
    cout.flush();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 5 ms 344 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 3 ms 344 KB Output is correct
7 Correct 5 ms 344 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 4 ms 344 KB Output is correct
3 Correct 4 ms 344 KB Output is correct
4 Correct 4 ms 440 KB Output is correct
5 Correct 4 ms 344 KB Output is correct
6 Correct 5 ms 344 KB Output is correct
7 Correct 4 ms 344 KB Output is correct
8 Correct 3 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 278 ms 628 KB Output is correct
3 Correct 523 ms 628 KB Output is correct
4 Correct 531 ms 628 KB Output is correct
5 Correct 499 ms 628 KB Output is correct
6 Correct 522 ms 852 KB Output is correct
7 Correct 540 ms 1140 KB Output is correct
8 Correct 552 ms 628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 524 ms 1416 KB Output is correct
3 Correct 539 ms 624 KB Output is correct
4 Correct 499 ms 1196 KB Output is correct
5 Correct 485 ms 624 KB Output is correct
6 Correct 548 ms 1140 KB Output is correct
7 Correct 537 ms 1104 KB Output is correct
8 Correct 493 ms 636 KB Output is correct