# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
746073 | 2023-05-21T11:12:31 Z | JakobZorz | 슈퍼트리 잇기 (IOI20_supertrees) | C++14 | 205 ms | 27916 KB |
#include "supertrees.h" #include <vector> using namespace std; vector<vector<int>> answer; int group_ids[1000]; vector<int> groups[1000]; vector<vector<int>> p; int num_groups; void connect(int a, int b){ answer[a][b]=1; answer[b][a]=1; } void connect_group(int group_id){ vector<int> group=groups[group_id]; vector<bool> in_cycle(group.size(),false); int present2=-1; for(int i=0;i<group.size();i++){ for(int j=0;j<group.size();j++){ if(p[group[i]][group[j]]==2){ present2=j; } } } if(present2==-1){ for(int i=0;i<group.size()-1;i++){ connect(group[i],group[i+1]); } return; } vector<int> cycle; in_cycle[present2]=true; for(int i=0;i<group.size();i++){ bool valid=true; for(int j=0;j<cycle.size();j++){ if(p[group[cycle[j]]][group[i]]!=2){ valid=false; break; } } if(valid){ cycle.push_back(i); in_cycle[i]=true; } } for(int i=0;i<cycle.size()-1;i++) connect(group[cycle[i]],group[cycle[i+1]]); connect(group[cycle[0]],group[cycle.back()]); for(int i=0;i<group.size();i++){ if(in_cycle[i]) continue; for(int j=0;j<group.size();j++){ if(p[group[i]][group[j]]==1&&in_cycle[group[j]]){ connect(group[i],group[j]); } } } } int construct(vector<vector<int>> p_) { p=p_; int n = p.size(); answer=vector<vector<int>>(n,vector<int>(n,0)); for(vector<int>& i:p) for(int j:i) if(j==3) return 0; for(int i=0;i<n;i++) group_ids[i]=-1; for(int i=0;i<n;i++){ if(group_ids[i]!=-1) continue; group_ids[i]=num_groups; groups[num_groups].push_back(i); for(int j=i+1;j<n;j++){ if(p[i][j]!=0){ group_ids[j]=num_groups; groups[num_groups].push_back(j); } } num_groups++; } for(int i=0;i<num_groups;i++) connect_group(i); build(answer); return 1; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 312 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 8 ms | 1352 KB | Output is correct |
7 | Correct | 184 ms | 27916 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 312 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 8 ms | 1352 KB | Output is correct |
7 | Correct | 184 ms | 27916 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 312 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 9 ms | 1364 KB | Output is correct |
13 | Correct | 187 ms | 27880 KB | Output is correct |
14 | Incorrect | 1 ms | 212 KB | Answer gives possible 1 while actual possible 0 |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 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 | Incorrect | 1 ms | 312 KB | Answer gives possible 1 while actual possible 0 |
5 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 320 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 49 ms | 7300 KB | Output is correct |
5 | Correct | 196 ms | 27676 KB | Output is correct |
6 | Correct | 195 ms | 27648 KB | Output is correct |
7 | Correct | 205 ms | 27660 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 51 ms | 7264 KB | Output is correct |
10 | Correct | 191 ms | 27576 KB | Output is correct |
11 | Correct | 203 ms | 27664 KB | Output is correct |
12 | Correct | 194 ms | 27584 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 0 ms | 212 KB | Output is correct |
15 | Incorrect | 1 ms | 212 KB | Too few ways to get from 0 to 4, should be 1 found 0 |
16 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 312 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 8 ms | 1352 KB | Output is correct |
7 | Correct | 184 ms | 27916 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 312 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 9 ms | 1364 KB | Output is correct |
13 | Correct | 187 ms | 27880 KB | Output is correct |
14 | Incorrect | 1 ms | 212 KB | Answer gives possible 1 while actual possible 0 |
15 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 312 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 8 ms | 1352 KB | Output is correct |
7 | Correct | 184 ms | 27916 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 312 KB | Output is correct |
10 | Correct | 0 ms | 212 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 9 ms | 1364 KB | Output is correct |
13 | Correct | 187 ms | 27880 KB | Output is correct |
14 | Incorrect | 1 ms | 212 KB | Answer gives possible 1 while actual possible 0 |
15 | Halted | 0 ms | 0 KB | - |