답안 #825975

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
825975 2023-08-15T09:40:01 Z thimote75 늑대인간 (IOI18_werewolf) C++14
0 / 100
3976 ms 39816 KB
#include "werewolf.h"

#include <bits/stdc++.h>

using namespace std;

using idata = vector<int>;

struct Road {
  int x, y;

  Road (int _x, int _y) {
    x = min(_x, _y);
    y = max(_x, _y);
  }
};

using t_Roads = vector<Road>;
using t_Graph = vector<t_Roads>;

t_Graph roads;
idata visited; int stage = 0;

bool dfs (int source, int target, int left, int right) {
    if (source == target) return true;
    
    if (visited[source] == stage) return false;
    visited[source] = stage;

    for (Road &road : roads[source]) {
        int next = road.x == source ? road.y : road.x;

        if (road.x <  left && right  < road.y) continue ;
        if (next   >= left && source < left) continue ;
        
        if (dfs(next, target, left, right))
            return true;
    }

    return false;
}

idata check_validity(int N, idata X, idata Y,
                            idata S, idata E,
                            idata L, idata R) {
  int M = X.size(); int Q = S.size();

  roads.resize(N);

  for (int i = 0; i < M; i ++) {
    Road road (X[i], Y[i]);

    roads[road.x].push_back(road);
    roads[road.y].push_back(road);
  }

  idata A(Q);
  visited.resize(N);

  for (int i = 0; i < Q; i ++) {
    stage ++;
    A[i] = dfs(S[i], E[i], L[i], R[i]);
  }

  return A;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3976 ms 39816 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -