Submission #835352

# Submission time Handle Problem Language Result Execution time Memory
835352 2023-08-23T13:38:05 Z mousebeaver Werewolf (IOI18_werewolf) C++14
0 / 100
4000 ms 36008 KB
#include "werewolf.h"
#include <bits/stdc++.h>
using namespace std;

void dfs(int l, int r, vector<vector<int>>& adjlist, int i, vector<bool>& visited)
{
    visited[i] = true;
    for(int j : adjlist[i])
    {
        if(!visited[j] && l <= j && j <= r)
        {
            dfs(l, r, adjlist, j, visited);
        }
    }
}

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 n = N;
    vector<vector<int>> adjlist(n, vector<int> (0));
    for(int i = 0; i < n; i++)
    {
        int a = X[i];
        int b = Y[i];
        adjlist[a].push_back(b);
        adjlist[b].push_back(a);
    }

    vector<int> output(S.size());
    for(int t = 0; t < (int) S.size(); t++)
    {
        int l = L[t];
        int r = R[t];
        int s = S[t];
        int e = E[t];

        vector<bool> visited(n, false);
        dfs(l, n-1, adjlist, s, visited);
        for(int i = 0; i < n; i++)
        {
            if(visited[i] && l <= i && i <= r)
            {
                dfs(0, r, adjlist, i, visited);
            }
        }
        output[t] = visited[e];
    }
    return output;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4014 ms 36008 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -