이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "werewolf.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> child[400005], adj1[200005], adj2[200005], ql[200005], qr[200005], ans;
int p[200005], par[400005], tin[400005], tout[400005], t;
set<int> ss[400005];
int parent(int u)
{
return (par[u]==u)?u:(par[u]=parent(par[u]));
}
void f(int u)
{
tin[u]=(t++);
for (int v:child[u])
f(v);
tout[u]=(t++);
}
vector<int> check_validity(int n, vector<int> x, vector<int> y, vector<int> s, vector<int> e, vector<int> l, vector<int> r)
{
for (int i=0; i<x.size(); i++)
{
int u=min(x[i], y[i]), v=max(x[i], y[i]);
adj1[u].push_back(v);
adj2[v].push_back(u);
}
for (int i=0; i<l.size(); i++)
{
ql[l[i]].push_back(i);
qr[r[i]].push_back(i);
ans.push_back(0);
}
for (int i=0; i<=n*2; i++)
par[i]=i;
int cnt=n;
for (int i=n-1; i>=0; i--)
{
for (int j:adj1[i])
{
int a=parent(i), b=parent(j);
if (a!=b)
{
child[cnt].push_back(a);
child[cnt].push_back(b);
par[a]=par[b]=(cnt++);
}
}
for (int j:ql[i])
p[j]=parent(s[j]);
}
f(cnt-1);
for (int i=0; i<n; i++)
ss[i].insert(tin[i]);
for (int i=0; i<=n*2; i++)
par[i]=i;
cnt=n;
for (int i=0; i<n; i++)
{
for (int j:adj2[i])
{
int a=parent(i), b=parent(j);
if (a!=b)
{
ss[cnt].insert(ss[a].begin(), ss[a].end());
ss[cnt].insert(ss[b].begin(), ss[b].end());
par[a]=par[b]=(cnt++);
}
}
for (int j:qr[i])
{
int x=parent(e[j]);
auto itr=ss[x].lower_bound(tin[p[j]]);
if (itr!=ss[x].end() && (*itr)<=tout[p[j]])
ans[j]=1;
}
}
return ans;
}
컴파일 시 표준 에러 (stderr) 메시지
werewolf.cpp: In function 'std::vector<int> check_validity(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
werewolf.cpp:20:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | for (int i=0; i<x.size(); i++)
| ~^~~~~~~~~
werewolf.cpp:26:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
26 | for (int i=0; i<l.size(); i++)
| ~^~~~~~~~~
# | 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... |