# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
464240 | 2021-08-12T14:59:09 Z | koioi.org-dennisstar | 카멜레온의 사랑 (JOI20_chameleon) | C++17 | 49 ms | 364 KB |
#include "chameleon.h" #include <bits/stdc++.h> using namespace std; vector<vector<int>> adj; vector<int> bi[2]; void f(int b, int x, int s, int e) { if (s==e) { vector<int> v(2); v[0]=x, v[1]=bi[b][s]; if (Query(v)!=1) return ; adj[x].emplace_back(bi[b][s]); adj[bi[b][s]].emplace_back(x); return ; } vector<int> v(1, x), w(1, x); int m=(s+e)/2; for (int i=s; i<=m; i++) v.emplace_back(bi[b][i]); if (Query(v)<v.size()) f(b, x, s, m); for (int i=m+1; i<=e; i++) w.emplace_back(bi[b][i]); if (Query(w)<w.size()) f(b, x, m+1, e); } vector<int> vis; int vc; void dfs(int i, int b) { vis[i]=vc; bi[b].emplace_back(i); for (auto &j:adj[i]) if (vis[j]!=vc) dfs(j, 1-b); } void div(int n) { bi[0].clear(); bi[1].clear(); vc++; for (int i=1; i<=n; i++) if (vis[i]!=vc) dfs(i, 0); } void Solve(int n) { n*=2; adj.resize(n+1); vis.resize(n+1); for (int i=1; i<=n; i++) { for (int j=0; j<2; j++) if (bi[j].size()) f(j, i, 0, bi[j].size()-1); div(i); } auto chk = [&](int x, int y) { if (adj[x].size()==1||adj[y].size()==1) return true; int f1=0, f2=0; vector<int> v(3); v[0]=x, v[1]=y; for (auto &i:adj[x]) if (i!=y) { v[2]=i; if (Query(v)==1) { f1=1; break; } } for (auto &i:adj[y]) if (i!=x) { v[2]=i; if (Query(v)==1) { f2=1; break; } } return f1&&f2; }; for (int i=1; i<=n; i++) for (auto &j:adj[i]) if (i<j&&chk(i, j)) { Answer(i, j); adj[j].clear(); break; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 200 KB | Output is correct |
2 | Correct | 0 ms | 200 KB | Output is correct |
3 | Correct | 34 ms | 344 KB | Output is correct |
4 | Correct | 35 ms | 348 KB | Output is correct |
5 | Correct | 34 ms | 356 KB | Output is correct |
6 | Correct | 34 ms | 356 KB | Output is correct |
7 | Correct | 42 ms | 352 KB | Output is correct |
8 | Correct | 34 ms | 328 KB | Output is correct |
9 | Correct | 36 ms | 344 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 200 KB | Output is correct |
2 | Correct | 0 ms | 200 KB | Output is correct |
3 | Correct | 0 ms | 200 KB | Output is correct |
4 | Correct | 0 ms | 200 KB | Output is correct |
5 | Correct | 0 ms | 200 KB | Output is correct |
6 | Correct | 0 ms | 200 KB | Output is correct |
7 | Correct | 1 ms | 200 KB | Output is correct |
8 | Correct | 1 ms | 200 KB | Output is correct |
9 | Correct | 1 ms | 200 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 200 KB | Output is correct |
2 | Correct | 0 ms | 200 KB | Output is correct |
3 | Correct | 0 ms | 200 KB | Output is correct |
4 | Correct | 0 ms | 200 KB | Output is correct |
5 | Correct | 0 ms | 200 KB | Output is correct |
6 | Correct | 0 ms | 200 KB | Output is correct |
7 | Correct | 1 ms | 200 KB | Output is correct |
8 | Correct | 1 ms | 200 KB | Output is correct |
9 | Correct | 1 ms | 200 KB | Output is correct |
10 | Correct | 1 ms | 200 KB | Output is correct |
11 | Correct | 1 ms | 200 KB | Output is correct |
12 | Correct | 1 ms | 200 KB | Output is correct |
13 | Correct | 1 ms | 200 KB | Output is correct |
14 | Correct | 1 ms | 200 KB | Output is correct |
15 | Correct | 1 ms | 200 KB | Output is correct |
16 | Correct | 1 ms | 256 KB | Output is correct |
17 | Correct | 1 ms | 200 KB | Output is correct |
18 | Correct | 1 ms | 200 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 200 KB | Output is correct |
2 | Correct | 0 ms | 200 KB | Output is correct |
3 | Incorrect | 49 ms | 364 KB | Wrong Answer [3] |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 200 KB | Output is correct |
2 | Correct | 0 ms | 200 KB | Output is correct |
3 | Correct | 34 ms | 344 KB | Output is correct |
4 | Correct | 35 ms | 348 KB | Output is correct |
5 | Correct | 34 ms | 356 KB | Output is correct |
6 | Correct | 34 ms | 356 KB | Output is correct |
7 | Correct | 42 ms | 352 KB | Output is correct |
8 | Correct | 34 ms | 328 KB | Output is correct |
9 | Correct | 36 ms | 344 KB | Output is correct |
10 | Correct | 0 ms | 200 KB | Output is correct |
11 | Correct | 0 ms | 200 KB | Output is correct |
12 | Correct | 0 ms | 200 KB | Output is correct |
13 | Correct | 0 ms | 200 KB | Output is correct |
14 | Correct | 0 ms | 200 KB | Output is correct |
15 | Correct | 0 ms | 200 KB | Output is correct |
16 | Correct | 1 ms | 200 KB | Output is correct |
17 | Correct | 1 ms | 200 KB | Output is correct |
18 | Correct | 1 ms | 200 KB | Output is correct |
19 | Correct | 1 ms | 200 KB | Output is correct |
20 | Correct | 1 ms | 200 KB | Output is correct |
21 | Correct | 1 ms | 200 KB | Output is correct |
22 | Correct | 1 ms | 200 KB | Output is correct |
23 | Correct | 1 ms | 200 KB | Output is correct |
24 | Correct | 1 ms | 200 KB | Output is correct |
25 | Correct | 1 ms | 256 KB | Output is correct |
26 | Correct | 1 ms | 200 KB | Output is correct |
27 | Correct | 1 ms | 200 KB | Output is correct |
28 | Correct | 0 ms | 200 KB | Output is correct |
29 | Correct | 0 ms | 200 KB | Output is correct |
30 | Incorrect | 49 ms | 364 KB | Wrong Answer [3] |
31 | Halted | 0 ms | 0 KB | - |