Submission #81509

# Submission time Handle Problem Language Result Execution time Memory
81509 2018-10-25T07:26:16 Z zubec Werewolf (IOI18_werewolf) C++14
15 / 100
4000 ms 23504 KB
#include "werewolf.h"
#include <bits/stdc++.h>
using namespace std;

const int N = 200100;

vector <int> g[N];

int d[2][N];

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) {
    for (int i = 0; i < N; i++){
        g[i].clear();
    }
    for (int i = 0; i < X.size(); i++){
        g[X[i]].push_back(Y[i]);
        g[Y[i]].push_back(X[i]);
    }
    vector <int> A;
    for (int ii = 0; ii < S.size(); ii++){
        int u = S[ii], v = E[ii];
        int l = L[ii], r = R[ii];
        for (int i = 0; i < N; i++){
            d[0][i] = d[1][i] = 1e9;
        }
        queue <int> q;
        if (u >= l){
            d[0][u] = 0;
            q.push(u);
        }
        while(!q.empty()){
            int v = q.front();
            q.pop();
            for (int i = 0; i < g[v].size(); i++){
                int to = g[v][i];
                if (to >= l && d[0][v] + 1 < d[0][to]){
                    d[0][to] = d[0][v] + 1;
                    q.push(to);
                }
            }
        }
        if (v <= r){
            d[1][v] = 0;
            q.push(v);
        }
        while(!q.empty()){
            int v = q.front();
            q.pop();
            for (int i = 0; i < g[v].size(); i++){
                int to = g[v][i];
                if (to <= r && d[1][v] + 1 < d[1][to]){
                    d[1][to] = d[1][v] + 1;
                    q.push(to);
                }
            }
        }
        int bb = 0;
        for (int i = l; i <= r; i++){
            if (d[0][i] != 1e9 && d[1][i] != 1e9){
                bb = 1;
                break;
            }
        }
        A.push_back(bb);
    }

    return A;

}

/**

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

*/

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:15:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < X.size(); i++){
                     ~~^~~~~~~~~~
werewolf.cpp:20:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int ii = 0; ii < S.size(); ii++){
                      ~~~^~~~~~~~~~
werewolf.cpp:34:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int i = 0; i < g[v].size(); i++){
                             ~~^~~~~~~~~~~~~
werewolf.cpp:49:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for (int i = 0; i < g[v].size(); i++){
                             ~~^~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 7 ms 5112 KB Output is correct
2 Correct 6 ms 5112 KB Output is correct
3 Correct 7 ms 5112 KB Output is correct
4 Correct 5 ms 5164 KB Output is correct
5 Correct 6 ms 5164 KB Output is correct
6 Correct 6 ms 5164 KB Output is correct
7 Correct 7 ms 5164 KB Output is correct
8 Correct 9 ms 5220 KB Output is correct
9 Correct 7 ms 5220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 5112 KB Output is correct
2 Correct 6 ms 5112 KB Output is correct
3 Correct 7 ms 5112 KB Output is correct
4 Correct 5 ms 5164 KB Output is correct
5 Correct 6 ms 5164 KB Output is correct
6 Correct 6 ms 5164 KB Output is correct
7 Correct 7 ms 5164 KB Output is correct
8 Correct 9 ms 5220 KB Output is correct
9 Correct 7 ms 5220 KB Output is correct
10 Correct 312 ms 5660 KB Output is correct
11 Correct 202 ms 5768 KB Output is correct
12 Correct 39 ms 6012 KB Output is correct
13 Correct 348 ms 6136 KB Output is correct
14 Correct 254 ms 6136 KB Output is correct
15 Correct 306 ms 6484 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4011 ms 23504 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 7 ms 5112 KB Output is correct
2 Correct 6 ms 5112 KB Output is correct
3 Correct 7 ms 5112 KB Output is correct
4 Correct 5 ms 5164 KB Output is correct
5 Correct 6 ms 5164 KB Output is correct
6 Correct 6 ms 5164 KB Output is correct
7 Correct 7 ms 5164 KB Output is correct
8 Correct 9 ms 5220 KB Output is correct
9 Correct 7 ms 5220 KB Output is correct
10 Correct 312 ms 5660 KB Output is correct
11 Correct 202 ms 5768 KB Output is correct
12 Correct 39 ms 6012 KB Output is correct
13 Correct 348 ms 6136 KB Output is correct
14 Correct 254 ms 6136 KB Output is correct
15 Correct 306 ms 6484 KB Output is correct
16 Execution timed out 4011 ms 23504 KB Time limit exceeded
17 Halted 0 ms 0 KB -