Submission #602086

# Submission time Handle Problem Language Result Execution time Memory
602086 2022-07-22T14:42:54 Z erekle Werewolf (IOI18_werewolf) C++17
15 / 100
335 ms 11656 KB
#include "werewolf.h"
#include <queue>
#include <iostream>

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 M = X.size(), Q = S.size();
  vector<int> A(Q);
  
  if (N <= 3000 && M <= 6000 && Q <= 3000) { // subtasks 1 and 2
    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]);
    }
    for (int qq = 0; qq < Q; ++qq) {
      cerr << " ON QUERY " << qq << endl;
      int s = S[qq], e = E[qq], l = L[qq], r = R[qq];

      // bfs from start as human
      cerr << " BFS FROM S" << endl;
      vector<bool> canHuman(N);
      queue<int> q;
      q.push(s), canHuman[s] = true;
      while (!q.empty()) {
        int x = q.front();
        q.pop();
        for (int y : g[x]) {
          if (!canHuman[y] && y >= l) q.push(y), canHuman[y] = true;
        }
      }

      cerr << " BFS FROM E" << endl;
      vector<bool> canWolf(N);
      q.push(e), canWolf[e] = true;
      while (!q.empty()) {
        int x = q.front();
        q.pop();
        for (int y : g[x]) {
          if (!canWolf[y] && y <= r) q.push(y), canWolf[y] = true;
        }
      }

      for (int i = 0; i < N; ++i) {
        if (canHuman[i] && canWolf[i] && l <= i && i <= r) A[qq] = 1;
      }
    }
  }

  return A;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 304 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 3 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 2 ms 300 KB Output is correct
9 Correct 2 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 304 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 3 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 2 ms 300 KB Output is correct
9 Correct 2 ms 304 KB Output is correct
10 Correct 281 ms 896 KB Output is correct
11 Correct 193 ms 844 KB Output is correct
12 Correct 50 ms 724 KB Output is correct
13 Correct 335 ms 856 KB Output is correct
14 Correct 229 ms 816 KB Output is correct
15 Correct 259 ms 832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 139 ms 11656 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 304 KB Output is correct
2 Correct 2 ms 212 KB Output is correct
3 Correct 2 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 3 ms 212 KB Output is correct
6 Correct 2 ms 212 KB Output is correct
7 Correct 2 ms 212 KB Output is correct
8 Correct 2 ms 300 KB Output is correct
9 Correct 2 ms 304 KB Output is correct
10 Correct 281 ms 896 KB Output is correct
11 Correct 193 ms 844 KB Output is correct
12 Correct 50 ms 724 KB Output is correct
13 Correct 335 ms 856 KB Output is correct
14 Correct 229 ms 816 KB Output is correct
15 Correct 259 ms 832 KB Output is correct
16 Incorrect 139 ms 11656 KB Output isn't correct
17 Halted 0 ms 0 KB -