답안 #1055403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1055403 2024-08-12T18:44:54 Z ArthuroWich 늑대인간 (IOI18_werewolf) C++17
0 / 100
4000 ms 22356 KB
#include "werewolf.h"
#include<bits/stdc++.h>
using namespace std;
vector<int> check_validity(int n, vector<int> X, vector<int> Y, vector<int> S, vector<int> E, vector<int> L, vector<int> R) {
    int q = S.size();
    vector<int> a(q);
    vector<vector<int>> adj(n);
    for (int i = 0; i < X.size(); i++) {
        adj[X[i]].push_back(Y[i]);
        adj[Y[i]].push_back(X[i]);
    }
    for (int i = 0; i < q; i++) {
        int l = L[i], r = R[i];
        vector<int> vis(n, 0);
        queue<int> q;
        if (S[i] >= l) {
            q.push(S[i]);
        }
        if (E[i] > r) {
            a[i] = 0;
            continue;
        }
        while(!q.empty()) {
            int a = q.front();
            q.pop();
            if (vis[a]) {
                continue;
            }
            vis[a] = 1;
            for (int b : adj[a]) {
                if (b >= l) {
                    q.push(b);
                }
            }
        }
        for (int i = l; i <= r; i++) {
            if (vis[i]) {
                for (int b : adj[i]) {
                    if (b < l) {
                        q.push(b);
                    }
                }
            }
        }
        while(!q.empty()) {
            int a = q.front();
            q.pop();
            if (vis[a]) {
                continue;
            }
            vis[a] = 1;
            for (int b : adj[a]) {
                if (b < r) {
                    q.push(b);
                }
            }
        }
        a[i] = vis[E[i]];
    }
    return a;
}

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:8:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    8 |     for (int i = 0; i < X.size(); i++) {
      |                     ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4062 ms 22356 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -