# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1069303 | 2024-08-21T19:03:27 Z | hasan2006 | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 168 ms | 24176 KB |
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; #define TL ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define rall(s) s.rbegin(),s.rend() #define all(s) s.begin(),s.end() #define pb push_back #define se second #define fi first #define ll long long #define ld long double #define YES cout<<"YES\n" #define Yes cout<<"Yes\n" #define yes cout<<"yes\n" #define NO cout<<"NO\n" #define No cout<<"No\n" #define no cout<<"no\n" const int N = 2e5 + 9 , mod = 1e9 + 7; ll a[N] , b[N] , dp[N]; //int press(string a){} int construct(vector<vector<int>> v){ ll i , j , l , r , s = 0, f , n , m , x , y , k; n = v.size(); vector<vector<int>>c(n); for(i = 0; i < n; i++) c[i].resize(n); for(i = 0; i < n; i++){ if(b[i] != 0) continue; vector<pair<int,pair<int,int>>>vc; vector<int>v1 , v2 , v3; for(j = 0; j < n; j++) if(v[i][j]) b[j] = 1 , v1.pb(j); l = r = 0; for(x = 0; x < v1.size(); x++) for(y = x + 1; y < v1.size(); y++){ vc.pb({v[v1[x]][v1[y]] , {v1[x] , v1[y]}}); if(v[v1[x]][v1[y]] == 2) l = 1; if(v[v1[x]][v1[y]] == 3) r = 1; } sort(all(vc)); if(v1.size() == 1) continue; if((l == 1 && r == 1) || vc.front().fi == 0){ return 0; } for(auto to : vc) if(to.fi == 1 && to.se.fi != to.se.se) b[to.se.fi] = b[to.se.se] = 2; set<int>st; for(auto to : v1){ st.insert(to); if(b[to] == 1) v2.pb(to); else v3.pb(to); } f = -1; for(auto to : v3){ if(f != -1) c[to][f] = c[f][to] = 1; f = to; } if(v2.size()){ if(v3.size()) v2.pb(v3.back()); if(v2.size() <= vc.back().fi){ return 0; } f = v2.back(); for(auto to : v2) c[f][to] = c[to][f] = 1 , f = to; if(vc.back().fi == 3) c[v2[0]][v2[2]] = c[v2[2]][v2[0]] = 1; } for(auto to : v1){ ll L = 0 ,R = 0 , s =0; for(j = 0; j < n ; j++) if(v[to][j] != 0){ if(st.find(j) == st.end()) return 0; s++; if(to == j) continue; if(v[to][j] == 2) L = 1; else if(v[to][j] == 3) R = 1; else { if(b[to] == 1 || b[j] == 1) return 0; } } if((L > l) || (R > r) || s != v1.size()) return 0; } } /* for(i = 0; i < n; i++){ for(j = 0; j < n; j++) cout<<c[i][j]<<" "; cout<<"\n"; }*/ build(c); return 1; } /* int main(){ #ifndef ONLINE_JUDGE freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif }*/ // Author : حسن
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 6 ms | 1388 KB | Output is correct |
7 | Correct | 168 ms | 24096 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 6 ms | 1388 KB | Output is correct |
7 | Correct | 168 ms | 24096 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 5 ms | 1372 KB | Output is correct |
13 | Correct | 115 ms | 24084 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 3 ms | 1116 KB | Output is correct |
17 | Correct | 79 ms | 17336 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 344 KB | Output is correct |
20 | Correct | 31 ms | 6228 KB | Output is correct |
21 | Correct | 122 ms | 24116 KB | Output is correct |
22 | Correct | 119 ms | 24148 KB | Output is correct |
23 | Correct | 142 ms | 24028 KB | Output is correct |
24 | Correct | 119 ms | 24144 KB | Output is correct |
25 | Correct | 56 ms | 14408 KB | Output is correct |
26 | Correct | 58 ms | 14076 KB | Output is correct |
27 | Correct | 145 ms | 24004 KB | Output is correct |
28 | Correct | 121 ms | 23948 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 1 ms | 348 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 448 KB | Output is correct |
8 | Correct | 5 ms | 1368 KB | Output is correct |
9 | Correct | 119 ms | 23952 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 7 ms | 1412 KB | Output is correct |
13 | Correct | 155 ms | 24004 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 3 ms | 1116 KB | Output is correct |
17 | Correct | 69 ms | 15876 KB | Output is correct |
18 | Correct | 0 ms | 348 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 0 ms | 348 KB | Output is correct |
21 | Correct | 28 ms | 6300 KB | Output is correct |
22 | Correct | 129 ms | 24020 KB | Output is correct |
23 | Correct | 114 ms | 24080 KB | Output is correct |
24 | Correct | 138 ms | 24176 KB | Output is correct |
25 | Correct | 49 ms | 14160 KB | Output is correct |
26 | Correct | 56 ms | 14352 KB | Output is correct |
27 | Correct | 119 ms | 24064 KB | Output is correct |
28 | Correct | 140 ms | 23956 KB | Output is correct |
29 | Correct | 51 ms | 14256 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 348 KB | Output is correct |
4 | Correct | 30 ms | 6216 KB | Output is correct |
5 | Correct | 123 ms | 24084 KB | Output is correct |
6 | Correct | 115 ms | 24152 KB | Output is correct |
7 | Correct | 138 ms | 24028 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 28 ms | 6232 KB | Output is correct |
10 | Correct | 116 ms | 23980 KB | Output is correct |
11 | Correct | 117 ms | 23896 KB | Output is correct |
12 | Correct | 137 ms | 24052 KB | Output is correct |
13 | Correct | 1 ms | 344 KB | Output is correct |
14 | Correct | 1 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Incorrect | 13 ms | 3932 KB | Answer gives possible 0 while actual possible 1 |
17 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 6 ms | 1388 KB | Output is correct |
7 | Correct | 168 ms | 24096 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 5 ms | 1372 KB | Output is correct |
13 | Correct | 115 ms | 24084 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 3 ms | 1116 KB | Output is correct |
17 | Correct | 79 ms | 17336 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 344 KB | Output is correct |
20 | Correct | 31 ms | 6228 KB | Output is correct |
21 | Correct | 122 ms | 24116 KB | Output is correct |
22 | Correct | 119 ms | 24148 KB | Output is correct |
23 | Correct | 142 ms | 24028 KB | Output is correct |
24 | Correct | 119 ms | 24144 KB | Output is correct |
25 | Correct | 56 ms | 14408 KB | Output is correct |
26 | Correct | 58 ms | 14076 KB | Output is correct |
27 | Correct | 145 ms | 24004 KB | Output is correct |
28 | Correct | 121 ms | 23948 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 1 ms | 348 KB | Output is correct |
32 | Correct | 0 ms | 348 KB | Output is correct |
33 | Correct | 0 ms | 348 KB | Output is correct |
34 | Correct | 0 ms | 348 KB | Output is correct |
35 | Correct | 1 ms | 448 KB | Output is correct |
36 | Correct | 5 ms | 1368 KB | Output is correct |
37 | Correct | 119 ms | 23952 KB | Output is correct |
38 | Correct | 0 ms | 348 KB | Output is correct |
39 | Correct | 0 ms | 348 KB | Output is correct |
40 | Correct | 7 ms | 1412 KB | Output is correct |
41 | Correct | 155 ms | 24004 KB | Output is correct |
42 | Correct | 1 ms | 348 KB | Output is correct |
43 | Correct | 0 ms | 348 KB | Output is correct |
44 | Correct | 3 ms | 1116 KB | Output is correct |
45 | Correct | 69 ms | 15876 KB | Output is correct |
46 | Correct | 0 ms | 348 KB | Output is correct |
47 | Correct | 0 ms | 348 KB | Output is correct |
48 | Correct | 0 ms | 348 KB | Output is correct |
49 | Correct | 28 ms | 6300 KB | Output is correct |
50 | Correct | 129 ms | 24020 KB | Output is correct |
51 | Correct | 114 ms | 24080 KB | Output is correct |
52 | Correct | 138 ms | 24176 KB | Output is correct |
53 | Correct | 49 ms | 14160 KB | Output is correct |
54 | Correct | 56 ms | 14352 KB | Output is correct |
55 | Correct | 119 ms | 24064 KB | Output is correct |
56 | Correct | 140 ms | 23956 KB | Output is correct |
57 | Correct | 51 ms | 14256 KB | Output is correct |
58 | Correct | 0 ms | 344 KB | Output is correct |
59 | Correct | 0 ms | 348 KB | Output is correct |
60 | Correct | 4 ms | 1116 KB | Output is correct |
61 | Correct | 86 ms | 18300 KB | Output is correct |
62 | Correct | 1 ms | 348 KB | Output is correct |
63 | Correct | 0 ms | 348 KB | Output is correct |
64 | Correct | 0 ms | 344 KB | Output is correct |
65 | Incorrect | 13 ms | 3928 KB | Answer gives possible 0 while actual possible 1 |
66 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 344 KB | Output is correct |
2 | Correct | 0 ms | 348 KB | Output is correct |
3 | Correct | 0 ms | 344 KB | Output is correct |
4 | Correct | 0 ms | 348 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
6 | Correct | 6 ms | 1388 KB | Output is correct |
7 | Correct | 168 ms | 24096 KB | Output is correct |
8 | Correct | 1 ms | 344 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 1 ms | 344 KB | Output is correct |
12 | Correct | 5 ms | 1372 KB | Output is correct |
13 | Correct | 115 ms | 24084 KB | Output is correct |
14 | Correct | 0 ms | 348 KB | Output is correct |
15 | Correct | 0 ms | 348 KB | Output is correct |
16 | Correct | 3 ms | 1116 KB | Output is correct |
17 | Correct | 79 ms | 17336 KB | Output is correct |
18 | Correct | 0 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 344 KB | Output is correct |
20 | Correct | 31 ms | 6228 KB | Output is correct |
21 | Correct | 122 ms | 24116 KB | Output is correct |
22 | Correct | 119 ms | 24148 KB | Output is correct |
23 | Correct | 142 ms | 24028 KB | Output is correct |
24 | Correct | 119 ms | 24144 KB | Output is correct |
25 | Correct | 56 ms | 14408 KB | Output is correct |
26 | Correct | 58 ms | 14076 KB | Output is correct |
27 | Correct | 145 ms | 24004 KB | Output is correct |
28 | Correct | 121 ms | 23948 KB | Output is correct |
29 | Correct | 0 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 1 ms | 348 KB | Output is correct |
32 | Correct | 0 ms | 348 KB | Output is correct |
33 | Correct | 0 ms | 348 KB | Output is correct |
34 | Correct | 0 ms | 348 KB | Output is correct |
35 | Correct | 1 ms | 448 KB | Output is correct |
36 | Correct | 5 ms | 1368 KB | Output is correct |
37 | Correct | 119 ms | 23952 KB | Output is correct |
38 | Correct | 0 ms | 348 KB | Output is correct |
39 | Correct | 0 ms | 348 KB | Output is correct |
40 | Correct | 7 ms | 1412 KB | Output is correct |
41 | Correct | 155 ms | 24004 KB | Output is correct |
42 | Correct | 1 ms | 348 KB | Output is correct |
43 | Correct | 0 ms | 348 KB | Output is correct |
44 | Correct | 3 ms | 1116 KB | Output is correct |
45 | Correct | 69 ms | 15876 KB | Output is correct |
46 | Correct | 0 ms | 348 KB | Output is correct |
47 | Correct | 0 ms | 348 KB | Output is correct |
48 | Correct | 0 ms | 348 KB | Output is correct |
49 | Correct | 28 ms | 6300 KB | Output is correct |
50 | Correct | 129 ms | 24020 KB | Output is correct |
51 | Correct | 114 ms | 24080 KB | Output is correct |
52 | Correct | 138 ms | 24176 KB | Output is correct |
53 | Correct | 49 ms | 14160 KB | Output is correct |
54 | Correct | 56 ms | 14352 KB | Output is correct |
55 | Correct | 119 ms | 24064 KB | Output is correct |
56 | Correct | 140 ms | 23956 KB | Output is correct |
57 | Correct | 51 ms | 14256 KB | Output is correct |
58 | Correct | 0 ms | 348 KB | Output is correct |
59 | Correct | 0 ms | 348 KB | Output is correct |
60 | Correct | 0 ms | 348 KB | Output is correct |
61 | Correct | 30 ms | 6216 KB | Output is correct |
62 | Correct | 123 ms | 24084 KB | Output is correct |
63 | Correct | 115 ms | 24152 KB | Output is correct |
64 | Correct | 138 ms | 24028 KB | Output is correct |
65 | Correct | 0 ms | 348 KB | Output is correct |
66 | Correct | 28 ms | 6232 KB | Output is correct |
67 | Correct | 116 ms | 23980 KB | Output is correct |
68 | Correct | 117 ms | 23896 KB | Output is correct |
69 | Correct | 137 ms | 24052 KB | Output is correct |
70 | Correct | 1 ms | 344 KB | Output is correct |
71 | Correct | 1 ms | 348 KB | Output is correct |
72 | Correct | 0 ms | 348 KB | Output is correct |
73 | Incorrect | 13 ms | 3932 KB | Answer gives possible 0 while actual possible 1 |
74 | Halted | 0 ms | 0 KB | - |