Submission #390839

# Submission time Handle Problem Language Result Execution time Memory
390839 2021-04-17T06:29:59 Z A_D Zagrade (COI20_zagrade) C++14
0 / 100
812 ms 328 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
void ask(int a,int b)
{
    cout<<"? "<<a<<" "<<b<<endl;
}
void solve()
{
    int n,q,x;
    cin>>n>>q;
    string s(n+1,'0');
    s[1]='(';
    s[n]=')';
    int l=2,r=n-1;
    while(l<=r){
        ask(l,r);
        cin>>x;
        if(x==1){
            s[l]='(';
            s[r]=')';
            l++;
            r--;
        }
        else{
            if(l+1==r){
                s[l]=')';
                s[r]='(';
                l++;
                r--;
            }
            else{
                ask(l-1,l);
                cin>>x;
                if(x==1){
                    s[l]=')';
                    l++;
                }
                else{
                    s[r]=')';
                    r--;
                }
            }
        }
    }
    string ans;
    for(int i=1;i<=n;i++){
        ans+=s[i];
    }
    cout<<"! "<<ans<<endl;
}
main()
{
    int t=1;
//    cin>>t;
    while(t--)solve();
}

Compilation message

zagrade.cpp:52:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   52 | main()
      |      ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Incorrect 17 ms 200 KB Mismatch at position 503. Expected (, found )
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 200 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Runtime error 812 ms 328 KB Execution killed with signal 13
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 200 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -