Submission #992169


Source Code Expand

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int int64_t

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
#define maxup(ans, x) (ans = (ans < x ? x : ans))
#define minup(ans, x) (ans = (ans > x ? x : ans))

#define breakif(cond) if(cond) break; else

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

int dfs(int now, VV &g, V& visited) {
	visited[now] = true;
	int sum = 1;
	for (int x : g[now]) if (!visited[x]) {
		sum += dfs(x, g, visited);
	}
	return sum;
}

signed main() {
	int n, m; cin >> n >> m;
	VV g(n);
	V pre(m, -1);
	rep(i, n) {
		int k; cin >> k;
		rep(j, k) {
			int l; cin >> l;
			l--;
			if (pre[l] != -1) {
				g[i].push_back(pre[l]);
				g[pre[l]].push_back(i);
			}
			pre[l] = i;
		}
	}

	V vs(n);
	int ans = dfs(0, g, vs);
	cout << (ans == n ? "YES" : "NO") << endl;

	system("pause");
}

Submission Info

Submission Time
Task C - Interpretation
User tosaka2
Language C++14 (GCC 5.4.1)
Score 400
Code Size 1367 Byte
Status AC
Exec Time 74 ms
Memory 12160 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:59:17: warning: ignoring return value of ‘int system(const char*)’, declared with attribute warn_unused_result [-Wunused-result]
  system("pause");
                 ^

Judge Result

Set Name sample dataset1 dataset2
Score / Max Score 0 / 0 200 / 200 200 / 200
Status
AC × 2
AC × 12
AC × 25
Set Name Test Cases
sample sample-01.txt, sample-02.txt
dataset1 sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt
dataset2 sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt
Case Name Status Exec Time Memory
01-01.txt AC 4 ms 504 KB
01-02.txt AC 4 ms 500 KB
01-03.txt AC 4 ms 504 KB
01-04.txt AC 4 ms 512 KB
01-05.txt AC 4 ms 504 KB
01-06.txt AC 4 ms 504 KB
01-07.txt AC 4 ms 500 KB
01-08.txt AC 4 ms 504 KB
01-09.txt AC 4 ms 504 KB
01-10.txt AC 5 ms 632 KB
02-01.txt AC 39 ms 2552 KB
02-02.txt AC 65 ms 8056 KB
02-03.txt AC 43 ms 3064 KB
02-04.txt AC 58 ms 5112 KB
02-05.txt AC 66 ms 7032 KB
02-06.txt AC 58 ms 5112 KB
02-07.txt AC 65 ms 6392 KB
02-08.txt AC 56 ms 9080 KB
02-09.txt AC 74 ms 12160 KB
02-10.txt AC 53 ms 6272 KB
02-11.txt AC 52 ms 6392 KB
02-12.txt AC 49 ms 4600 KB
02-13.txt AC 50 ms 4600 KB
sample-01.txt AC 4 ms 500 KB
sample-02.txt AC 4 ms 504 KB