# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
602362 |
2022-07-23T00:28:29 Z |
jairRS |
Werewolf (IOI18_werewolf) |
C++17 |
|
4000 ms |
28212 KB |
#include "werewolf.h"
#include "bits/stdc++.h"
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
const int INF = 1e9;
vvi adj;
void dfsHuman(int src, vector<bool> &reachable, int L)
{
if (src < L)
return;
reachable[src] = true;
for (int a : adj[src])
{
if (reachable[a])
continue;
dfsHuman(a, reachable, L);
}
}
void dfsWolf(int src, vector<bool> &reachable, int R)
{
if (src > R)
return;
reachable[src] = true;
for (int a : adj[src])
{
if (reachable[a])
continue;
dfsHuman(a, reachable, R);
}
}
vi check_validity(int N, vi X, vi Y, vi S, vi E, vi L, vi R)
{
adj = vvi(N);
for (int i = 0; i < X.size(); i++)
{
adj[X[i]].push_back(Y[i]);
adj[Y[i]].push_back(X[i]);
}
int Q = S.size();
vi ans(Q, false);
for (int i = 0; i < Q; i++)
{
vector<bool> reachableHuman(N, false);
dfsHuman(S[i], reachableHuman, L[i]);
vector<bool> reachableWolf(N, false);
dfsWolf(E[i], reachableWolf, R[i]);
for (int a = L[i]; a <= R[i]; a++)
ans[i] |= (reachableHuman[a] && reachableWolf[a]);
}
return ans;
}
Compilation message
werewolf.cpp: In function 'vi check_validity(int, vi, vi, vi, vi, vi, vi)':
werewolf.cpp:42:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | for (int i = 0; i < X.size(); i++)
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4080 ms |
28212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |