답안 #790997

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
790997 2023-07-23T10:42:52 Z YassirSalama 늑대인간 (IOI18_werewolf) C++14
15 / 100
283 ms 28004 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;continue;
			}
		}

	}
	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++){
      |              ~^~~~~~~~~
# 결과 실행 시간 메모리 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 1 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 1 ms 348 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
# 결과 실행 시간 메모리 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 1 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 1 ms 348 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 260 ms 756 KB Output is correct
11 Correct 136 ms 724 KB Output is correct
12 Correct 19 ms 796 KB Output is correct
13 Correct 283 ms 820 KB Output is correct
14 Correct 156 ms 732 KB Output is correct
15 Correct 213 ms 908 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 103 ms 28004 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 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 1 ms 348 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 260 ms 756 KB Output is correct
11 Correct 136 ms 724 KB Output is correct
12 Correct 19 ms 796 KB Output is correct
13 Correct 283 ms 820 KB Output is correct
14 Correct 156 ms 732 KB Output is correct
15 Correct 213 ms 908 KB Output is correct
16 Runtime error 103 ms 28004 KB Execution killed with signal 11
17 Halted 0 ms 0 KB -