# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
757727 | 2023-06-13T16:37:37 Z | Piokemon | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 262 ms | 22200 KB |
#include "supertrees.h" #include <bits/stdc++.h> using namespace std; typedef long long int ll; bool odw[1009]; int nr[1009]; vector<int> lista[1009]; int incykl[1009]; int construct(vector<vector<int>> p) { int n = p.size(); vector<int> czesc(n,0); vector<vector<int>> answer(n,czesc); for(int i=0;i<=n;i++) odw[i]=0; for (int i=0;i<n;i++){ if (odw[i]) continue; nr[i] = i; lista[i].push_back(i); odw[i] = 1; for (int j=0;j<n;j++){ if (p[i][j]==3) return 0; if (odw[j] || i==j) continue; if (p[i][j]==1){ answer[i][j] = 1; answer[j][i] = 1; nr[j] = i; lista[i].push_back(j); odw[j] = 1; } } } for (int i=0;i<n;i++){ for (int j=0;j<n;j++){ if (p[i][j] != p[nr[i]][j]) return 0; } } for(int i=0;i<=n;i++) odw[i]=0; /*cout << "nr: "; for (int i=0;i<n;i++) cout << nr[i] << ' '; cout << '\n';*/ for (int i=0;i<n;i++){ if (nr[i]!=i || odw[i]) continue; vector<int> cykl; cykl.push_back(i); for (int j=0;j<n;j++){ if (p[i][j]==2 && !odw[nr[j]]){ cykl.push_back(nr[j]); odw[nr[j]] = 1; } } for (int j=0;j<=n;j++) incykl[j] = 0; for (int j:cykl) incykl[j] = 1; for (int j:cykl){ for (int k=0;k<n;k++){ if (nr[k]==j){ if (p[k][j] != 1) return 0; } else if (incykl[nr[k]]){ if (p[k][j] != 2) return 0; } else{ if (p[k][j] != 0) return 0; } } } /*cout << "cykl: "; for (int j:cykl){ cout << j << ' '; } cout << '\n';*/ if (cykl.size()==1) continue; for (int j=0;j<cykl.size()-1;j++){ answer[cykl[j]][cykl[j+1]] = 1; answer[cykl[j+1]][cykl[j]] = 1; } answer[cykl.back()][cykl[0]] = 1; answer[cykl[0]][cykl.back()] =1; } build(answer); return 1; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | 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 | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 9 ms | 1212 KB | Output is correct |
7 | Correct | 240 ms | 22060 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 9 ms | 1212 KB | Output is correct |
7 | Correct | 240 ms | 22060 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 9 ms | 1224 KB | Output is correct |
13 | Correct | 199 ms | 22052 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 4 ms | 724 KB | Output is correct |
17 | Correct | 83 ms | 12064 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 50 ms | 5696 KB | Output is correct |
21 | Correct | 208 ms | 22080 KB | Output is correct |
22 | Correct | 208 ms | 22064 KB | Output is correct |
23 | Correct | 230 ms | 22080 KB | Output is correct |
24 | Correct | 192 ms | 22084 KB | Output is correct |
25 | Correct | 93 ms | 12068 KB | Output is correct |
26 | Correct | 103 ms | 12176 KB | Output is correct |
27 | Correct | 214 ms | 22052 KB | Output is correct |
28 | Correct | 214 ms | 22176 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Incorrect | 0 ms | 212 KB | Answer gives possible 1 while actual possible 0 |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 46 ms | 5800 KB | Output is correct |
5 | Correct | 262 ms | 21984 KB | Output is correct |
6 | Correct | 196 ms | 22052 KB | Output is correct |
7 | Correct | 185 ms | 22004 KB | Output is correct |
8 | Correct | 0 ms | 212 KB | Output is correct |
9 | Correct | 59 ms | 5708 KB | Output is correct |
10 | Correct | 187 ms | 22052 KB | Output is correct |
11 | Correct | 196 ms | 22092 KB | Output is correct |
12 | Correct | 209 ms | 22200 KB | Output is correct |
13 | Correct | 0 ms | 212 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 48 ms | 5728 KB | Output is correct |
17 | Correct | 196 ms | 22116 KB | Output is correct |
18 | Correct | 193 ms | 22056 KB | Output is correct |
19 | Correct | 194 ms | 22088 KB | Output is correct |
20 | Correct | 196 ms | 22100 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | 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 | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 9 ms | 1212 KB | Output is correct |
7 | Correct | 240 ms | 22060 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 9 ms | 1224 KB | Output is correct |
13 | Correct | 199 ms | 22052 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 4 ms | 724 KB | Output is correct |
17 | Correct | 83 ms | 12064 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 50 ms | 5696 KB | Output is correct |
21 | Correct | 208 ms | 22080 KB | Output is correct |
22 | Correct | 208 ms | 22064 KB | Output is correct |
23 | Correct | 230 ms | 22080 KB | Output is correct |
24 | Correct | 192 ms | 22084 KB | Output is correct |
25 | Correct | 93 ms | 12068 KB | Output is correct |
26 | Correct | 103 ms | 12176 KB | Output is correct |
27 | Correct | 214 ms | 22052 KB | Output is correct |
28 | Correct | 214 ms | 22176 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
31 | Correct | 0 ms | 212 KB | Output is correct |
32 | Incorrect | 0 ms | 212 KB | Answer gives possible 1 while actual possible 0 |
33 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | 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 | 0 ms | 212 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 9 ms | 1212 KB | Output is correct |
7 | Correct | 240 ms | 22060 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 9 ms | 1224 KB | Output is correct |
13 | Correct | 199 ms | 22052 KB | Output is correct |
14 | Correct | 1 ms | 212 KB | Output is correct |
15 | Correct | 1 ms | 212 KB | Output is correct |
16 | Correct | 4 ms | 724 KB | Output is correct |
17 | Correct | 83 ms | 12064 KB | Output is correct |
18 | Correct | 1 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 50 ms | 5696 KB | Output is correct |
21 | Correct | 208 ms | 22080 KB | Output is correct |
22 | Correct | 208 ms | 22064 KB | Output is correct |
23 | Correct | 230 ms | 22080 KB | Output is correct |
24 | Correct | 192 ms | 22084 KB | Output is correct |
25 | Correct | 93 ms | 12068 KB | Output is correct |
26 | Correct | 103 ms | 12176 KB | Output is correct |
27 | Correct | 214 ms | 22052 KB | Output is correct |
28 | Correct | 214 ms | 22176 KB | Output is correct |
29 | Correct | 0 ms | 212 KB | Output is correct |
30 | Correct | 1 ms | 212 KB | Output is correct |
31 | Correct | 0 ms | 212 KB | Output is correct |
32 | Incorrect | 0 ms | 212 KB | Answer gives possible 1 while actual possible 0 |
33 | Halted | 0 ms | 0 KB | - |