# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
405275 | 2021-05-16T06:58:00 Z | dxz05 | Simurgh (IOI17_simurgh) | C++14 | 465 ms | 332 KB |
#include "simurgh.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 5e5 + 3e2; typedef long long ll; vector<pair<int, int>> edges; int par[MAXN]; int findset(int x){ if (x == par[x]) return x; return par[x] = findset(par[x]); } bool unite(int x, int y){ x = findset(x); y = findset(y); if (x == y) return false; if (rand() % 2) swap(x, y); par[x] = y; return true; } int n; bool check(vector<int> &r){ if (r.size() != n - 1) return false; for (int i = 0; i < n; i++) par[i] = i; int cnt = 0; for (int i : r){ if (unite(edges[i].first, edges[i].second)) cnt++; } return cnt == n - 1; } vector<int> find_roads(int _n, vector<int> u, vector<int> v) { n = _n; int m = v.size(); for (int i = 0; i < m; i++){ edges.push_back(make_pair(u[i], v[i])); } for (int mask = 0; mask < (1 << m); mask++){ vector<int> r; for (int i = 0; i < m; i++){ if (mask & (1 << i)) r.push_back(i); } if (check(r)){ if (count_common_roads(r) == n - 1) return r; } } return {}; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 204 KB | correct |
2 | Correct | 376 ms | 288 KB | correct |
3 | Correct | 465 ms | 284 KB | correct |
4 | Correct | 2 ms | 204 KB | correct |
5 | Correct | 1 ms | 204 KB | correct |
6 | Correct | 11 ms | 204 KB | correct |
7 | Correct | 1 ms | 204 KB | correct |
8 | Correct | 1 ms | 204 KB | correct |
9 | Correct | 1 ms | 204 KB | correct |
10 | Correct | 3 ms | 204 KB | correct |
11 | Correct | 1 ms | 204 KB | correct |
12 | Correct | 4 ms | 204 KB | correct |
13 | Correct | 123 ms | 204 KB | correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 204 KB | correct |
2 | Correct | 376 ms | 288 KB | correct |
3 | Correct | 465 ms | 284 KB | correct |
4 | Correct | 2 ms | 204 KB | correct |
5 | Correct | 1 ms | 204 KB | correct |
6 | Correct | 11 ms | 204 KB | correct |
7 | Correct | 1 ms | 204 KB | correct |
8 | Correct | 1 ms | 204 KB | correct |
9 | Correct | 1 ms | 204 KB | correct |
10 | Correct | 3 ms | 204 KB | correct |
11 | Correct | 1 ms | 204 KB | correct |
12 | Correct | 4 ms | 204 KB | correct |
13 | Correct | 123 ms | 204 KB | correct |
14 | Incorrect | 4 ms | 332 KB | WA in grader: NO |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 204 KB | correct |
2 | Correct | 376 ms | 288 KB | correct |
3 | Correct | 465 ms | 284 KB | correct |
4 | Correct | 2 ms | 204 KB | correct |
5 | Correct | 1 ms | 204 KB | correct |
6 | Correct | 11 ms | 204 KB | correct |
7 | Correct | 1 ms | 204 KB | correct |
8 | Correct | 1 ms | 204 KB | correct |
9 | Correct | 1 ms | 204 KB | correct |
10 | Correct | 3 ms | 204 KB | correct |
11 | Correct | 1 ms | 204 KB | correct |
12 | Correct | 4 ms | 204 KB | correct |
13 | Correct | 123 ms | 204 KB | correct |
14 | Incorrect | 4 ms | 332 KB | WA in grader: NO |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | correct |
2 | Incorrect | 4 ms | 204 KB | WA in grader: NO |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 40 ms | 204 KB | correct |
2 | Correct | 376 ms | 288 KB | correct |
3 | Correct | 465 ms | 284 KB | correct |
4 | Correct | 2 ms | 204 KB | correct |
5 | Correct | 1 ms | 204 KB | correct |
6 | Correct | 11 ms | 204 KB | correct |
7 | Correct | 1 ms | 204 KB | correct |
8 | Correct | 1 ms | 204 KB | correct |
9 | Correct | 1 ms | 204 KB | correct |
10 | Correct | 3 ms | 204 KB | correct |
11 | Correct | 1 ms | 204 KB | correct |
12 | Correct | 4 ms | 204 KB | correct |
13 | Correct | 123 ms | 204 KB | correct |
14 | Incorrect | 4 ms | 332 KB | WA in grader: NO |
15 | Halted | 0 ms | 0 KB | - |