# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
641591 |
2022-09-17T06:04:24 Z |
bonk |
Zagrade (COI20_zagrade) |
C++14 |
|
1002 ms |
960 KB |
#include <bits/stdc++.h>
using namespace std;
int ask(int a, int b){
cout << "? " << a << " " << b << endl;
int ret; cin >> ret;
return ret;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, q; cin >> n >> q;
vector<char>ans(n + 1, '#');
stack<int>st;
int cnt = 0;
for(int i = 1; i <= n; i++){
if(st.empty()){
st.push(i);
continue;
}
int x = st.top();
if(ask(x, i)){
cnt += 2;
ans[x] = '(';
ans[i] = ')';
st.pop();
} else{
st.push(i);
}
}
int unused = n - cnt;
int tmp = unused;
cout << "! ";
for(int i = 1; i <= n; i++){
if(ans[i] == '#'){
if(tmp > unused/2) ans[i] = ')';
else ans[i] = '(';
tmp--;
}
cout << ans[i];
}
cout << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
4 ms |
208 KB |
Output is correct |
3 |
Correct |
7 ms |
208 KB |
Output is correct |
4 |
Correct |
7 ms |
208 KB |
Output is correct |
5 |
Correct |
10 ms |
208 KB |
Output is correct |
6 |
Correct |
8 ms |
208 KB |
Output is correct |
7 |
Correct |
9 ms |
208 KB |
Output is correct |
8 |
Correct |
7 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
8 ms |
320 KB |
Output is correct |
3 |
Correct |
8 ms |
312 KB |
Output is correct |
4 |
Correct |
8 ms |
312 KB |
Output is correct |
5 |
Correct |
6 ms |
208 KB |
Output is correct |
6 |
Correct |
7 ms |
208 KB |
Output is correct |
7 |
Correct |
6 ms |
208 KB |
Output is correct |
8 |
Correct |
7 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
369 ms |
392 KB |
Output is correct |
3 |
Correct |
714 ms |
396 KB |
Output is correct |
4 |
Correct |
774 ms |
404 KB |
Output is correct |
5 |
Correct |
890 ms |
396 KB |
Output is correct |
6 |
Correct |
905 ms |
396 KB |
Output is correct |
7 |
Correct |
1002 ms |
604 KB |
Output is correct |
8 |
Correct |
639 ms |
400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
208 KB |
Output is correct |
2 |
Correct |
833 ms |
744 KB |
Output is correct |
3 |
Correct |
783 ms |
568 KB |
Output is correct |
4 |
Correct |
823 ms |
836 KB |
Output is correct |
5 |
Correct |
860 ms |
548 KB |
Output is correct |
6 |
Correct |
822 ms |
960 KB |
Output is correct |
7 |
Correct |
788 ms |
748 KB |
Output is correct |
8 |
Correct |
837 ms |
400 KB |
Output is correct |