# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1097640 | 2024-10-07T17:57:59 Z | FIFI_cpp | Zagrade (COI20_zagrade) | C++17 | 613 ms | 1768 KB |
#include <bits/stdc++.h> using namespace std; #define TRACE(x) cerr << #x << " " << x << endl #define FOR(i, a, b) for (int i = (a); i < int(b); ++i) #define REP(i, n) FOR(i, 0, n) #define _ << " " << const int MAXN = 1e5 + 10; int n, q; char sol[MAXN]; int ask(int a, int b) { printf("? %d %d\n", a + 1, b + 1); fflush(stdout); int ret; scanf("%d", &ret); return ret; } int ans() { printf("! %s\n", sol); fflush(stdout); exit(0); } int main(void) { scanf("%d %d", &n, &q); stack<int> S; for (int i = 0; i < n; ++i) { if (S.empty()) { S.push(i); continue; } int ok = ask(S.top(), i); if (ok) { sol[S.top()] = '('; sol[i] = ')'; S.pop(); } else { S.push(i); } } assert(S.size() % 2 == 0); int x = (int) S.size() / 2; for (int i = 0; i < x; ++i) { sol[S.top()] = '('; S.pop(); } for (int i = 0; i < x; ++i) { sol[S.top()] = ')'; S.pop(); } ans(); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 2 ms | 344 KB | Output is correct |
3 | Correct | 5 ms | 344 KB | Output is correct |
4 | Correct | 5 ms | 344 KB | Output is correct |
5 | Correct | 4 ms | 344 KB | Output is correct |
6 | Correct | 4 ms | 344 KB | Output is correct |
7 | Correct | 4 ms | 344 KB | Output is correct |
8 | Correct | 4 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 6 ms | 440 KB | Output is correct |
3 | Correct | 4 ms | 344 KB | Output is correct |
4 | Correct | 5 ms | 344 KB | Output is correct |
5 | Correct | 4 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 | 5 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 344 KB | Output is correct |
2 | Correct | 244 ms | 1240 KB | Output is correct |
3 | Correct | 565 ms | 1768 KB | Output is correct |
4 | Correct | 568 ms | 968 KB | Output is correct |
5 | Correct | 593 ms | 724 KB | Output is correct |
6 | Correct | 537 ms | 1208 KB | Output is correct |
7 | Correct | 565 ms | 1380 KB | Output is correct |
8 | Correct | 583 ms | 744 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 609 ms | 1332 KB | Output is correct |
3 | Correct | 613 ms | 1060 KB | Output is correct |
4 | Correct | 565 ms | 1376 KB | Output is correct |
5 | Correct | 598 ms | 1088 KB | Output is correct |
6 | Correct | 587 ms | 1144 KB | Output is correct |
7 | Correct | 600 ms | 888 KB | Output is correct |
8 | Correct | 593 ms | 716 KB | Output is correct |