Submission #1018331

# Submission time Handle Problem Language Result Execution time Memory
1018331 2024-07-09T19:04:07 Z vjudge1 Werewolf (IOI18_werewolf) C++17
0 / 100
4000 ms 25728 KB
#include "werewolf.h"
#include<iostream>
#include<vector>
using namespace std;

vector<int>ad[200001],v(200001);

void dfs1(int u,int l){
    if(u<l||v[u])return;
    v[u]=1;
    for(auto h:ad[u])dfs1(h,l);
}

void dfs2(int u,int r){
    if(r<u||v[u]!=1)return;
    v[u]=2;
    for(auto h:ad[u])dfs2(h,r);
}

vector<int>check_validity(int N,vector<int> X,vector<int> Y,
                                vector<int> S,vector<int> E,
                                vector<int> L,vector<int> R) {
    vector<int>A;
    for(int i=0;i<X.size();i++){
        ad[X[i]].push_back(Y[i]);
        ad[Y[i]].push_back(X[i]);
    }
    for(int i=0;i<S.size();i++){
        for(int j=1;j<=N;j++)v[j]=0;
        dfs1(S[i],L[i]);
        for(int j=1;j<=N;j++)
            if(v[j]==1)dfs2(j,R[i]);
        if(v[E[i]]==2)A.push_back(1);
        else A.push_back(0);
    }
    return A;
}

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:24:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |     for(int i=0;i<X.size();i++){
      |                 ~^~~~~~~~~
werewolf.cpp:28:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |     for(int i=0;i<S.size();i++){
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4081 ms 25728 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 5724 KB Output isn't correct
2 Halted 0 ms 0 KB -