| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 321167 | blue | 카니발 티켓 (IOI20_tickets) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "supertrees.h"
#include <vector>
#include <set>
using namespace std;
int construct(vector< vector<int> > p)
{
int n = p.size();
vector< vector<int> > b(n);
for(int i = 0; i < n; i++) b[i] = vector<int>(n, 0);
vector<int> group(n, -1);
set<int> grouplist;
for(int i = 0; i < n; i++)
{
group[i] = i;
grouplist.clear();
for(int j = 0; j < i; j++) if(p[i][j]) grouplist.insert(group[j]);
for(int j = 0; j < i; j++) if(grouplist.find(group[j]) != grouplist.end()) group[j] = i;
}
for(int i = 0; i < n; i++)
{
for(int j = 0; j < n; j++)
{
if(group[i] == group[j] && p[i][j] == 0) return 0;
if(group[i] != group[j] && p[i][j] == 2) return 0;
}
}
vector<int> group_set[n];
for(int i = 0; i < n; i++) group_set[group[i]].push_back(i);
for(int i = 0; i < n; i++) if(group_set[i].size() >) group_set[i].push_back(group_set[i][0]);
for(int i = 0; i < n; i++)
{
for(int j = 0; j < group_set[i].size()-1; j++)
{
b[group_set[i][j]][group_set[i][j+1]] = 1;
b[group_set[i][j+1]][group_set[i][j]] = 1;
}
}
build(b);
return 1;
}
