# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
434476 | Maqsut_03 | Werewolf (IOI18_werewolf) | C++14 | 644 ms | 524292 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<bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 222222;
vector<string> vec;
vector<ll> v[N];
char a[N];
bool used[N];
bool ans;
void dfs(int i, int j, int k, string s)
{
used[i] = 1;
if (i == k)
{
vec.push_back(s);
used[i] = 0;
return ;
}
for (auto l:v[i])
{
if (!used[l])
{
dfs(l, i, k, s + a[l]);
}
}
used[i] = 0;
}
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) {
int q = S.size();
std::vector<int> A(q, 0);
for (int i=0; i<N; i++)
{
v[X[i]].push_back(Y[i]);
v[Y[i]].push_back(X[i]);
}
for (int i=0; i<q; i++)
{
ans = false;
vec.clear();
for (int j=0; j<L[i]; j++) a[j] = 'B';
for (int j=L[i]; j<=R[i]; j++) a[j] = 'T';
for (int j=R[i]+1; j<N; j++) a[j] = 'O';
string WW = "";
WW += a[S[i]];
dfs(S[i], -1, E[i], WW);
for (string l:vec)
{
int q = 0;
for (int j=1; j<l.size(); j++)
if (l[j-1] == 'O' && l[j] == 'T') q++;
if (l.find("BO") == -1 && l.find("OB") == -1 && q < 2)
{
ans = 1;
break;
}
}
if (ans) A[i] = 1;
else A[i] = 0;
}
return A;
}
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... |