# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1024200 | ksu2009en | Werewolf (IOI18_werewolf) | C++17 | 4062 ms | 35668 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "werewolf.h"
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <bitset>
#include <cstring>
#include <unordered_map>
using namespace std;
typedef int ll;
vector<ll> d[200007];
bool used1[200007], used2[200007];
ll lim = 0;
void dfs1(ll v){
if(v < lim)
return;
used1[v] = true;
for(auto i: d[v]){
if(!used1[i] && i >= lim)
dfs1(i);
}
}
void dfs2(ll v){
if(v > lim)
return;
used2[v] = true;
for(auto i: d[v]){
if(!used2[i] && i <= lim)
dfs2(i);
}
}
std::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) {
ll q = l.size();
for(int i = 0; i < q; i++)
s[i]++, e[i]++;
for(int i = 0; i < x.size(); i++){
d[x[i]].push_back(y[i]);
d[y[i]].push_back(x[i]);
}
vector<int> ans(q);
for(int i = 0; i < q; i++){
ll lim = l[i];
dfs1(s[i]);
lim = r[i];
dfs2(e[i]);
int res = 0;
for(int j = 1; j <= n; j++){
if(used1[j] && used2[j]){
res = 1;
}
used1[j] = used2[j] = 0;
}
ans.push_back(res);
}
return ans;
}
Compilation message (stderr)
# | 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... |