Submission #500161

# Submission time Handle Problem Language Result Execution time Memory
500161 2021-12-30T12:01:11 Z aymanrs Werewolf (IOI18_werewolf) C++14
0 / 100
4000 ms 43524 KB
#include <bits/stdc++.h>
#include "werewolf.h"
using namespace std;
struct node {
    int id;
    list<node*> l;
    bool v;
};
vector<node> g;
void wolf(node*n, int r, bool w[]){
    w[n->id] = true;
    for(node* c : n->l){
        if(!w[c->id] && c->id <= r) wolf(c, r, w);
    }
}
bool human(node* n, int l, bool w[], int r){
    n->v = true;
    for(node* c : n->l){
        if(w[c->id] && (c->id >= l || n->id <= r)) return true;
        if(!c->v && c->id >= l && human(c, l, w, r)) return true;
    }
    return false;
}
vector<int> check_validity(int N, vector<int> X, vector<int> Y, vector<int> S, vector<int> E, vector<int> L, vector<int> R){
    g.resize(N);
    for(int i = 0;i < N;i++) g[i].id=i;
    for(int i = 0;i < X.size();i++){
        g[X[i]].l.push_back(&g[Y[i]]);
        g[Y[i]].l.push_back(&g[X[i]]);
    }
    vector<int> ans(S.size(), 0);
    for(int i = 0;i < S.size();i++){
        for(int j = 0;j < N;j++) g[i].v = false;
        bool w[N] = {false};
        wolf(&g[E[i]], R[i], w);
        if(human(&g[S[i]], L[i], w, R[i])) ans[i] = 1;
    }
    return ans;
}

Compilation message

werewolf.cpp: In function 'std::vector<int> check_validity(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
werewolf.cpp:27:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i = 0;i < X.size();i++){
      |                   ~~^~~~~~~~~~
werewolf.cpp:32:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   32 |     for(int i = 0;i < S.size();i++){
      |                   ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4035 ms 43524 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -