# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
864744 | 2023-10-23T14:10:25 Z | andrei_boaca | 슈퍼트리 잇기 (IOI20_supertrees) | C++17 | 159 ms | 30288 KB |
#include "supertrees.h" #include <vector> #include <bits/stdc++.h> //#include "grader.cpp" using namespace std; int n; vector<vector<int>> adj; vector<int> muchii[1005]; int comp[1005],nrcomp; vector<int> nodes; void dfs(int nod) { comp[nod]=nrcomp; nodes.push_back(nod); for(int i:muchii[nod]) if(!comp[i]) dfs(i); } int construct(std::vector<std::vector<int>> p) { n=p.size(); adj.resize(n); for(int i=0;i<n;i++) adj[i].resize(n); bool sub1=1; bool sub2=1; for(int i=0;i<n;i++) for(int j=0;j<n;j++) { sub1&=(p[i][j]<=1); sub2&=(p[i][j]==0||p[i][j]==2||i==j); } if(sub1||sub2) { for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(p[i][j]==1) { muchii[i].push_back(j); muchii[j].push_back(i); } for(int i=0;i<n;i++) if(comp[i]==0) { nrcomp++; nodes.clear(); dfs(i); for(int j=1;j<nodes.size();j++) { int a=nodes[j-1]; int b=nodes[j]; adj[a][b]=adj[b][a]=1; } if(sub2) { int a=nodes[0]; int b=nodes.back(); if(a!=b) { adj[a][b]=1; adj[b][a]=1; } } } for(int i=0;i<n;i++) for(int j=0;j<n;j++) { if(p[i][j]==0&&comp[i]==comp[j]) return 0; if(p[i][j]>0&&comp[i]!=comp[j]) return 0; } build(adj); return 1; } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 7 ms | 1624 KB | Output is correct |
7 | Correct | 154 ms | 30288 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 7 ms | 1624 KB | Output is correct |
7 | Correct | 154 ms | 30288 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 6 ms | 1116 KB | Output is correct |
13 | Correct | 143 ms | 22116 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 | 71 ms | 17956 KB | Output is correct |
18 | Correct | 1 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 37 ms | 5972 KB | Output is correct |
21 | Correct | 149 ms | 23300 KB | Output is correct |
22 | Correct | 150 ms | 22048 KB | Output is correct |
23 | Correct | 159 ms | 26572 KB | Output is correct |
24 | Correct | 146 ms | 22100 KB | Output is correct |
25 | Correct | 60 ms | 13392 KB | Output is correct |
26 | Correct | 59 ms | 12112 KB | Output is correct |
27 | Correct | 159 ms | 28244 KB | Output is correct |
28 | Correct | 148 ms | 22100 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 0 ms | 348 KB | Output is correct |
5 | Incorrect | 0 ms | 348 KB | Answer gives possible 0 while actual possible 1 |
6 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 348 KB | Output is correct |
2 | Incorrect | 0 ms | 348 KB | Answer gives possible 0 while actual possible 1 |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 7 ms | 1624 KB | Output is correct |
7 | Correct | 154 ms | 30288 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 6 ms | 1116 KB | Output is correct |
13 | Correct | 143 ms | 22116 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 | 71 ms | 17956 KB | Output is correct |
18 | Correct | 1 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 37 ms | 5972 KB | Output is correct |
21 | Correct | 149 ms | 23300 KB | Output is correct |
22 | Correct | 150 ms | 22048 KB | Output is correct |
23 | Correct | 159 ms | 26572 KB | Output is correct |
24 | Correct | 146 ms | 22100 KB | Output is correct |
25 | Correct | 60 ms | 13392 KB | Output is correct |
26 | Correct | 59 ms | 12112 KB | Output is correct |
27 | Correct | 159 ms | 28244 KB | Output is correct |
28 | Correct | 148 ms | 22100 KB | Output is correct |
29 | Correct | 1 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 348 KB | Output is correct |
32 | Correct | 0 ms | 348 KB | Output is correct |
33 | Incorrect | 0 ms | 348 KB | Answer gives possible 0 while actual possible 1 |
34 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 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 | 7 ms | 1624 KB | Output is correct |
7 | Correct | 154 ms | 30288 KB | Output is correct |
8 | Correct | 0 ms | 348 KB | Output is correct |
9 | Correct | 0 ms | 348 KB | Output is correct |
10 | Correct | 0 ms | 348 KB | Output is correct |
11 | Correct | 0 ms | 348 KB | Output is correct |
12 | Correct | 6 ms | 1116 KB | Output is correct |
13 | Correct | 143 ms | 22116 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 | 71 ms | 17956 KB | Output is correct |
18 | Correct | 1 ms | 344 KB | Output is correct |
19 | Correct | 0 ms | 348 KB | Output is correct |
20 | Correct | 37 ms | 5972 KB | Output is correct |
21 | Correct | 149 ms | 23300 KB | Output is correct |
22 | Correct | 150 ms | 22048 KB | Output is correct |
23 | Correct | 159 ms | 26572 KB | Output is correct |
24 | Correct | 146 ms | 22100 KB | Output is correct |
25 | Correct | 60 ms | 13392 KB | Output is correct |
26 | Correct | 59 ms | 12112 KB | Output is correct |
27 | Correct | 159 ms | 28244 KB | Output is correct |
28 | Correct | 148 ms | 22100 KB | Output is correct |
29 | Correct | 1 ms | 348 KB | Output is correct |
30 | Correct | 0 ms | 348 KB | Output is correct |
31 | Correct | 0 ms | 348 KB | Output is correct |
32 | Correct | 0 ms | 348 KB | Output is correct |
33 | Incorrect | 0 ms | 348 KB | Answer gives possible 0 while actual possible 1 |
34 | Halted | 0 ms | 0 KB | - |