답안 #821755

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
821755 2023-08-11T15:32:33 Z Darren0724 Zagrade (COI20_zagrade) C++17
100 / 100
808 ms 1532 KB
//#pragma GCC optimize("Ofast","O3","unroll-loops")
//#pragma GCC target("avx2")
#include<bits/stdc++.h>
using namespace std;
//#define double long double
#define int long long
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define rz resize
#define pb emplace_back
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define x first
#define y second
#define ACorz ios_base::sync_with_stdio(false);cin.tie(0);
//#define endl '\n'
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const int INF=1e9,INF2=2e9;
const int mod1=1e9+7;
const int mod=998244353;
const int N=5005;
const int K=45000;
const int M=5000;
int ask(int a,int b){
    cout<<"? "<<a+1<<' '<<b+1<<endl;
    int p;cin>>p;
    return p;
}

int32_t main(){
    //ACorz;
    int n;cin>>n;
    int q;cin>>q;
    vector<int> v;
    string s(n,'0');
    for(int i=0;i<n;i++){
        if(v.size()==0){
            v.push_back(i);
            continue;
        }
        if(ask(v.back(),i)){
            s[v.back()]='(';
            s[i]=')';
            v.pop_back();
        }
        else{
            v.push_back(i);
        }
    }
    int x=v.size()/2;
    for(int i=0;i<x;i++){
        s[v.back()]='(';
        v.pop_back();
    }
    for(int i=0;i<x;i++){
        s[v.back()]=')';
        v.pop_back();
    }
    cout<<"! "<<s<<endl;

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 3 ms 208 KB Output is correct
3 Correct 4 ms 208 KB Output is correct
4 Correct 6 ms 208 KB Output is correct
5 Correct 5 ms 212 KB Output is correct
6 Correct 9 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
8 Correct 9 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 7 ms 208 KB Output is correct
4 Correct 5 ms 208 KB Output is correct
5 Correct 10 ms 208 KB Output is correct
6 Correct 9 ms 304 KB Output is correct
7 Correct 6 ms 208 KB Output is correct
8 Correct 5 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 380 ms 376 KB Output is correct
3 Correct 733 ms 384 KB Output is correct
4 Correct 546 ms 388 KB Output is correct
5 Correct 808 ms 384 KB Output is correct
6 Correct 792 ms 396 KB Output is correct
7 Correct 569 ms 1088 KB Output is correct
8 Correct 716 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 753 ms 1532 KB Output is correct
3 Correct 640 ms 712 KB Output is correct
4 Correct 599 ms 1060 KB Output is correct
5 Correct 656 ms 764 KB Output is correct
6 Correct 686 ms 1028 KB Output is correct
7 Correct 551 ms 940 KB Output is correct
8 Correct 671 ms 380 KB Output is correct