# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
991116 | fv3 | 늑대인간 (IOI18_werewolf) | C++14 | 4090 ms | 22352 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "werewolf.h"
using namespace std;
typedef long long ll;
vector<int> check_validity(int N, vector<int> X, vector<int> Y, vector<int> S, vector<int> E, vector<int> L, vector<int> R)
{
// Construct adjacency list
vector<vector<int>> adj(N);
for (int i = 0; i < X.size(); i++)
{
adj[X[i]].push_back(Y[i]);
adj[Y[i]].push_back(X[i]);
}
vector<int> validity(S.size());
for (int q = 0; q < S.size(); q++)
{
vector<int> visited(N, 0);
queue<int> hq; // Human queue
queue<int> wq; // Werewolf queue
// BFS as human
hq.push(S[q]);
visited[S[q]] = 1;
while (!hq.empty())
{
int s = hq.front();
hq.pop();
for (auto node : adj[s])
{
if (visited[node]) continue;
if (node >= L[q])
{
visited[node] = 1;
hq.push(node);
}
else if (s <= R[q])
{
visited[node] = 1;
wq.push(node);
}
}
}
// BFS as werewolf
while (!wq.empty())
{
int s = wq.front();
wq.pop();
for (auto node : adj[s])
{
if (visited[node] || node > R[q]) continue;
visited[node] = 1;
wq.push(node);
}
}
validity[q] = visited[E[q]];
}
return validity;
}
// X and Y --> describe the graph
// S and E --> start and ending point
// L and R --> As human you cannot be in c_i for 0 <= i <= L
// As werewolf you cannot be in c_i for R <= i <= N - 1
//
// Subtask 1: N = 100, M = 200, Q = 100
// BFS to all cities less than R and push all neighbours greater than to another queue
// BFS from the other queue untill you find the desired city
// O((N+M)*Q) = O(2000000) ez
//
// Subtask 3: All cities are on a line
//
// c_0 is sure to be unsafe for humans
// c_N-1 is sure to be unsafe for werewolfs
/*
6 6 3
5 1
1 2
1 3
3 4
3 0
5 2
4 2 1 2
4 2 2 2
5 4 3 4
*/
컴파일 시 표준 에러 (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... |