Submission #332430

# Submission time Handle Problem Language Result Execution time Memory
332430 2020-12-02T13:40:58 Z pggp Werewolf (IOI18_werewolf) C++14
15 / 100
4000 ms 31852 KB
#include <bits/stdc++.h>

using namespace std;

vector < bool > used_wer;
vector < bool > used_hum;
vector < vector < int > > Ed;

int cur_R, cur_L;

void wer_dfs(int vertex){
	used_wer[vertex] = true;
	for(int v : Ed[vertex]){
		if(!used_wer[v] and v <= cur_R){
			wer_dfs(v);
		}
	}
}

void hum_dfs(int vertex){
	used_hum[vertex] = true;
	for(int v : Ed[vertex]){
		if(!used_hum[v] and v >= cur_L){
			hum_dfs(v);
		}
	}

}

vector < int > check_validity(int N, vector < int > X, vector < int > Y, vector < int > S, vector < int > E, vector < int > L, vector < int > R){
	vector < int > ans;
	int Q = E.size();
	Ed.resize(N);
	used_wer.resize(N);
	used_hum.resize(N);
	for (int i = 0; i < X.size(); ++i)
	{
		Ed[X[i]].push_back(Y[i]);
		Ed[Y[i]].push_back(X[i]);
	}



	for(int q = 0; q < Q; q++){
		cur_R = R[q];
		cur_L = L[q];
		for (int i = 0; i < N; ++i)
		{
			used_hum[i] = false;
			used_wer[i] = false;
		}
		hum_dfs(S[q]);
		wer_dfs(E[q]);
		int to_return = 0;
		for (int i = 0; i < N; ++i)
		{
			if(used_hum[i] and used_wer[i]){
				to_return = 1;
			}
		}
		ans.push_back(to_return);
	}
	return ans;
}

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:36:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |  for (int i = 0; i < X.size(); ++i)
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 312 ms 876 KB Output is correct
11 Correct 179 ms 748 KB Output is correct
12 Correct 49 ms 1004 KB Output is correct
13 Correct 329 ms 876 KB Output is correct
14 Correct 220 ms 908 KB Output is correct
15 Correct 280 ms 1004 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4045 ms 31852 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 312 ms 876 KB Output is correct
11 Correct 179 ms 748 KB Output is correct
12 Correct 49 ms 1004 KB Output is correct
13 Correct 329 ms 876 KB Output is correct
14 Correct 220 ms 908 KB Output is correct
15 Correct 280 ms 1004 KB Output is correct
16 Execution timed out 4045 ms 31852 KB Time limit exceeded
17 Halted 0 ms 0 KB -