Submission #559441

# Submission time Handle Problem Language Result Execution time Memory
559441 2022-05-09T20:24:50 Z A_D Zagrade (COI20_zagrade) C++14
71 / 100
752 ms 988 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);
    s[0]='(';
    vec.push_back(0);
    for(int i=1;i<n;i++){
        if(vec.empty()){
            s[i]='(';
            vec.push_back(i);
            continue;
        }
        cout<<"? "<<vec.back()+1<<" "<<i+1<<endl;
        int x;
        cin>>x;
        if(x==1){
            s[i]=')';
            vec.pop_back();
        }
        else{
            s[i]='(';
            vec.push_back(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:40:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   40 | main()
      | ^~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 6 ms 208 KB Output is correct
3 Correct 10 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 5 ms 208 KB Output is correct
7 Correct 4 ms 208 KB Output is correct
8 Correct 7 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 386 ms 384 KB Output is correct
3 Correct 752 ms 384 KB Output is correct
4 Correct 570 ms 388 KB Output is correct
5 Correct 665 ms 384 KB Output is correct
6 Correct 708 ms 384 KB Output is correct
7 Correct 574 ms 988 KB Output is correct
8 Correct 631 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 208 KB Mismatch at position 1. Expected ), found (
2 Halted 0 ms 0 KB -