이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3e3 + 100;
int n;
int pref[maxn][maxn];
int suf[maxn][maxn];
vector<int> g[maxn];
int get(int v, int p[]){
if(p[v] == v) return v;
return p[v] = get(p[v], p);
}
void join(int a, int b, int p[]){
p[get(a, p)] = get(b, p);
}
void add(vector<int> &v){
for(int &x: v) x++;
}
vector<int> check_validity(int N, std::vector<int> X, std::vector<int> Y,
std::vector<int> S, std::vector<int> E,
std::vector<int> L, std::vector<int> R){
add(X); add(Y); add(S); add(E); add(L); add(R);
for(int i = 0; i < X.size(); i++){
g[X[i]].push_back(Y[i]);
g[Y[i]].push_back(X[i]);
}
n = N;
for(int i = 1; i <= n; i++){
pref[0][i] = suf[n+1][i] = i;
}
for(int i = 1; i <= n; i++){
for(int j = 1; j <= n; j++){
pref[i][j] = pref[i-1][j];
}
for(int to: g[i]){
if(to < i) join(to, i, pref[i]);
}
}
for(int i = n; i > 0; i--){
for(int j = 1; j <= n; j++){
suf[i][j] = suf[i+1][j];
}
for(int to: g[i]){
if(to > i) join(to, i, suf[i]);
}
}
vector<int> ans;
for(int i = 0; i < S.size(); i++){
int s = S[i], e = E[i];
int l = L[i], r = R[i];
int res = 0;
for(int k = l; k <= r; k++){
if(get(s, suf[l]) == get(k, suf[l]) && get(k, pref[r]) == get(e, pref[r])){
res = 1;
}
}
ans.push_back(res);
}
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:28:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | for(int i = 0; i < X.size(); i++){
| ~~^~~~~~~~~~
werewolf.cpp:53:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for(int i = 0; i < S.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... |