Submission #992837


Source Code Expand

#include <cstdio>
#include <cmath>

#include <vector>

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define inc( i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec( i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

template<typename T> void swap(T & x, T & y) { T t = x; x = y; y = t; return; }
template<typename T> T abs(T x) { return (0 <= x ? x : -x); }
template<typename T> T max(T a, T b) { return (b <= a ? a : b); }
template<typename T> T min(T a, T b) { return (a <= b ? a : b); }
template<typename T> bool setmin(T & a, T b) { if(a <= b) { return false; } else { a = b; return true; } }
template<typename T> bool setmax(T & a, T b) { if(b <= a) { return false; } else { a = b; return true; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, m;
std::vector<int> p2l[100000];
std::vector<int> l2p[100000];
bool p_vis[100000];
bool l_vis[100000];

int queue[100000], get, set; // person

int main() {
	scanf("%d%d", &n, &m);
	inc(i, n) {
		int k;
		scanf("%d", &k);
		inc(j, k) {
			int lang;
			scanf("%d", &lang);
			p2l[i].push_back(lang);
			l2p[lang].push_back(i);
		}
	}
	
	p_vis[0] = true;
	queue[set++] = 0;
	while(get < set) {
		int q = queue[get++];
		
		for(auto && le : p2l[q]) {
			if(l_vis[le]) { continue; }
			l_vis[le] = true;
			for(auto && pe : l2p[le]) {
				if(! p_vis[pe]) { queue[set++] = pe; p_vis[pe] = true; }
			}
		}
	}
	
	bool ans = true;
	inc(i, n) { ans &= p_vis[i]; }
	
	printf("%s\n", ans ? "YES" : "NO");
	
	return 0;
}

Submission Info

Submission Time
Task C - Interpretation
User FF256grhy
Language C++14 (GCC 5.4.1)
Score 400
Code Size 2036 Byte
Status AC
Exec Time 41 ms
Memory 9080 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:41:23: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &m);
                       ^
./Main.cpp:44:18: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &k);
                  ^
./Main.cpp:47:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
    scanf("%d", &lang);
                      ^

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 7 ms 4992 KB
01-02.txt AC 7 ms 4992 KB
01-03.txt AC 7 ms 4992 KB
01-04.txt AC 8 ms 4992 KB
01-05.txt AC 8 ms 4992 KB
01-06.txt AC 7 ms 4992 KB
01-07.txt AC 7 ms 4992 KB
01-08.txt AC 7 ms 4992 KB
01-09.txt AC 7 ms 4992 KB
01-10.txt AC 7 ms 4992 KB
02-01.txt AC 31 ms 7680 KB
02-02.txt AC 35 ms 8960 KB
02-03.txt AC 31 ms 7168 KB
02-04.txt AC 40 ms 8448 KB
02-05.txt AC 38 ms 8576 KB
02-06.txt AC 41 ms 8448 KB
02-07.txt AC 39 ms 8960 KB
02-08.txt AC 31 ms 8696 KB
02-09.txt AC 34 ms 9080 KB
02-10.txt AC 30 ms 8696 KB
02-11.txt AC 30 ms 8696 KB
02-12.txt AC 30 ms 8704 KB
02-13.txt AC 30 ms 8704 KB
sample-01.txt AC 7 ms 4992 KB
sample-02.txt AC 7 ms 4992 KB