이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "supertrees.h"
#include <bits/stdc++.h>
using namespace std;
using ll = int;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
#define F first
#define S second
class UnionFind {
private:
ll n;
vi p,sz;
public:
UnionFind(ll n): n(n),p(n),sz(n,1){
for (ll i = 0; n > i; i++) p[i] = i;
}
ll root(ll x){
if (x != p[x]) p[x] = root(p[x]);
return p[x];
}
void unify (ll x, ll y){
x = root(x), y = root(y);
if(x == y) return;
if (sz[x] < sz[y]) swap(x,y);
p[y] = x; sz[x] += sz[y];
}
};
void build(vvi b);
int construct(vvi p) {
int n = p.size();
vvi ans(n,vi(n,0));
vi hasSet(n,0);
for (int i = 0; n > i; i++){
if (hasSet[i]){
for (ll j = 0; n > j; j++){
if (j == i) continue;
if (p[i][j]) return 0;
}
continue;
}
vi cur_set;
for (ll j = 0; n > j; j++){
if (p[i][j] != 0){
cur_set.push_back(j);
if (hasSet[j]) return 0;
else hasSet[j] = 1;
}
}
for (auto j: cur_set){
for (auto k: cur_set){
if (j == k) continue;
if (p[j][k] == 0) return 0;
else p[j][k] = 0;
}
}
//if (cur_set.size() == 1) continue;
//if (cur_set.size() == 2) return 0;
for (ll j = 0; cur_set.size() > j; j++){
//ans[i][cur_set[j]] = ans[cur_set[j]][i] = 1;
ans[cur_set[j]][cur_set[(j+1)%n]] = ans[cur_set[(j+1)%n]][cur_set[j]] = 1;
}
}
for (ll i = 0; n > i; i++){
for (ll j = 0; n > j; j++){
if (p[i][j] && i != j) return 0;
}
}
build(ans);
return 1;
}
컴파일 시 표준 에러 (stderr) 메시지
supertrees.cpp: In function 'int construct(vvi)':
supertrees.cpp:65:39: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'int'} [-Wsign-compare]
65 | for (ll j = 0; cur_set.size() > j; j++){
| ~~~~~~~~~~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |