Submission #999157

# Submission time Handle Problem Language Result Execution time Memory
999157 2024-06-15T07:28:36 Z Unforgettablepl Werewolf (IOI18_werewolf) C++17
15 / 100
4000 ms 31600 KB
#include <bits/stdc++.h>
using namespace std;

#define all(x) x.begin(),x.end()


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>> adj(n);
    for(int i=0;i<X.size();i++){
        adj[X[i]].emplace_back(Y[i]);
        adj[Y[i]].emplace_back(X[i]);
    }
    vector<int> ans(S.size());
    for(int i=0;i<S.size();i++){
        priority_queue<pair<int,int>> q;
        vector<int> dists(n,-1);
        q.emplace(S[i],S[i]);
        vector<bool> visited(n);
        while(!q.empty()){
            auto [dist,idx]=q.top();q.pop();
            if(visited[idx])continue;
            visited[idx]=true;
            dists[idx] = dist;
            for(int&x:adj[idx])if(!visited[x])q.emplace(min(x,dist),x);
        }
        vector<int> diste(n,n);
        visited = vector<bool>(n);
        q.emplace(-E[i],E[i]);
        while(!q.empty()){
            auto [dist,idx]=q.top();q.pop();dist=-dist;
            if(visited[idx])continue;
            visited[idx]=true;
            diste[idx] = dist;
            for(int&x:adj[idx])if(!visited[x])q.emplace(-max(x,dist),x);
        }
        for(int x=0;x<n;x++)if(dists[x]>=L[i] and diste[x]<=R[i])ans[i]=1;
    }
    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:12:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(int i=0;i<X.size();i++){
      |                 ~^~~~~~~~~
werewolf.cpp:17:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i=0;i<S.size();i++){
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 3 ms 456 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 3 ms 456 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1656 ms 896 KB Output is correct
11 Correct 1328 ms 860 KB Output is correct
12 Correct 511 ms 860 KB Output is correct
13 Correct 1567 ms 860 KB Output is correct
14 Correct 1040 ms 856 KB Output is correct
15 Correct 3103 ms 988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4034 ms 31600 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 3 ms 456 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 344 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1656 ms 896 KB Output is correct
11 Correct 1328 ms 860 KB Output is correct
12 Correct 511 ms 860 KB Output is correct
13 Correct 1567 ms 860 KB Output is correct
14 Correct 1040 ms 856 KB Output is correct
15 Correct 3103 ms 988 KB Output is correct
16 Execution timed out 4034 ms 31600 KB Time limit exceeded
17 Halted 0 ms 0 KB -