제출 #559791

#제출 시각아이디문제언어결과실행 시간메모리
559791A_DZagrade (COI20_zagrade)C++14
14 / 100
2447 ms376 KiB
#include <bits/stdc++.h>
#define int long long
#define ii pair<int,int>
#define F first
#define S second
using namespace std;

void solve()
{
    int n,q;
    cin>>n>>q;
    string s(n,'0');
    int h=n;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j+=2){
            if(s[i]!='0'||s[j]!='0')continue;
            if(i>=n||j>=n){
                cout<<"! "<<s<<endl;
                return;
            }
            cout<<"? "<<i+1<<" "<<j+1<<endl;
            int x;
            cin>>x;
            if(x==1){
                h-=2;
                s[i]='(';
                s[j]=')';
            }
        }
    }
    cout<<"! "<<s<<endl;
    return;
    h/=2;
    for(int i=0;i<n;i++){
        if(s[i]=='0'){
            if(h>0){
                s[i]=')';
            }
            else{
                s[i]='(';
            }
            h--;
        }
    }
    cout<<"! "<<s<<endl;
}

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

    //*/


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

컴파일 시 표준 에러 (stderr) 메시지

zagrade.cpp:48:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   48 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...