# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1003902 |
2024-06-20T19:45:57 Z |
vjudge1 |
Zagrade (COI20_zagrade) |
C++17 |
|
617 ms |
1676 KB |
#include <bits/stdc++.h>
using namespace std;
int query(int a, int b, int &Q)
{
cout << "? " << a << " " << b << endl;
int resp; cin >> resp;
return resp;
}
void solve(int N, int Q)
{
string resp(N, '.');
vector<int> resto;
for (int i = 1; i <= N; i++)
{
if (resto.empty()) resto.push_back(i);
else if(query(resto.back(), i, Q))
{
resp[resto.back()-1] = '(';
resp[i-1] = ')';
resto.pop_back();
}
else resto.push_back(i);
}
// cerr << "resp: " << resp << '\n';
// cerr << "resto: "; for (auto x : resto) cerr << " "; cerr << '\n';
int sz = resto.size();
for (int i = 0; i < sz/2; i++) resp[resto[i]-1] = ')';
for (int i = sz/2; i < sz; i++) resp[resto[i]-1] = '(';
cout << "! " << resp << endl;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N, Q;
cin >> N >> Q;
solve(N, Q);
}
# |
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 |
4 ms |
344 KB |
Output is correct |
4 |
Correct |
3 ms |
344 KB |
Output is correct |
5 |
Correct |
3 ms |
344 KB |
Output is correct |
6 |
Correct |
5 ms |
344 KB |
Output is correct |
7 |
Correct |
5 ms |
344 KB |
Output is correct |
8 |
Correct |
2 ms |
344 KB |
Output is correct |
# |
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 |
Correct |
4 ms |
448 KB |
Output is correct |
4 |
Correct |
4 ms |
456 KB |
Output is correct |
5 |
Correct |
3 ms |
344 KB |
Output is correct |
6 |
Correct |
4 ms |
344 KB |
Output is correct |
7 |
Correct |
5 ms |
344 KB |
Output is correct |
8 |
Correct |
5 ms |
344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
280 ms |
528 KB |
Output is correct |
3 |
Correct |
516 ms |
532 KB |
Output is correct |
4 |
Correct |
552 ms |
528 KB |
Output is correct |
5 |
Correct |
482 ms |
532 KB |
Output is correct |
6 |
Correct |
525 ms |
524 KB |
Output is correct |
7 |
Correct |
546 ms |
1088 KB |
Output is correct |
8 |
Correct |
512 ms |
532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
561 ms |
1676 KB |
Output is correct |
3 |
Correct |
617 ms |
1140 KB |
Output is correct |
4 |
Correct |
577 ms |
1176 KB |
Output is correct |
5 |
Correct |
595 ms |
1148 KB |
Output is correct |
6 |
Correct |
568 ms |
1636 KB |
Output is correct |
7 |
Correct |
561 ms |
1336 KB |
Output is correct |
8 |
Correct |
548 ms |
528 KB |
Output is correct |