Submission #766035

# Submission time Handle Problem Language Result Execution time Memory
766035 2023-06-25T09:13:01 Z tengiz05 Werewolf (IOI18_werewolf) C++17
15 / 100
4000 ms 24524 KB
#include "werewolf.h"
#include "iostream"
#include "array"
#include "queue"
#ifndef EVAL
#include "grader.cpp"
#endif
using namespace std;

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 m = X.size();
    vector<vector<int>> e(n);
    for (int i = 0; i < m; i++) {
        e[X[i]].push_back(Y[i]);
        e[Y[i]].push_back(X[i]);
    }
    int Q = S.size();
    vector<int> ans(Q);
    for (int i = 0; i < Q; i++) {
        vector<array<int, 2>> dp(n);
        queue<array<int, 2>> q;
        q.push({S[i], 0});
        dp[S[i]][0] = 1;
        while (!q.empty()) {
            auto [u, p] = q.front();
            q.pop();
            if (L[i] <= u && u <= R[i] && p == 0 && !dp[u][1]) {
                dp[u][1] = 1;
                q.push({u, 1});
            }
            for (int v : e[u]) {
                if (!dp[v][p] && ((p == 0 && v >= L[i]) || (p == 1 && v <= R[i]))) {
                    dp[v][p] = 1;
                    q.push({v, p});
                }
            }
        }
        ans[i] = dp[E[i]][1];
    }
    return ans;
}

/*


6 6 3
5 1
1 2
1 3
3 4
3 0
5 2
4 2 1 2
4 2 2 2
5 4 3 4



*/
# Verdict Execution time Memory 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 1 ms 292 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 300 KB Output is correct
# Verdict Execution time Memory 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 1 ms 292 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 300 KB Output is correct
10 Correct 309 ms 748 KB Output is correct
11 Correct 202 ms 748 KB Output is correct
12 Correct 17 ms 736 KB Output is correct
13 Correct 258 ms 748 KB Output is correct
14 Correct 175 ms 744 KB Output is correct
15 Correct 206 ms 852 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4034 ms 24524 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory 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 1 ms 292 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 300 KB Output is correct
10 Correct 309 ms 748 KB Output is correct
11 Correct 202 ms 748 KB Output is correct
12 Correct 17 ms 736 KB Output is correct
13 Correct 258 ms 748 KB Output is correct
14 Correct 175 ms 744 KB Output is correct
15 Correct 206 ms 852 KB Output is correct
16 Execution timed out 4034 ms 24524 KB Time limit exceeded
17 Halted 0 ms 0 KB -