# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
730124 | 2023-04-25T10:01:56 Z | lucri | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 199 ms | 22132 KB |
#include "supertrees.h" #include <vector> #include <cassert> #include <cstdio> #include <cstdlib> #include <string> int t[1010]; bool e[1010],dc[1010],ca[1010]; int tata(int nod) { if(t[nod]==nod) return nod; return t[nod]=tata(t[nod]); } int construct(std::vector<std::vector<int>> p) { int n = p.size(); std::vector<std::vector<int>> answer; answer.resize(n); for (int i = 0; i < n; i++) { t[i]=i; dc[i]=false; e[i]=true; answer[i].resize(n); } for(int i=0;i<n;++i) { if(p[i][i]!=1) return 0; for(int j=0;j<n;++j) if(p[i][j]==1) { if(tata(i)!=tata(j)) { answer[i][j]=answer[j][i]=1; t[t[i]]=t[j]; } } } for(int i=0;i<n;++i) { for(int j=0;j<n;++j) if(p[i][j]==0) { if(tata(i)==tata(j)) return 0; } } for(int i=0;i<n;++i) if(e[i]) for(int j=i+1;j<n;++j) { if(e[j]) if(tata(i)==tata(j)) { e[j]=false; for(int q=0;q<n;++q) if(p[i][q]!=p[j][q]) return 0; } } int ciclu[1010]; for(int i=0;i<n;++i) { for(int q=0;q<n;++q) ca[q]=false; ca[i]=true; if(e[i]==true&&dc[i]==false) { ciclu[0]=1; ciclu[1]=i; for(int j=0;j<n;++j) if(e[j]&&p[i][j]==2) { ciclu[++ciclu[0]]=j; ca[j]=true; } if(ciclu[0]>2) { for(int ii=1;ii<ciclu[0];++ii) { dc[ciclu[ii]]=true; answer[ciclu[ii]][ciclu[ii+1]]=answer[ciclu[ii+1]][ciclu[ii]]=1; for(int q=0;q<n;++q) { if(q!=ciclu[ii]) if(ca[q]==false&&p[ciclu[i]][q]==2||ca[q]==true&&p[ciclu[i]][q]!=2) return 0; } } answer[ciclu[ciclu[0]]][ciclu[1]]=answer[ciclu[1]][ciclu[ciclu[0]]]=1; } else if(ciclu[0]==2) return 0; } } build(answer); return 1; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 2 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1168 KB | Output is correct |
7 | Correct | 173 ms | 22132 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 2 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1168 KB | Output is correct |
7 | Correct | 173 ms | 22132 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 | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 10 ms | 1168 KB | Output is correct |
13 | Correct | 197 ms | 22076 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 | 724 KB | Output is correct |
17 | Correct | 79 ms | 12108 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 45 ms | 5740 KB | Output is correct |
21 | Correct | 175 ms | 21964 KB | Output is correct |
22 | Correct | 199 ms | 21964 KB | Output is correct |
23 | Correct | 183 ms | 22024 KB | Output is correct |
24 | Correct | 196 ms | 21988 KB | Output is correct |
25 | Correct | 88 ms | 12036 KB | Output is correct |
26 | Correct | 71 ms | 12108 KB | Output is correct |
27 | Correct | 184 ms | 22024 KB | Output is correct |
28 | Correct | 189 ms | 22036 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 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 | 1 ms | 212 KB | Output is correct |
5 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 2 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1168 KB | Output is correct |
7 | Correct | 173 ms | 22132 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 | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 10 ms | 1168 KB | Output is correct |
13 | Correct | 197 ms | 22076 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 | 724 KB | Output is correct |
17 | Correct | 79 ms | 12108 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 45 ms | 5740 KB | Output is correct |
21 | Correct | 175 ms | 21964 KB | Output is correct |
22 | Correct | 199 ms | 21964 KB | Output is correct |
23 | Correct | 183 ms | 22024 KB | Output is correct |
24 | Correct | 196 ms | 21988 KB | Output is correct |
25 | Correct | 88 ms | 12036 KB | Output is correct |
26 | Correct | 71 ms | 12108 KB | Output is correct |
27 | Correct | 184 ms | 22024 KB | Output is correct |
28 | Correct | 189 ms | 22036 KB | Output is correct |
29 | Correct | 0 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 | 1 ms | 212 KB | Output is correct |
33 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
34 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 2 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 7 ms | 1168 KB | Output is correct |
7 | Correct | 173 ms | 22132 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 | 212 KB | Output is correct |
11 | Correct | 0 ms | 212 KB | Output is correct |
12 | Correct | 10 ms | 1168 KB | Output is correct |
13 | Correct | 197 ms | 22076 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 | 724 KB | Output is correct |
17 | Correct | 79 ms | 12108 KB | Output is correct |
18 | Correct | 0 ms | 212 KB | Output is correct |
19 | Correct | 0 ms | 212 KB | Output is correct |
20 | Correct | 45 ms | 5740 KB | Output is correct |
21 | Correct | 175 ms | 21964 KB | Output is correct |
22 | Correct | 199 ms | 21964 KB | Output is correct |
23 | Correct | 183 ms | 22024 KB | Output is correct |
24 | Correct | 196 ms | 21988 KB | Output is correct |
25 | Correct | 88 ms | 12036 KB | Output is correct |
26 | Correct | 71 ms | 12108 KB | Output is correct |
27 | Correct | 184 ms | 22024 KB | Output is correct |
28 | Correct | 189 ms | 22036 KB | Output is correct |
29 | Correct | 0 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 | 1 ms | 212 KB | Output is correct |
33 | Runtime error | 1 ms | 340 KB | Execution killed with signal 11 |
34 | Halted | 0 ms | 0 KB | - |