Submission #435160

# Submission time Handle Problem Language Result Execution time Memory
435160 2021-06-23T04:34:11 Z Apiram Werewolf (IOI18_werewolf) C++14
0 / 100
4000 ms 58576 KB
#include<bits/stdc++.h>
#include "werewolf.h"
using namespace std;
vector<vector<int>>adj(2e5 + 5);
bool ok;
vector<vector<bool>>visited(2e5 + 5,vector<bool>(2,false));
void dfs (int s,int bot,int l,int r,int e){
	if (ok)return;
	if (s==e&&bot==1){
		ok=true;
		return;
	}
	else if (s==e)return;
	visited[s][bot]=true;
	for (auto x:adj[s]){
			if (bot==0&&x>=r&&!visited[x][bot]){
				dfs(x,bot,l,r,e);
			}
			else if (bot==1&&x<=l&&!visited[x][bot]){
				dfs(x,bot,l,r,e);
			}
			else if (x>l&&x<r){
				if (!visited[x][bot^1])
				dfs(x,bot^1,l,r,e);
				if (!visited[x][bot])
				dfs(x,bot,l,r,e);
			}
	}
}
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) {
  vector<int>A(E.size());
  for (int i  =0;i<X.size();++i){
  	adj[X[i]].push_back(Y[i]);
  	adj[Y[i]].push_back(X[i]);
  }
  //0 - human
  //1 - wolf
	for (int i  =0;i<E.size();++i){
  	ok=false;
	  for (int j =0;j<=N;++j){
	  	visited[j][0]=false;
	  	visited[j][1]=false;
	  }
  	if (s[i]>=L[i]&&s[i]<=R[i]){
  		dfs(s[i],0,L[i]-1,R[i]+1,E[i]);
  		dfs(s[i],1,L[i]-1,R[i]+1,E[i]);
  	}
  	else 
  	dfs(s[i],0,L[i]-1,R[i]+1,E[i]);
  	A[i]=ok;}
  	
  return A;
}

Compilation message

werewolf.cpp: In function 'std::vector<int> check_validity(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
werewolf.cpp:34:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |   for (int i  =0;i<X.size();++i){
      |                  ~^~~~~~~~~
werewolf.cpp:40:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |  for (int i  =0;i<E.size();++i){
      |                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 21 ms 19020 KB Output is correct
2 Incorrect 19 ms 19092 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 19020 KB Output is correct
2 Incorrect 19 ms 19092 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4046 ms 58576 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 21 ms 19020 KB Output is correct
2 Incorrect 19 ms 19092 KB Output isn't correct
3 Halted 0 ms 0 KB -