답안 #333591

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
333591 2020-12-07T06:37:42 Z nicholask 늑대인간 (IOI18_werewolf) C++14
컴파일 오류
0 ms 0 KB
#include "werewolf.h"
#include <bits/stdc++.h>
using namespace std;
vector <int> check_validity(int n,vector <int> x,vector <int> y,vector <int> s,vector <int> e,vector <int> l,vector <int> r){
	int m=x.size(),q=s.size();
	vector <int> g[n];
	for (int i=0; i<m; i++){
		g[x[i]].push_back(y[i]);
		g[y[i]].push_back(x[i]);
	}
	vector <int> res;
	for (int i=0; i<q; i++){
		bool visited[n];
		for (int j=0; j<n; j++) visited[i]=0;
		queue <int> q;
		if (s[i]>=l[i]){
			q.push(s[i]);
			visited[q[i]]=1;
		}
		while (!q.empty()){
			int t=q.front();
			q.pop();
			for (auto&j:g[t]){
				if (j>=l[i]&&!visited[j]){
					q.push(j);
					visited[j]=1;
				}
			}
		}
		for (int j=0; j<n; j++){
			if (!visited[j]) continue;
			bool vis[n];
			for (int k=0; k<n; i++) vis[k]=0;
			queue <int> r;
			if (j<=r[i]){
				r.push(j);
				vis[j]=1;
			}
			while (!r.empty()){
				int t=r.front();
				r.pop();
				if (t==e[i]){
					res.push_back(1);
					goto die;
				}
				for (auto&k:g[t]){
					if (k<=r[i]&&!vis[k]){
						r.push(k);
						visited[k]=1;
					}
				}
			}
		}
		ans.push_back(0);
		die:;
	}
	return res;
}

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:18:13: error: no match for 'operator[]' (operand types are 'std::queue<int>' and 'int')
   18 |    visited[q[i]]=1;
      |             ^
werewolf.cpp:35:12: error: no match for 'operator[]' (operand types are 'std::queue<int>' and 'int')
   35 |    if (j<=r[i]){
      |            ^
werewolf.cpp:47:14: error: no match for 'operator[]' (operand types are 'std::queue<int>' and 'int')
   47 |      if (k<=r[i]&&!vis[k]){
      |              ^
werewolf.cpp:54:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   54 |   ans.push_back(0);
      |   ^~~
      |   abs