Submission #781271

# Submission time Handle Problem Language Result Execution time Memory
781271 2023-07-13T01:39:47 Z kebine Zagrade (COI20_zagrade) C++17
100 / 100
801 ms 1548 KB
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
#define keish                             ios_base::sync_with_stdio(0);       cin.tie(0); cout.tie(0)
      
using namespace std;

int n, q, ok;

signed main(){
      keish;
  cin >> n >> q;
      
      vector<char> c(n + 5);
      vector<int> v;
      v.push_back(1);
      
      int cnt = n / 2;
      for(int i = 2; i <= n; i++){
            if(v.empty()){
                  v.push_back(i);
                  continue;
            }
            cout << "? " << v.back() << " " << i << endl;
            cin >> ok;
            if(ok){
                  c[v.back()] = '(';
                  c[i] = ')';
                  cnt--;
                  v.pop_back();
            }else{
                  v.push_back(i);
            }
      }

      for(auto x : v){
            if(cnt) c[x] = ')', cnt--;
            else c[x] = '(';
      }
      
      cout << "! ";
      for(int i = 1; i <= n; i++) cout << c[i];
      cout << endl;
}     
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 4 ms 208 KB Output is correct
3 Correct 4 ms 220 KB Output is correct
4 Correct 7 ms 256 KB Output is correct
5 Correct 6 ms 208 KB Output is correct
6 Correct 7 ms 312 KB Output is correct
7 Correct 7 ms 208 KB Output is correct
8 Correct 8 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 10 ms 348 KB Output is correct
3 Correct 9 ms 208 KB Output is correct
4 Correct 9 ms 316 KB Output is correct
5 Correct 7 ms 208 KB Output is correct
6 Correct 7 ms 316 KB Output is correct
7 Correct 9 ms 316 KB Output is correct
8 Correct 8 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 208 KB Output is correct
2 Correct 272 ms 392 KB Output is correct
3 Correct 572 ms 400 KB Output is correct
4 Correct 577 ms 396 KB Output is correct
5 Correct 651 ms 396 KB Output is correct
6 Correct 790 ms 392 KB Output is correct
7 Correct 801 ms 968 KB Output is correct
8 Correct 640 ms 400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 633 ms 1548 KB Output is correct
3 Correct 694 ms 768 KB Output is correct
4 Correct 714 ms 1092 KB Output is correct
5 Correct 767 ms 732 KB Output is correct
6 Correct 641 ms 1084 KB Output is correct
7 Correct 629 ms 880 KB Output is correct
8 Correct 449 ms 400 KB Output is correct