답안 #593522

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
593522 2022-07-11T10:19:25 Z jiahng Zagrade (COI20_zagrade) C++14
100 / 100
828 ms 1248 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define int ll
typedef pair<int,ll> pi;
typedef vector <int> vi;
typedef vector <pi> vpi;
typedef pair<pi, ll> pii;
typedef set <ll> si;
typedef long double ld;
#define f first
#define s second
#define mp make_pair
#define for(i,s,e) for(int i=s;i<=int(e);++i)
#define dec(i,s,e) for(int i=s;i>=int(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define afor(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define maxn 500100
#define inf (ll)1e14
#define mod 1000000007
#define getchar_unlocked _getchar_nolock

int n,q;
char ans[maxn];

bool qry(int a,int b){
    cout << "? " << a << ' ' << b << '\n';
    cout.flush();
    bool res; cin >> res;
    return res;
}
int32_t main(){
    fast;
    cin >> n >> q;
    stack <int> st; st.push(1);
    for(i,2,n){
        if (!st.empty() && qry(st.top(), i)){
            ans[i] = ')'; ans[st.top()] = '('; st.pop();
        }else st.push(i);
    }
    int m = st.size();
    for(i,1,m){
        ans[st.top()] = (i <= m/2 ? '(' : ')'); st.pop();
    }
    cout << "! "; for(i,1,n) cout << ans[i]; cout << '\n';
    cout.flush();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 2 ms 208 KB Output is correct
3 Correct 8 ms 208 KB Output is correct
4 Correct 7 ms 208 KB Output is correct
5 Correct 8 ms 208 KB Output is correct
6 Correct 8 ms 208 KB Output is correct
7 Correct 10 ms 208 KB Output is correct
8 Correct 7 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 9 ms 208 KB Output is correct
3 Correct 8 ms 208 KB Output is correct
4 Correct 6 ms 320 KB Output is correct
5 Correct 8 ms 320 KB Output is correct
6 Correct 8 ms 208 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
8 Correct 8 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 399 ms 496 KB Output is correct
3 Correct 775 ms 380 KB Output is correct
4 Correct 569 ms 388 KB Output is correct
5 Correct 814 ms 624 KB Output is correct
6 Correct 793 ms 464 KB Output is correct
7 Correct 758 ms 876 KB Output is correct
8 Correct 757 ms 444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 828 ms 1248 KB Output is correct
3 Correct 592 ms 560 KB Output is correct
4 Correct 692 ms 768 KB Output is correct
5 Correct 802 ms 680 KB Output is correct
6 Correct 565 ms 844 KB Output is correct
7 Correct 724 ms 816 KB Output is correct
8 Correct 639 ms 592 KB Output is correct