# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
312545 | 2020-10-13T16:51:08 Z | model_code | Zagrade (COI20_zagrade) | C++17 | 1012 ms | 1040 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 | 256 KB | Output is correct |
2 | Correct | 6 ms | 256 KB | Output is correct |
3 | Correct | 9 ms | 372 KB | Output is correct |
4 | Correct | 9 ms | 256 KB | Output is correct |
5 | Correct | 10 ms | 256 KB | Output is correct |
6 | Correct | 9 ms | 256 KB | Output is correct |
7 | Correct | 9 ms | 384 KB | Output is correct |
8 | Correct | 9 ms | 256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 6 ms | 256 KB | Output is correct |
3 | Correct | 8 ms | 408 KB | Output is correct |
4 | Correct | 9 ms | 376 KB | Output is correct |
5 | Correct | 9 ms | 256 KB | Output is correct |
6 | Correct | 8 ms | 372 KB | Output is correct |
7 | Correct | 13 ms | 376 KB | Output is correct |
8 | Correct | 11 ms | 376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 471 ms | 772 KB | Output is correct |
3 | Correct | 981 ms | 608 KB | Output is correct |
4 | Correct | 881 ms | 924 KB | Output is correct |
5 | Correct | 959 ms | 760 KB | Output is correct |
6 | Correct | 1008 ms | 804 KB | Output is correct |
7 | Correct | 951 ms | 964 KB | Output is correct |
8 | Correct | 879 ms | 668 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 256 KB | Output is correct |
2 | Correct | 652 ms | 920 KB | Output is correct |
3 | Correct | 1012 ms | 604 KB | Output is correct |
4 | Correct | 874 ms | 1040 KB | Output is correct |
5 | Correct | 793 ms | 596 KB | Output is correct |
6 | Correct | 923 ms | 788 KB | Output is correct |
7 | Correct | 965 ms | 644 KB | Output is correct |
8 | Correct | 857 ms | 760 KB | Output is correct |