Submission #1082273

# Submission time Handle Problem Language Result Execution time Memory
1082273 2024-08-31T03:51:10 Z jer033 Werewolf (IOI18_werewolf) C++17
0 / 100
133 ms 51724 KB
#include "werewolf.h"
#include <bits/stdc++.h>
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 Q = S.size();
    std::vector<int> answers(Q);
    vector<vector<int>> edges(N);
    int M = X.size();
    for (int i=0; i<M; i++)
    {
        int x = X[i];
        int y = Y[i];
        edges[x].push_back(y);
        edges[y].push_back(x);
    }

    for (int i = 0; i < Q; i++) {
        int l = L[i];
        int r = R[i];
        int s = S[i];
        int e = E[i];

        //avoid cities less than l in human form
        vector<bool> human(N, 0);
        queue<int> visitlist;
        human[s] = 1;
        visitlist.push(s);
        while (!visitlist.empty())
        {
            int k = visitlist.front();
            visitlist.pop();
            for (int x: edges[k])
            {
                if ((human[x]==0) and (x>=l))
                {
                    human[x] = 1;
                    visitlist.push(x);
                }
            }
        }

        //avoid cities greater than r in wolf form
        vector<bool> wolf;
        //use the same visitlist;
        wolf[e] = 1;
        visitlist.push(e);
        while (!visitlist.empty())
        {
            int k = visitlist.front();
            visitlist.pop();
            for (int x: edges[k])
            {
                if ((wolf[x]==0) and (x<=r))
                {
                    wolf[x] = 1;
                    visitlist.push(x);
                }
            }
        }

        answers[i] = 0;
        for (int j = 0; j<N; j++)
        {
            if ((human[j]) and (wolf[j]))
                answers[i] = 1;
        }

    }
    return answers;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 133 ms 51724 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -