# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
367726 | 2021-02-18T06:27:16 Z | arnold518 | Zagrade (COI20_zagrade) | C++14 | 1124 ms | 7348 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 1e5; int N, Q; map<pii, int> MM; bool query(int l, int r) { if(MM.find({l, r})!=MM.end()) return MM[{l, r}]; printf("? %d %d\n", l, r); fflush(stdout); int t; scanf("%d", &t); MM[{l, r}]=t; return t; } char ans[MAXN+10]; int main() { scanf("%d%d", &N, &Q); vector<int> V; for(int i=1; i<=N; i++) { if(V.empty()) V.push_back(i); else { int t=V.back(); if(query(t, i)) { ans[t]='('; ans[i]=')'; V.pop_back(); } else { V.push_back(i); } } } for(int i=0; i<V.size()/2; i++) ans[V[i]]=')'; for(int i=V.size()/2; i<V.size(); i++) ans[V[i]]='('; printf("! %s\n", ans+1); fflush(stdout); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 3 ms | 364 KB | Output is correct |
3 | Correct | 9 ms | 364 KB | Output is correct |
4 | Correct | 10 ms | 364 KB | Output is correct |
5 | Correct | 9 ms | 364 KB | Output is correct |
6 | Correct | 10 ms | 384 KB | Output is correct |
7 | Correct | 6 ms | 364 KB | Output is correct |
8 | Correct | 8 ms | 364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 13 ms | 524 KB | Output is correct |
3 | Correct | 11 ms | 364 KB | Output is correct |
4 | Correct | 13 ms | 512 KB | Output is correct |
5 | Correct | 9 ms | 364 KB | Output is correct |
6 | Correct | 16 ms | 364 KB | Output is correct |
7 | Correct | 13 ms | 364 KB | Output is correct |
8 | Correct | 10 ms | 492 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 541 ms | 3652 KB | Output is correct |
3 | Correct | 1025 ms | 6720 KB | Output is correct |
4 | Correct | 1050 ms | 6912 KB | Output is correct |
5 | Correct | 883 ms | 6904 KB | Output is correct |
6 | Correct | 881 ms | 7068 KB | Output is correct |
7 | Correct | 1008 ms | 7112 KB | Output is correct |
8 | Correct | 989 ms | 6768 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 900 ms | 7348 KB | Output is correct |
3 | Correct | 919 ms | 6932 KB | Output is correct |
4 | Correct | 1066 ms | 7108 KB | Output is correct |
5 | Correct | 1060 ms | 7116 KB | Output is correct |
6 | Correct | 738 ms | 7068 KB | Output is correct |
7 | Correct | 1124 ms | 7084 KB | Output is correct |
8 | Correct | 1117 ms | 6980 KB | Output is correct |