답안 #580512

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
580512 2022-06-21T11:17:05 Z Vanilla 늑대인간 (IOI18_werewolf) C++17
15 / 100
257 ms 19668 KB
#include <bits/stdc++.h>
#include "werewolf.h"
using namespace std;
const int maxn = 3e3 + 2;
vector <int> ad [maxn];
bitset <maxn> vis1, vis2;

void dfs1 (int u, int l, int r) {
  vis1[u] = 1;
  for (int v: ad[u]) {
    if (v < l || vis1[v]) continue;
    dfs1(v, l, r);
  }
}

int dfs2 (int u, int l, int r) {
  vis2[u] = 1;
  bool b = (vis1[u] && u >= l && u <= r);
  for (int v: ad[u]) {
    if (v > r || vis2[v]) continue;
    b|=dfs2(v, l, r);
  }
  return b;  
}

vector<int> check_validity(int N, vector<int> X, vector<int> Y,
                                vector<int> S, vector<int> E,
                                vector<int> L, vector<int> R) {
  for (int i = 0; i < X.size(); i++){
    ad[X[i]].push_back(Y[i]);
    ad[Y[i]].push_back(X[i]);
  }
  int Q = S.size();
  vector<int> A(Q);
  for (int i = 0; i < Q; ++i) {
    vis1 = vis2 = 0;
    dfs1(S[i], L[i], R[i]);
    A[i] = dfs2(E[i], L[i], R[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:29:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   for (int i = 0; i < X.size(); i++){
      |                   ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 372 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 1 ms 368 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 368 KB Output is correct
9 Correct 1 ms 372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 372 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 1 ms 368 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 368 KB Output is correct
9 Correct 1 ms 372 KB Output is correct
10 Correct 241 ms 848 KB Output is correct
11 Correct 127 ms 716 KB Output is correct
12 Correct 14 ms 852 KB Output is correct
13 Correct 257 ms 752 KB Output is correct
14 Correct 173 ms 700 KB Output is correct
15 Correct 209 ms 924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 127 ms 19668 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 372 KB Output is correct
3 Correct 1 ms 376 KB Output is correct
4 Correct 1 ms 368 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 368 KB Output is correct
9 Correct 1 ms 372 KB Output is correct
10 Correct 241 ms 848 KB Output is correct
11 Correct 127 ms 716 KB Output is correct
12 Correct 14 ms 852 KB Output is correct
13 Correct 257 ms 752 KB Output is correct
14 Correct 173 ms 700 KB Output is correct
15 Correct 209 ms 924 KB Output is correct
16 Runtime error 127 ms 19668 KB Execution killed with signal 11
17 Halted 0 ms 0 KB -