Submission #825999

# Submission time Handle Problem Language Result Execution time Memory
825999 2023-08-15T09:47:58 Z thimote75 Werewolf (IOI18_werewolf) C++14
15 / 100
4000 ms 52240 KB
#include "werewolf.h"

#include <bits/stdc++.h>

using namespace std;

using idata = vector<int>;
using igrid = vector<idata>;

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;
igrid visited; int stage = 0;

bool dfs (int source, int state, int target, int left, int right) {
    if (state >= 2)
      return false;
    if (state == 0 && source < left) return false;
    if (state == 1 && source > right) return false;

    if (source == target) return true;

    
    if (visited[source][state] == stage) return false;
    visited[source][state] = stage;

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

        if (road.x < left && right < road.y) continue ;
        
        if (dfs(next, state,     target, left, right)
         || dfs(next, state + 1, 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, idata(2));

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

  return A;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 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 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 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 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 153 ms 972 KB Output is correct
11 Correct 116 ms 852 KB Output is correct
12 Correct 14 ms 1108 KB Output is correct
13 Correct 108 ms 948 KB Output is correct
14 Correct 90 ms 888 KB Output is correct
15 Correct 383 ms 1088 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4050 ms 52240 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 296 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 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 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 153 ms 972 KB Output is correct
11 Correct 116 ms 852 KB Output is correct
12 Correct 14 ms 1108 KB Output is correct
13 Correct 108 ms 948 KB Output is correct
14 Correct 90 ms 888 KB Output is correct
15 Correct 383 ms 1088 KB Output is correct
16 Execution timed out 4050 ms 52240 KB Time limit exceeded
17 Halted 0 ms 0 KB -