# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
706433 |
2023-03-06T14:51:03 Z |
vjudge1 |
Zagrade (COI20_zagrade) |
C++17 |
|
867 ms |
1316 KB |
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
//#define endl '\n'
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define F first
#define S second
#define sz(x) (int)(x).size()
#define pb push_back
const int mod = 1e7 + 7;
const int N = 1e6 + 15;
const ll inf = 1e18;
int32_t main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
stack<int> st;
st.push(0);
int n,q;
cin >> n >> q;
vector<char> a(n,'x');
int valid=0;
int op=n/2,cl=n/2; // number of open bracket needed ..
for (int i=1;i<n;i++){
if (st.empty()){
st.push(i);
continue;
}
cout << "? " << st.top()+1 << ' ' << i+1 << endl;
cout.flush();
cin >> valid;
if (valid){
a[st.top()] = '(';
a[i] = ')';
op--;cl--;
st.pop();
}
else {
st.push(i);
}
}
// now they are )))(((
for (int i=0;i<op;i++){
a[st.top()] = '(';
st.pop();
}
for (int i=0;i<cl;i++){
a[st.top()] = ')';
st.pop();
}
cout << "! ";
for (auto it : a) cout << it ;
cout << endl;
cout.flush();
}
# |
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 |
10 ms |
208 KB |
Output is correct |
4 |
Correct |
8 ms |
208 KB |
Output is correct |
5 |
Correct |
7 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 |
8 ms |
208 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
12 ms |
316 KB |
Output is correct |
3 |
Correct |
9 ms |
208 KB |
Output is correct |
4 |
Correct |
9 ms |
208 KB |
Output is correct |
5 |
Correct |
7 ms |
208 KB |
Output is correct |
6 |
Correct |
7 ms |
208 KB |
Output is correct |
7 |
Correct |
10 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 |
295 ms |
396 KB |
Output is correct |
3 |
Correct |
734 ms |
392 KB |
Output is correct |
4 |
Correct |
844 ms |
400 KB |
Output is correct |
5 |
Correct |
756 ms |
392 KB |
Output is correct |
6 |
Correct |
772 ms |
396 KB |
Output is correct |
7 |
Correct |
547 ms |
932 KB |
Output is correct |
8 |
Correct |
815 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
208 KB |
Output is correct |
2 |
Correct |
755 ms |
1316 KB |
Output is correct |
3 |
Correct |
823 ms |
656 KB |
Output is correct |
4 |
Correct |
794 ms |
988 KB |
Output is correct |
5 |
Correct |
752 ms |
612 KB |
Output is correct |
6 |
Correct |
621 ms |
964 KB |
Output is correct |
7 |
Correct |
547 ms |
700 KB |
Output is correct |
8 |
Correct |
867 ms |
396 KB |
Output is correct |