Submission #1889889


Source Code Expand

#include<iostream>
#include <list>
#include<stack>
#include<queue>
#include <vector>
#include <set>
#include <map>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
#include<string>
#include <functional>
#include"time.h"
using namespace std;

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define LL long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define dump(x)  cerr << #x << " = " << (x) << endl
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
const int INF = (1 << 30);

//毎回変える定数
#define N_MAX 200


//問題文のとおりの変数
int N, M;

//オリジナル変数
vector<vector<int>> P2L;//人から言語への辺
vector<vector<int>> L2P;//言語から人への辺

vector<bool> connectionP;
vector<bool> connectionL;

//サブ関数
//入力
void input() {
	cin >> N >> M;
	REP(i, N)connectionP.push_back(false);
	REP(i, M)connectionL.push_back(false);
	REP(i, M)L2P.push_back(vector<int>());

	int K,tmp;
	REP(i, N) {
		vector<int> tmpL;
		cin >> K;
		REP(j, K) {
			cin >> tmp;
			tmp--;

			tmpL.push_back(tmp);//P2L
			L2P[tmp].push_back(i);//L2P
		}
		P2L.push_back(tmpL);
	}
}

//計算
void connectP2L(int);
void connectL2P(int lang) {
	if (connectionL[lang])return;
	connectionL[lang] = true;
	for (auto var : L2P[lang]) {
		connectP2L(var);
	}
}

void connectP2L(int person) {
	if (connectionP[person])return;
	connectionP[person] = true;
	for (auto var : P2L[person]) {
		connectL2P(var);
	}
}

void calc() {
	connectP2L(0);
}

//出力
void output() {
	bool flag = true;
	for (auto var : connection) {
		if (var == false) {
			flag = false;
			break;
		}
	}
	if (flag)cout << "YES" << endl;
	else cout << "NO" << endl;
}

//デバッグ
void debug() {
	cin >> N;
}

//メイン関数
int main() {

	input();
	calc();
	output();
	debug();

	return 0;
}

Submission Info

Submission Time
Task C - Interpretation
User toma25
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2010 Byte
Status CE

Compile Error

./Main.cpp: In function ‘void output()’:
./Main.cpp:88:18: error: ‘connection’ was not declared in this scope
  for (auto var : connection) {
                  ^