이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include "supertrees.h"
using namespace std;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef long long ll;
#define f first
#define s second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize
const int md = 1e9+7;
const ll inf = 1e18;
const int maxn = 1e3+5;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
int par[maxn];
void init(int *p, int n)
{
for(int i = 0; i< n; i++) p[i] = i;
}
int findset(int *p, int x)
{
if(p[x] == x) return x;
return p[x] = findset(p, p[x]);
}
void unionset(int *p, int x, int y)
{
int a = findset(p, x);
int b = findset(p, y);
if(a == b) return;
p[a] = b;
}
int construct(std::vector<std::vector<int>> p)
{
int n = p.size();
init(par, n);
bool good = true;
for(int i = 0; i< n; i++)
{
for(int j = i+1; j< n; j++)
{
if(p[i][j] == 1)
{
unionset(par, i, j);
}
else
{
if(findset(par, i) == findset(par, j))
{
good = false;
return 0;
}
}
}
}
vector< vector<int> > res(n, vector<int>(n, 0));
for(int i = 0; i< n; i++)
{
for(int j = i+1; j< n; j++)
{
res[i][j] = res[j][i] = (findset(par, i) == j);
}
}
build(res);
return 1;
}
컴파일 시 표준 에러 (stderr) 메시지
supertrees.cpp: In function 'int construct(std::vector<std::vector<int> >)':
supertrees.cpp:56:7: warning: variable 'good' set but not used [-Wunused-but-set-variable]
56 | bool good = true;
| ^~~~
# | 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... |