# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
863659 |
2023-10-20T16:40:23 Z |
Rifal |
Zagrade (COI20_zagrade) |
C++14 |
|
508 ms |
2472 KB |
#include <bits/stdc++.h>
#include <fstream>
//#define endl '\n'
#define mod 1000000007
#define INF 900000000
//#define cin fin
//#define cout fout
//#define fi first
//#define se second
using namespace std;
//ofstream fout("intel.out");
//ifstream fin("intel.in");
int main()
{
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
int n, q; cin >> n >> q; string ans; stack<int> st;
for(int i = 1; i <= n; i++) {
if(st.empty()) {
st.push(i);
ans.push_back('(');
}
else {
cout << '?' << ' ' << st.top() << ' ' << i << endl;
int x; cin >> x;
if(x == 1) {
st.pop();
ans.push_back(')');
}
else {
st.push(i);
ans.push_back('(');
}
}
}
if(!st.empty()) {
// cout << st.size() << endl;
int siz = st.size();
for(int i = 0; i < siz/2; i++) {
// cout << st.top() << 'l' << endl;
ans[st.top()-1] = '(';
st.pop();
}
for(int i = 0; i < siz/2; i++) {
// cout << st.top() << 'g' << endl;
ans[st.top()-1] = ')';
st.pop();
}
}
cout << '!' << ' ' << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
2 ms |
344 KB |
Output is correct |
3 |
Correct |
6 ms |
600 KB |
Output is correct |
4 |
Correct |
4 ms |
600 KB |
Output is correct |
5 |
Correct |
4 ms |
600 KB |
Output is correct |
6 |
Correct |
4 ms |
344 KB |
Output is correct |
7 |
Correct |
5 ms |
600 KB |
Output is correct |
8 |
Correct |
3 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
4 ms |
708 KB |
Output is correct |
3 |
Correct |
5 ms |
600 KB |
Output is correct |
4 |
Correct |
3 ms |
600 KB |
Output is correct |
5 |
Correct |
4 ms |
600 KB |
Output is correct |
6 |
Correct |
5 ms |
856 KB |
Output is correct |
7 |
Correct |
3 ms |
344 KB |
Output is correct |
8 |
Correct |
4 ms |
600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
227 ms |
1156 KB |
Output is correct |
3 |
Correct |
448 ms |
1408 KB |
Output is correct |
4 |
Correct |
482 ms |
1400 KB |
Output is correct |
5 |
Correct |
452 ms |
1312 KB |
Output is correct |
6 |
Correct |
469 ms |
1628 KB |
Output is correct |
7 |
Correct |
481 ms |
1936 KB |
Output is correct |
8 |
Correct |
508 ms |
1560 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
440 ms |
2472 KB |
Output is correct |
3 |
Correct |
445 ms |
1132 KB |
Output is correct |
4 |
Correct |
451 ms |
1740 KB |
Output is correct |
5 |
Correct |
432 ms |
1352 KB |
Output is correct |
6 |
Correct |
461 ms |
1956 KB |
Output is correct |
7 |
Correct |
478 ms |
1628 KB |
Output is correct |
8 |
Correct |
413 ms |
1152 KB |
Output is correct |