Submission #341835

# Submission time Handle Problem Language Result Execution time Memory
341835 2020-12-31T07:09:02 Z shrek12357 Werewolf (IOI18_werewolf) C++14
15 / 100
362 ms 32620 KB
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
#include <stack>
#include <bitset>
//#include "molecules.h"
using namespace std;
#define ll long long
//cin.tie(0);ios_base::sync_with_stdio(0);

const int MAXN = 1e5 + 5;

int n;
vector<int> adjList[MAXN];

bool ans1(int s, int e, int l, int r) {
	bool can[MAXN], can1[MAXN];
	bool vis[MAXN], vis1[MAXN];
	queue<int> q;
	q.push(s);
	for (int i = 0; i < n; i++) {
		vis[i] = false;
		vis1[i] = false;
		can[i] = false;
		can1[i] = false;
	}
	while (q.size() > 0) {
		int cur = q.front();
		q.pop();
		if (vis[cur]) {
			continue;
		}
		can[cur] = true;
		vis[cur] = true;
		for (auto i : adjList[cur]) {
			if(i >= l)
				q.push(i);
		}
	}
	q.push(e);
	while (q.size() > 0) {
		int cur = q.front();
		q.pop();
		if (vis1[cur]) {
			continue;
		}
		vis1[cur] = true;
		can1[cur] = true;
		for (auto i : adjList[cur]) {
			if (i <= r) {
				q.push(i);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (can[i] == can1[i] && can[i]) {
			return true;
		}
	}
	return false;
}


vector<int> check_validity(int N, vector<int> x, vector<int> y, vector<int> s, vector<int> e, vector<int> l, vector<int> r) {
	n = N;
	for (int i = 0; i < x.size(); i++) {
		adjList[x[i]].push_back(y[i]);
		adjList[y[i]].push_back(x[i]);
	}
	vector<int> ans;
	for (int i = 0; i < s.size(); i++) {
		ans.push_back(ans1(s[i], e[i], l[i], r[i]));
	}
	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:73:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |  for (int i = 0; i < x.size(); i++) {
      |                  ~~^~~~~~~~~~
werewolf.cpp:78:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   78 |  for (int i = 0; i < s.size(); i++) {
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 3 ms 2796 KB Output is correct
4 Correct 2 ms 2668 KB Output is correct
5 Correct 2 ms 2668 KB Output is correct
6 Correct 3 ms 2668 KB Output is correct
7 Correct 3 ms 2668 KB Output is correct
8 Correct 2 ms 2668 KB Output is correct
9 Correct 2 ms 2668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 3 ms 2796 KB Output is correct
4 Correct 2 ms 2668 KB Output is correct
5 Correct 2 ms 2668 KB Output is correct
6 Correct 3 ms 2668 KB Output is correct
7 Correct 3 ms 2668 KB Output is correct
8 Correct 2 ms 2668 KB Output is correct
9 Correct 2 ms 2668 KB Output is correct
10 Correct 336 ms 3308 KB Output is correct
11 Correct 210 ms 3052 KB Output is correct
12 Correct 39 ms 3052 KB Output is correct
13 Correct 362 ms 3308 KB Output is correct
14 Correct 258 ms 3052 KB Output is correct
15 Correct 295 ms 3308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 175 ms 32620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2668 KB Output is correct
2 Correct 2 ms 2668 KB Output is correct
3 Correct 3 ms 2796 KB Output is correct
4 Correct 2 ms 2668 KB Output is correct
5 Correct 2 ms 2668 KB Output is correct
6 Correct 3 ms 2668 KB Output is correct
7 Correct 3 ms 2668 KB Output is correct
8 Correct 2 ms 2668 KB Output is correct
9 Correct 2 ms 2668 KB Output is correct
10 Correct 336 ms 3308 KB Output is correct
11 Correct 210 ms 3052 KB Output is correct
12 Correct 39 ms 3052 KB Output is correct
13 Correct 362 ms 3308 KB Output is correct
14 Correct 258 ms 3052 KB Output is correct
15 Correct 295 ms 3308 KB Output is correct
16 Runtime error 175 ms 32620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Halted 0 ms 0 KB -