답안 #835359

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
835359 2023-08-23T13:44:23 Z mousebeaver 늑대인간 (IOI18_werewolf) C++14
15 / 100
4000 ms 35928 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 < (int) X.size(); 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, numeric_limits<int>::max()/2, 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 216 ms 644 KB Output is correct
11 Correct 142 ms 608 KB Output is correct
12 Correct 17 ms 852 KB Output is correct
13 Correct 225 ms 656 KB Output is correct
14 Correct 167 ms 596 KB Output is correct
15 Correct 159 ms 804 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4006 ms 35928 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 216 ms 644 KB Output is correct
11 Correct 142 ms 608 KB Output is correct
12 Correct 17 ms 852 KB Output is correct
13 Correct 225 ms 656 KB Output is correct
14 Correct 167 ms 596 KB Output is correct
15 Correct 159 ms 804 KB Output is correct
16 Execution timed out 4006 ms 35928 KB Time limit exceeded
17 Halted 0 ms 0 KB -