# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1024203 | ksu2009en | Werewolf (IOI18_werewolf) | C++17 | 4040 ms | 26484 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 < x.size(); i++){
d[x[i]].push_back(y[i]);
d[y[i]].push_back(x[i]);
}
vector<int> ans;
for(int i = 0; i < q; i++){
lim = l[i];
dfs1(s[i]);
lim = r[i];
dfs2(e[i]);
int res = 0;
for(int j = 0; j < n; j++){
if(used1[j] && used2[j]){
res = 1;
}
used1[j] = used2[j] = 0;
}
ans.push_back(res);
}
return ans;
}
/*
6 6 3
0 3
3 1
3 4
1 2
2 5
1 5
4 2 1 2
4 2 2 2
5 4 3 4
*/
/*
6 6 1
0 3
3 1
3 4
1 2
2 5
1 5
4 2 1 2
4 2 2 2
5 4 3 4
*/
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... |