답안 #600590

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
600590 2022-07-21T05:55:56 Z jack715 늑대인간 (IOI18_werewolf) C++14
0 / 100
4000 ms 22404 KB
#include "werewolf.h"
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pp pop_back
#define mp make_pair
#define bb back
#define ff first
#define ss second

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<int> path[n];
  for (int i = 0; i < x.size(); i++) {
    path[x[i]].pb(y[i]);
    path[y[i]].pb(x[i]);
  }

  queue<int> bfs;
  for (int i = 0; i < Q; i++) {
    vector<int> used(n, 0);
    bfs.push(s[i]);
    while (!bfs.empty()) {
      int now = bfs.front();
      bfs.pop();
      for (int next : path[now]) {
        if (used[next] || next < l[i]) continue;
        used[next] = 1;
        bfs.push(next);
      }
    }

    for (int j = l[i]; j <= r[i]; j++) {
      if (used[j]) bfs.push(j);
    }

    // cout << "WAY\n";
    while (!bfs.empty()) {
      int now = bfs.front();
      bfs.pop();
      for (int next : path[now]) {
        if (used[next] || next > r[i]) continue;
        used[next] = 1;
        bfs.push(next);
      }
    }

    // cout << "WUT\n";
    if (used[e[i]]) A[i] = 1;
  }
  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:19:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |   for (int i = 0; i < x.size(); i++) {
      |                   ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4098 ms 22404 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -