Submission #791066

# Submission time Handle Problem Language Result Execution time Memory
791066 2023-07-23T11:33:00 Z YassirSalama Werewolf (IOI18_werewolf) C++14
15 / 100
242 ms 19660 KB
#include "werewolf.h"
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(),v.end()
#define OVL(v,s) for(auto x:v) cout<<x<<s;cout<<endl;
#define ll long long
#define pb push_back
const int MAXN=3500;
vector<int> c(MAXN,0);
vector<vector<int>> v(MAXN);
void dfs(int node,int ab,vector<bool>& visited){
	visited[node]=true;
	for(auto x:v[node]){
		if(visited[x]) continue;
		if(ab==1&&c[x]<=1){
			//He is human
			dfs(x,ab,visited);
		}else if(ab==2&&c[x]>=1){
			//he is a werewolf
			dfs(x,ab,visited);
		}
	}
}
vector<int> check_validity(int n, vector<int> a, vector<int> b, 
					vector<int> ql, vector<int> qr,
					vector<int> l, vector<int> r) {
	int q = ql.size();
	for(int i=0;i<a.size();i++){
		v[a[i]].pb(b[i]);
		v[b[i]].pb(a[i]);
	}
	vector<int> ans(q,0);
	for(int j=0;j<q;j++){
		for(int i=0;i<n;i++){
			if(i<l[j]) {
				c[i]=2;//You should be a werewolf
			}else if(i<=r[j]) c[i]=1;//you can transform here
			else c[i]=0;//You should be a human here
		}
		vector<bool> visited1(MAXN,false);
		vector<bool> visited2(MAXN,false);
		dfs(ql[j],1,visited1);
		dfs(qr[j],2,visited2);
		for(int i=l[j];i<=r[j];i++){
			if(visited1[i]&&visited2[i]) {
				ans[j]=1;break;
			}
		}
 
	}
	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:28:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |  for(int i=0;i<a.size();i++){
      |              ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 216 ms 652 KB Output is correct
11 Correct 116 ms 624 KB Output is correct
12 Correct 18 ms 724 KB Output is correct
13 Correct 242 ms 780 KB Output is correct
14 Correct 157 ms 628 KB Output is correct
15 Correct 199 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 107 ms 19660 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 0 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 216 ms 652 KB Output is correct
11 Correct 116 ms 624 KB Output is correct
12 Correct 18 ms 724 KB Output is correct
13 Correct 242 ms 780 KB Output is correct
14 Correct 157 ms 628 KB Output is correct
15 Correct 199 ms 760 KB Output is correct
16 Runtime error 107 ms 19660 KB Execution killed with signal 11
17 Halted 0 ms 0 KB -