답안 #780439

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
780439 2023-07-12T09:01:14 Z makanhulia Zagrade (COI20_zagrade) C++17
71 / 100
780 ms 908 KB
#include <bits/stdc++.h>
using namespace std;

# define int long long
# define fir first
# define sec second
# define pb push_back

const int cnst = 2e5+5;
bool mutipletestcase = 0;
bool debug = 0;

string checker;

int find(int x, int y) {
    int temp = 0;
    for(int i = x-1; i<y; i++) {
        if(checker[i] == '(') temp++;
        else temp--;

        if(temp < 0) return 0;
    }
    
    return temp == 0;
}

int ask(int l, int r) {
    cout << "? " << l << " " << r << endl;
    int a;
    if(!debug) cin >> a;
    else a = find(l, r);
    return a;
}

void solve() {
    int n, q; cin >> n >> q;
    string ans = "(";

    if(debug) cin >> checker;

    stack<int> st;
    st.push(1); st.push(1);

    for(int i = 2; i<=n; i++) {
        bool a = ask(st.top(), i);
        if(a) st.pop(), ans += ')';
        else ans += '(', st.push(i);
    }

    cout << "! " << ans << endl;
}

signed main() {
    ios_base::sync_with_stdio(false);
    int t = 1;
    if(mutipletestcase) cin >> t; 
    while(t--) solve();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 5 ms 320 KB Output is correct
3 Correct 10 ms 312 KB Output is correct
4 Correct 9 ms 316 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 9 ms 320 KB Output is correct
7 Correct 7 ms 320 KB Output is correct
8 Correct 8 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 741 ms 516 KB Output is correct
3 Correct 739 ms 628 KB Output is correct
4 Correct 490 ms 576 KB Output is correct
5 Correct 780 ms 524 KB Output is correct
6 Correct 591 ms 516 KB Output is correct
7 Correct 762 ms 908 KB Output is correct
8 Correct 643 ms 480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 208 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -