답안 #559795

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
559795 2022-05-10T15:30:22 Z A_D Zagrade (COI20_zagrade) C++14
100 / 100
808 ms 1496 KB
#include <bits/stdc++.h>
#define int long long
#define ii pair<int,int>
#define F first
#define S second
using namespace std;

const int N=1e5+100;
bool vis[N];
vector<int> vec;
void solve()
{
    int n,q;
    cin>>n>>q;
    string s;
    s.resize(n);
    vec.push_back(0);
    for(int i=1;i<n;i++){
        if(vec.empty()){
            vec.push_back(i);
            continue;
        }
        cout<<"? "<<vec.back()+1<<" "<<i+1<<endl;
        int x;
        cin>>x;
        if(x==1){
            s[vec.back()]='(';
            s[i]=')';
            vec.pop_back();
        }
        else{
            s[i]='(';
            vec.push_back(i);
        }
    }
    int sz=vec.size();
    for(int i=0;i<sz/2;i++){
        s[vec[i]]=')';
    }
    for(int i=sz/2;i<sz;i++){
        s[vec[i]]='(';
    }
    cout<<"! "<<s<<endl;
}

main()
{
/*
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    //*/


    int t=1;
//    cin>>t;
    while(t--){
        solve();
    }
}

Compilation message

zagrade.cpp:46:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   46 | main()
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
3 Correct 8 ms 208 KB Output is correct
4 Correct 9 ms 208 KB Output is correct
5 Correct 10 ms 208 KB Output is correct
6 Correct 8 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 10 ms 208 KB Output is correct
3 Correct 8 ms 208 KB Output is correct
4 Correct 9 ms 308 KB Output is correct
5 Correct 9 ms 208 KB Output is correct
6 Correct 9 ms 208 KB Output is correct
7 Correct 9 ms 208 KB Output is correct
8 Correct 8 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 332 ms 380 KB Output is correct
3 Correct 713 ms 456 KB Output is correct
4 Correct 538 ms 388 KB Output is correct
5 Correct 680 ms 384 KB Output is correct
6 Correct 663 ms 396 KB Output is correct
7 Correct 611 ms 996 KB Output is correct
8 Correct 498 ms 396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 748 ms 1496 KB Output is correct
3 Correct 767 ms 924 KB Output is correct
4 Correct 619 ms 1236 KB Output is correct
5 Correct 549 ms 740 KB Output is correct
6 Correct 808 ms 1180 KB Output is correct
7 Correct 749 ms 772 KB Output is correct
8 Correct 581 ms 388 KB Output is correct