Submission #1066965

# Submission time Handle Problem Language Result Execution time Memory
1066965 2024-08-20T09:06:11 Z Muhammad_Aneeq Werewolf (IOI18_werewolf) C++17
0 / 100
4000 ms 39148 KB
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include "bits/stdc++.h"
using namespace std;
int const N=2e5+10;
vector<int>nei[N]={};
bool reach[N]={};
int l,r;
void dfs(int u,int form=0)
{
    reach[u]=1;
    for (auto i:nei[u])
    {
        if (reach[i])
            continue;
        if (i>r&&form==1)
            continue;
        if (u<l&&i>r)
            continue;
        if (u>r&&i<l)
            continue;
        if (i<l)
            dfs(i,1);
        else
            dfs(i,form);
    }
}
vector<int> check_validity(int N, vector<int> X, vector<int> Y,vector<int> S, vector<int> E,vector<int> L, vector<int> R)
{
    for (int i=0;i<X.size();i++)
    {
        nei[X[i]].push_back(Y[i]);
        nei[Y[i]].push_back(X[i]);
    }
    vector<int>ans;
    for (int i=0;i<S.size();i++)
    {
        l=L[i],r=R[i];
        dfs(S[i]);
        ans.push_back(reach[E[i]]);
        for (int j=0;j<N;j++)
            reach[j]=0;
    }
    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:32:19: 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<X.size();i++)
      |                  ~^~~~~~~~~
werewolf.cpp:38:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (int i=0;i<S.size();i++)
      |                  ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 3 ms 5136 KB Output is correct
3 Correct 3 ms 4952 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Incorrect 2 ms 4956 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 3 ms 5136 KB Output is correct
3 Correct 3 ms 4952 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Incorrect 2 ms 4956 KB Output isn't correct
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4062 ms 39148 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 3 ms 5136 KB Output is correct
3 Correct 3 ms 4952 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Incorrect 2 ms 4956 KB Output isn't correct
6 Halted 0 ms 0 KB -