Submission #706424

# Submission time Handle Problem Language Result Execution time Memory
706424 2023-03-06T14:40:16 Z vjudge1 Zagrade (COI20_zagrade) C++17
0 / 100
798 ms 976 KB
#include <bits/stdc++.h>
using namespace std;
// #define int long long
// #define endl '\n'
#define F first
#define S second
#define pb push_back
#define all(a) a.begin(),a.end()
const int N=4e3;
const int off=1<<20;
const int MOD=1e9+7;


signed main(){
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
   int n,q;
   cin >> n >> q;
   int mns=1;
   string s;
   int cnt=n/2;
   stack<int>stck;
   stck.push(1);
   for(int i=0;i<n;i++)s+='?';
   for(int i=2;i<=n;i++){
      cout.flush()<<"? "<<stck.top()<<' '<<i<<endl;
      int ans;
      cin >> ans;
      if(ans){
         s[stck.top()-1]='(';
         s[i-1]=')';
         stck.pop();
         cnt--;
      }
      else {
         stck.push(i);
         mns=1;
      }
   }
   int l=cnt,r=cnt;
   for(int i=0;i<n;i++){
      if(s[i]=='?'){
         if(l){
            s[i]=')';
            l--;
         }
         else{
            s[i]='(';
            r--;
         }
      }
   }
   cout.flush()<<"! "<<s<<endl;
}

Compilation message

zagrade.cpp: In function 'int main()':
zagrade.cpp:18:8: warning: variable 'mns' set but not used [-Wunused-but-set-variable]
   18 |    int mns=1;
      |        ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Runtime error 1 ms 336 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 9 ms 324 KB Output is correct
3 Runtime error 1 ms 456 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Runtime error 2 ms 848 KB Execution killed with signal 11
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 798 ms 976 KB Output is correct
3 Runtime error 1 ms 848 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -