Submission #312716

# Submission time Handle Problem Language Result Execution time Memory
312716 2020-10-14T08:36:42 Z reymontada61 Werewolf (IOI18_werewolf) C++14
15 / 100
4000 ms 29968 KB
#include "werewolf.h"
#include <bits/stdc++.h>
using namespace std;

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 Q = S.size();
  vector<int> A;
  vector<int> adj[N+1];
  
  int M = X.size();
  
  for (int i=0; i<M; i++) {
	  adj[X[i]].push_back(Y[i]);
	  adj[Y[i]].push_back(X[i]);
  }
  
  bool reach[N+1][2];
  
  for (int i=0; i<Q; i++) {
	  
	  int s = S[i], e = E[i], l = L[i], r = R[i];
	  
	  memset(reach, 0, sizeof reach);
	  queue<pair<int, int>> proc;
	  
	  if (s >= l) proc.push({s, 0});
	  
	  while (!proc.empty()) {
		  
		  auto x = proc.front();
		  proc.pop();
		  
		  int no = x.first;
		  int st = x.second;
		  
		  if (l <= no && no <= r && st == 0) {
			  if (!reach[no][1]) {
				  reach[no][1] = true;
				  proc.push({no, 1});
			  }
		  }
		  
		  for (auto x: adj[no]) {
			  if (st == 0 && x < l) {
				  continue;
			  }
			  else if (st == 1 && x > r) {
				  continue;
			  }
			  else {
				  if (!reach[x][st]) {
					  reach[x][st] = true;
					  proc.push({x, st});
				  }
			  }
		  }
		  
	  }
	  
	  if (reach[e][1]) {
		  A.push_back(1);
	  }
	  else {
		  A.push_back(0);
	  }
  }
  
  return A;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 452 ms 768 KB Output is correct
11 Correct 279 ms 768 KB Output is correct
12 Correct 24 ms 768 KB Output is correct
13 Correct 365 ms 768 KB Output is correct
14 Correct 240 ms 888 KB Output is correct
15 Correct 269 ms 896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4070 ms 29968 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 384 KB Output is correct
2 Correct 1 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 452 ms 768 KB Output is correct
11 Correct 279 ms 768 KB Output is correct
12 Correct 24 ms 768 KB Output is correct
13 Correct 365 ms 768 KB Output is correct
14 Correct 240 ms 888 KB Output is correct
15 Correct 269 ms 896 KB Output is correct
16 Execution timed out 4070 ms 29968 KB Time limit exceeded
17 Halted 0 ms 0 KB -