# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
595303 | 2022-07-13T14:43:20 Z | Red_Inside | Connecting Supertrees (IOI20_supertrees) | C++17 | 171 ms | 24016 KB |
#include "supertrees.h" #include <bits/stdc++.h> #define ll long long #define f first #define s second #define pb push_back #define mp make_pair #define o cout<<"BUG"<<endl; #define FOR(i, j, n) for(int j = i; j < n; ++j) #define forn(i, j, n) for(int j = i; j <= n; ++j) #define nfor(i, j, n) for(int j = n; j >= i; --j) #define all(v) v.begin(), v.end() #define ld long double #define ull unsigned long long using namespace std; const int maxn=1e6+10,LOG=17,mod=998244353; int block = 226, timer = 0; const ld EPS = 1e-18; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define bt(i) (1 << (i)) //#define int ll const int inf=2e9; #define y1 yy #define prev pre #define pii pair <int, int> int used[maxn], good[maxn], root[maxn]; int construct(vector <vector <int> > a) { int n = a[0].size(); vector <vector <int> > ans; ans = a; forn(0, i, n-1) forn(0, j, n-1) ans[i][j] = 0; vector <int> roots; forn(0, i, n-1) { if(a[i][i] != 1) return 0; if(used[i]) continue; vector <int> vec; forn(0, j, n-1) { if(a[i][j] == 1) { vec.pb(j); used[j] = 1; } } FOR(0, j, vec.size()) { forn(0, k, n-1) { if(a[i][k] == 1 && a[vec[j]][k] != 1) return 0; if(a[i][k] != 1 && a[vec[j]][k] == 1) return 0; } } FOR(1, j, vec.size()) { ans[vec[j]][vec[j-1]] = 1; ans[vec[j-1]][vec[j]] = 1; } // cout << "NEW TREE: "; // for(auto j : vec) cout << j << " "; // cout << endl; for(auto j : vec) root[j] = vec[0]; roots.pb(vec[0]); } forn(0, i, n-1) used[i] = 0; FOR(0, i, roots.size()) { if(used[i]) continue; vector <int> vec; FOR(0, j, roots.size()) { if(a[roots[i]][roots[j]] == 2) { used[j] = i + 1; vec.pb(roots[j]); } } vec.pb(roots[i]); if(vec.size() == 2) return 0; if(vec.size() == 1) continue; FOR(0, j, vec.size()) { FOR(j + 1, k, vec.size()) { if(a[vec[j]][vec[k]] != 2) return 0; } } FOR(0, j, vec.size()) { forn(0, k, n-1) { // cout << vec[j] << ' ' << k << " " << root[k] << " " << roots[i] << endl; if(a[vec[j]][k] == 2 && root[k] != roots[i] && a[roots[i]][root[k]] != 2) return 0; if(a[vec[j]][k] == 0 && a[roots[i]][root[k]] != 0) return 0; } } FOR(1, j, vec.size()) { ans[vec[j]][vec[j-1]] = 1; ans[vec[j-1]][vec[j]] = 1; } ans[vec[0]][vec.back()] = 1; ans[vec.back()][vec[0]] = 1; } build(ans); return 1; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 308 KB | Output is correct |
4 | Correct | 1 ms | 308 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1232 KB | Output is correct |
7 | Correct | 159 ms | 22308 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 308 KB | Output is correct |
4 | Correct | 1 ms | 308 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1232 KB | Output is correct |
7 | Correct | 159 ms | 22308 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 308 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 7 ms | 1236 KB | Output is correct |
13 | Correct | 163 ms | 22252 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 3 ms | 852 KB | Output is correct |
17 | Correct | 77 ms | 12308 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 41 ms | 6036 KB | Output is correct |
21 | Correct | 167 ms | 22272 KB | Output is correct |
22 | Correct | 164 ms | 22328 KB | Output is correct |
23 | Correct | 164 ms | 22284 KB | Output is correct |
24 | Correct | 166 ms | 22532 KB | Output is correct |
25 | Correct | 73 ms | 12400 KB | Output is correct |
26 | Correct | 70 ms | 12348 KB | Output is correct |
27 | Correct | 165 ms | 22380 KB | Output is correct |
28 | Correct | 164 ms | 22432 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 308 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 7 ms | 1236 KB | Output is correct |
9 | Correct | 161 ms | 22284 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 7 ms | 1220 KB | Output is correct |
13 | Correct | 166 ms | 22396 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 3 ms | 852 KB | Output is correct |
17 | Correct | 79 ms | 12316 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 308 KB | Output is correct |
20 | Correct | 0 ms | 312 KB | Output is correct |
21 | Correct | 43 ms | 6032 KB | Output is correct |
22 | Correct | 171 ms | 22216 KB | Output is correct |
23 | Correct | 158 ms | 22288 KB | Output is correct |
24 | Correct | 169 ms | 22248 KB | Output is correct |
25 | Correct | 73 ms | 12344 KB | Output is correct |
26 | Correct | 73 ms | 12316 KB | Output is correct |
27 | Correct | 160 ms | 23988 KB | Output is correct |
28 | Correct | 168 ms | 24016 KB | Output is correct |
29 | Correct | 77 ms | 14028 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 40 ms | 5956 KB | Output is correct |
5 | Correct | 169 ms | 22312 KB | Output is correct |
6 | Correct | 167 ms | 22256 KB | Output is correct |
7 | Correct | 168 ms | 22268 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 41 ms | 6040 KB | Output is correct |
10 | Correct | 165 ms | 22300 KB | Output is correct |
11 | Correct | 162 ms | 22320 KB | Output is correct |
12 | Correct | 168 ms | 22232 KB | Output is correct |
13 | Correct | 0 ms | 316 KB | Output is correct |
14 | Correct | 0 ms | 308 KB | Output is correct |
15 | Correct | 1 ms | 312 KB | Output is correct |
16 | Correct | 41 ms | 5964 KB | Output is correct |
17 | Correct | 168 ms | 22308 KB | Output is correct |
18 | Correct | 162 ms | 22216 KB | Output is correct |
19 | Correct | 163 ms | 22396 KB | Output is correct |
20 | Correct | 161 ms | 22264 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 308 KB | Output is correct |
4 | Correct | 1 ms | 308 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1232 KB | Output is correct |
7 | Correct | 159 ms | 22308 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 308 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 7 ms | 1236 KB | Output is correct |
13 | Correct | 163 ms | 22252 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 3 ms | 852 KB | Output is correct |
17 | Correct | 77 ms | 12308 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 41 ms | 6036 KB | Output is correct |
21 | Correct | 167 ms | 22272 KB | Output is correct |
22 | Correct | 164 ms | 22328 KB | Output is correct |
23 | Correct | 164 ms | 22284 KB | Output is correct |
24 | Correct | 166 ms | 22532 KB | Output is correct |
25 | Correct | 73 ms | 12400 KB | Output is correct |
26 | Correct | 70 ms | 12348 KB | Output is correct |
27 | Correct | 165 ms | 22380 KB | Output is correct |
28 | Correct | 164 ms | 22432 KB | Output is correct |
29 | Correct | 1 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 1 ms | 212 KB | Output is correct |
32 | Correct | 0 ms | 212 KB | Output is correct |
33 | Correct | 0 ms | 308 KB | Output is correct |
34 | Correct | 1 ms | 212 KB | Output is correct |
35 | Correct | 1 ms | 212 KB | Output is correct |
36 | Correct | 7 ms | 1236 KB | Output is correct |
37 | Correct | 161 ms | 22284 KB | Output is correct |
38 | Correct | 0 ms | 212 KB | Output is correct |
39 | Correct | 0 ms | 212 KB | Output is correct |
40 | Correct | 7 ms | 1220 KB | Output is correct |
41 | Correct | 166 ms | 22396 KB | Output is correct |
42 | Correct | 0 ms | 212 KB | Output is correct |
43 | Correct | 1 ms | 212 KB | Output is correct |
44 | Correct | 3 ms | 852 KB | Output is correct |
45 | Correct | 79 ms | 12316 KB | Output is correct |
46 | Correct | 0 ms | 212 KB | Output is correct |
47 | Correct | 0 ms | 308 KB | Output is correct |
48 | Correct | 0 ms | 312 KB | Output is correct |
49 | Correct | 43 ms | 6032 KB | Output is correct |
50 | Correct | 171 ms | 22216 KB | Output is correct |
51 | Correct | 158 ms | 22288 KB | Output is correct |
52 | Correct | 169 ms | 22248 KB | Output is correct |
53 | Correct | 73 ms | 12344 KB | Output is correct |
54 | Correct | 73 ms | 12316 KB | Output is correct |
55 | Correct | 160 ms | 23988 KB | Output is correct |
56 | Correct | 168 ms | 24016 KB | Output is correct |
57 | Correct | 77 ms | 14028 KB | Output is correct |
58 | Correct | 1 ms | 212 KB | Output is correct |
59 | Correct | 0 ms | 212 KB | Output is correct |
60 | Correct | 4 ms | 836 KB | Output is correct |
61 | Correct | 75 ms | 14080 KB | Output is correct |
62 | Correct | 1 ms | 212 KB | Output is correct |
63 | Correct | 0 ms | 212 KB | Output is correct |
64 | Correct | 0 ms | 312 KB | Output is correct |
65 | Correct | 41 ms | 6272 KB | Output is correct |
66 | Correct | 72 ms | 14080 KB | Output is correct |
67 | Correct | 72 ms | 14076 KB | Output is correct |
68 | Correct | 72 ms | 14088 KB | Output is correct |
69 | Correct | 77 ms | 14080 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 308 KB | Output is correct |
4 | Correct | 1 ms | 308 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1232 KB | Output is correct |
7 | Correct | 159 ms | 22308 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 0 ms | 212 KB | Output is correct |
10 | Correct | 0 ms | 308 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 7 ms | 1236 KB | Output is correct |
13 | Correct | 163 ms | 22252 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Correct | 0 ms | 212 KB | Output is correct |
16 | Correct | 3 ms | 852 KB | Output is correct |
17 | Correct | 77 ms | 12308 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 41 ms | 6036 KB | Output is correct |
21 | Correct | 167 ms | 22272 KB | Output is correct |
22 | Correct | 164 ms | 22328 KB | Output is correct |
23 | Correct | 164 ms | 22284 KB | Output is correct |
24 | Correct | 166 ms | 22532 KB | Output is correct |
25 | Correct | 73 ms | 12400 KB | Output is correct |
26 | Correct | 70 ms | 12348 KB | Output is correct |
27 | Correct | 165 ms | 22380 KB | Output is correct |
28 | Correct | 164 ms | 22432 KB | Output is correct |
29 | Correct | 1 ms | 212 KB | Output is correct |
30 | Correct | 0 ms | 212 KB | Output is correct |
31 | Correct | 1 ms | 212 KB | Output is correct |
32 | Correct | 0 ms | 212 KB | Output is correct |
33 | Correct | 0 ms | 308 KB | Output is correct |
34 | Correct | 1 ms | 212 KB | Output is correct |
35 | Correct | 1 ms | 212 KB | Output is correct |
36 | Correct | 7 ms | 1236 KB | Output is correct |
37 | Correct | 161 ms | 22284 KB | Output is correct |
38 | Correct | 0 ms | 212 KB | Output is correct |
39 | Correct | 0 ms | 212 KB | Output is correct |
40 | Correct | 7 ms | 1220 KB | Output is correct |
41 | Correct | 166 ms | 22396 KB | Output is correct |
42 | Correct | 0 ms | 212 KB | Output is correct |
43 | Correct | 1 ms | 212 KB | Output is correct |
44 | Correct | 3 ms | 852 KB | Output is correct |
45 | Correct | 79 ms | 12316 KB | Output is correct |
46 | Correct | 0 ms | 212 KB | Output is correct |
47 | Correct | 0 ms | 308 KB | Output is correct |
48 | Correct | 0 ms | 312 KB | Output is correct |
49 | Correct | 43 ms | 6032 KB | Output is correct |
50 | Correct | 171 ms | 22216 KB | Output is correct |
51 | Correct | 158 ms | 22288 KB | Output is correct |
52 | Correct | 169 ms | 22248 KB | Output is correct |
53 | Correct | 73 ms | 12344 KB | Output is correct |
54 | Correct | 73 ms | 12316 KB | Output is correct |
55 | Correct | 160 ms | 23988 KB | Output is correct |
56 | Correct | 168 ms | 24016 KB | Output is correct |
57 | Correct | 77 ms | 14028 KB | Output is correct |
58 | Correct | 1 ms | 212 KB | Output is correct |
59 | Correct | 0 ms | 212 KB | Output is correct |
60 | Correct | 0 ms | 212 KB | Output is correct |
61 | Correct | 40 ms | 5956 KB | Output is correct |
62 | Correct | 169 ms | 22312 KB | Output is correct |
63 | Correct | 167 ms | 22256 KB | Output is correct |
64 | Correct | 168 ms | 22268 KB | Output is correct |
65 | Correct | 0 ms | 212 KB | Output is correct |
66 | Correct | 41 ms | 6040 KB | Output is correct |
67 | Correct | 165 ms | 22300 KB | Output is correct |
68 | Correct | 162 ms | 22320 KB | Output is correct |
69 | Correct | 168 ms | 22232 KB | Output is correct |
70 | Correct | 0 ms | 316 KB | Output is correct |
71 | Correct | 0 ms | 308 KB | Output is correct |
72 | Correct | 1 ms | 312 KB | Output is correct |
73 | Correct | 41 ms | 5964 KB | Output is correct |
74 | Correct | 168 ms | 22308 KB | Output is correct |
75 | Correct | 162 ms | 22216 KB | Output is correct |
76 | Correct | 163 ms | 22396 KB | Output is correct |
77 | Correct | 161 ms | 22264 KB | Output is correct |
78 | Correct | 1 ms | 212 KB | Output is correct |
79 | Correct | 0 ms | 212 KB | Output is correct |
80 | Correct | 4 ms | 836 KB | Output is correct |
81 | Correct | 75 ms | 14080 KB | Output is correct |
82 | Correct | 1 ms | 212 KB | Output is correct |
83 | Correct | 0 ms | 212 KB | Output is correct |
84 | Correct | 0 ms | 312 KB | Output is correct |
85 | Correct | 41 ms | 6272 KB | Output is correct |
86 | Correct | 72 ms | 14080 KB | Output is correct |
87 | Correct | 72 ms | 14076 KB | Output is correct |
88 | Correct | 72 ms | 14088 KB | Output is correct |
89 | Correct | 77 ms | 14080 KB | Output is correct |
90 | Correct | 0 ms | 212 KB | Output is correct |
91 | Correct | 0 ms | 212 KB | Output is correct |
92 | Correct | 3 ms | 852 KB | Output is correct |
93 | Correct | 75 ms | 14092 KB | Output is correct |
94 | Correct | 1 ms | 212 KB | Output is correct |
95 | Incorrect | 1 ms | 308 KB | Answer gives possible 1 while actual possible 0 |
96 | Halted | 0 ms | 0 KB | - |