# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1003803 |
2024-06-20T17:59:03 Z |
vjudge1 |
Zagrade (COI20_zagrade) |
C++17 |
|
595 ms |
1620 KB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 1e5+5;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pb push_back
#define fr first
#define sc second
int n, q;
string ans;
int main() {
cin >> n >> q;
for(int i = 1; i <= n; i++) ans += '.';
stack<int> fila;
fila.push(1);
for(int i = 2; i <= n; i++) {
int x = fila.top(), aux;
cout << "? " << x << " " << i << endl;
cin >> aux;
if(aux) {
fila.pop();
ans[x-1] = '(';
ans[i-1] = ')';
continue;
}
fila.push(i);
}
int s = sz(fila);
for(int i = 1; i <= s; i++) {
if(i <= s/2) ans[fila.top()-1] = '(';
else ans[fila.top()-1] = ')';
fila.pop();
}
cout << "! " << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
4 ms |
344 KB |
Output is correct |
3 |
Runtime error |
0 ms |
344 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Runtime error |
1 ms |
856 KB |
Execution killed with signal 11 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
595 ms |
1620 KB |
Output is correct |
3 |
Runtime error |
1 ms |
856 KB |
Execution killed with signal 11 |
4 |
Halted |
0 ms |
0 KB |
- |