이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "werewolf.h"
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define OVL(v,s) for(auto x:v) cout<<x<<s;cout<<endl;
#define ll long long
#define pb push_back
const int MAXN=3500;
vector<int> c(MAXN,0);
vector<vector<int>> v(MAXN);
void dfs(int node,int ab,vector<bool>& visited){
visited[node]=true;
for(auto x:v[node]){
if(visited[x]) continue;
if(ab==1&&c[x]<=1){
//He is human
dfs(x,ab,visited);
}else if(ab==2&&c[x]>=1){
//he is a werewolf
dfs(x,ab,visited);
}
}
}
vector<int> check_validity(int n, vector<int> a, vector<int> b,
vector<int> ql, vector<int> qr,
vector<int> l, vector<int> r) {
int q = ql.size();
for(int i=0;i<a.size();i++){
v[a[i]].pb(b[i]);
v[b[i]].pb(a[i]);
}
vector<int> ans(q,0);
for(int j=0;j<q;j++){
for(int i=0;i<n;i++){
if(i<l[j]) {
c[i]=2;//You should be a werewolf
}else if(i<=r[j]) c[i]=1;//you can transform here
else c[i]=0;//You should be a human here
}
vector<bool> visited1(MAXN,false);
vector<bool> visited2(MAXN,false);
dfs(ql[j],1,visited1);
dfs(qr[j],2,visited2);
for(int i=l[j];i<=r[j];i++){
if(visited1[i]&&visited2[i]) {
ans[j]=1;break;
}
}
}
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:15: 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<a.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... |