Submission #416386

# Submission time Handle Problem Language Result Execution time Memory
416386 2021-06-02T10:54:44 Z AmineTrabelsi Werewolf (IOI18_werewolf) C++14
0 / 100
4000 ms 28460 KB
#include "werewolf.h"
#include <bits/stdc++.h>
using namespace std;
const int Nx = 200000;
vector<int> gr[Nx+5];
/*
struct node{
    int x;
    bool form; // 0 human 1 werewolf
    node(){}
    node(int _x,bool _form){
        x = _x;
        form = _form;
    }
};*/
int e,l,r;
bool vis[Nx+5][3];
bool dfs(int node,bool form){
    cerr<< node <<" "<< form << '\n';
    if(node == e && form){
        return 1;
    }
    if(form && node > r)return 0;
    if(!form && node < l)return 0;
    vis[node][form] = 1;
    bool ans = 0;
    for(auto u:gr[node]){
        if(form && u <= r && !vis[u][1]){
            ans = ans || dfs(u,1);
        }else if(!form){
            if(u >= l && !vis[u][0])ans = ans || dfs(u,0);
            if(ans)return 1;
            if(node >= l && node <= r && u <= r && !vis[u][1])ans = ans || dfs(u,1);
        }
        if(ans)return 1;
    }
    return ans;
}
vector<int> check_validity(int N, vector<int> X, vector<int> Y,vector<int> S, vector<int> E,vector<int> L, vector<int> R) {
    int Q = S.size();
    int M = X.size();
    vector<int> ans(Q,0);
    for(int i=0;i<M;i++){
        gr[X[i]].push_back(Y[i]);
        gr[Y[i]].push_back(X[i]);
    }
    for(int i=0;i<Q;i++){
        memset(vis,0,sizeof vis);
        e = E[i], l = L[i], r = R[i];
        ans[i] = dfs(S[i],0);
    }
    return ans;
}
/*
4 3 1 2
h h h |w
0 1 2 3 4 5
H H | W W W
4 3 1 5 2
 
*/
# Verdict Execution time Memory Grader output
1 Correct 32 ms 5604 KB Output is correct
2 Incorrect 39 ms 5596 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 5604 KB Output is correct
2 Incorrect 39 ms 5596 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4041 ms 28460 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 5604 KB Output is correct
2 Incorrect 39 ms 5596 KB Output isn't correct
3 Halted 0 ms 0 KB -