답안 #815404

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
815404 2023-08-08T14:47:24 Z erray 늑대인간 (IOI18_werewolf) C++17
15 / 100
4000 ms 23152 KB
#include "werewolf.h"
//author: erray
#include <bits/stdc++.h>

using namespace std;
 
#ifdef DEBUG
  #include "/home/ioi/codes/debug.h"
#else
  #define debug(...) (void) 37
#endif

struct DSU {
  vector<int> link;
  DSU(int n) {
    link.resize(n);
    iota(link.begin(), link.end(), 0);
  }
  int get(int v) {
    return link[v] = (v == link[v] ? v : get(link[v]));
  }
  bool unite(int x, int y) {
    x = get(x), y = get(y);
    if (x == y) {
      return false;
    }
    link[y] = x;
    return true;
  }
};
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 M = int(X.size());
  int Q = int(E.size());
  vector<vector<int>> g(N);
  for (int i = 0; i < M; ++i) {
    g[X[i]].push_back(Y[i]);
    g[Y[i]].push_back(X[i]);
  }
  vector<int> ans(Q);
  for (int q = 0; q < Q; ++q) {
    DSU eg(N), sg(N);
    for (int i = 0; i <= R[q]; ++i) {
      for (auto u : g[i]) {
        if (u < i) {
          eg.unite(i, u);
        }
      }
    }
    for (int i = N - 1; i >= L[q]; --i) {
      for (auto u : g[i]) {
        if (u > i) {
          sg.unite(i, u);
        }
      }
    }
    for (int i = 0; i < N; ++i) {
      ans[q] |= (eg.get(i) == eg.get(E[q]) && sg.get(i) == sg.get(S[q]));
    }
  }
  return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 437 ms 736 KB Output is correct
11 Correct 399 ms 724 KB Output is correct
12 Correct 246 ms 724 KB Output is correct
13 Correct 494 ms 736 KB Output is correct
14 Correct 438 ms 724 KB Output is correct
15 Correct 1008 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4101 ms 23152 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 300 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 312 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 437 ms 736 KB Output is correct
11 Correct 399 ms 724 KB Output is correct
12 Correct 246 ms 724 KB Output is correct
13 Correct 494 ms 736 KB Output is correct
14 Correct 438 ms 724 KB Output is correct
15 Correct 1008 ms 852 KB Output is correct
16 Execution timed out 4101 ms 23152 KB Time limit exceeded
17 Halted 0 ms 0 KB -