Submission #136245

# Submission time Handle Problem Language Result Execution time Memory
136245 2019-07-25T04:50:40 Z 김세빈(#3258) Link (CEOI06_link) C++14
12 / 100
270 ms 4728 KB
#include <bits/stdc++.h>

using namespace std;

int D[505050], P[505050];
bool chk[505050];
int n, k, ans;

void erase(int p, int d)
{
	if(!d){
		if(!D[p]){
			erase(p, k);
			ans ++;
		}
		return;
	}
	
	chk[p] = 1; D[P[p]] --;
	if(!chk[P[p]]){
		erase(P[p], d - 1);
	}
}

int main()
{
	int i, x, y;
	
	scanf("%d%d", &n, &k);
	
	for(i=1; i<=n; i++){
		scanf("%d%d", &x, &y);
		P[x] = y; D[y] ++;
	}
	
	erase(1, k);
	
	for(i=1; i<=n; i++){
		if(!chk[i] && D[i] == 0){
			erase(i, k); ans ++;
		}
	}
	
	for(i=1; i<=n; i++){
		if(!chk[i]){
			erase(i, k); ans ++;
		}
	}
	
	printf("%d\n", ans);
	
	return 0;
}

Compilation message

link.cpp: In function 'int main()':
link.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d", &n, &k);
  ~~~~~^~~~~~~~~~~~~~~~
link.cpp:32:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &x, &y);
   ~~~~~^~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Incorrect 2 ms 248 KB Output isn't correct
4 Correct 3 ms 376 KB Output is correct
5 Incorrect 3 ms 376 KB Output isn't correct
6 Incorrect 11 ms 632 KB Output isn't correct
7 Incorrect 16 ms 872 KB Output isn't correct
8 Incorrect 23 ms 932 KB Output isn't correct
9 Correct 32 ms 1272 KB Output is correct
10 Incorrect 32 ms 1272 KB Output isn't correct
11 Correct 51 ms 1656 KB Output is correct
12 Incorrect 71 ms 2096 KB Output isn't correct
13 Incorrect 121 ms 2552 KB Output isn't correct
14 Incorrect 125 ms 2936 KB Output isn't correct
15 Incorrect 143 ms 3396 KB Output isn't correct
16 Incorrect 177 ms 3880 KB Output isn't correct
17 Incorrect 189 ms 4304 KB Output isn't correct
18 Incorrect 213 ms 4664 KB Output isn't correct
19 Incorrect 223 ms 4728 KB Output isn't correct
20 Incorrect 248 ms 4728 KB Output isn't correct
21 Incorrect 235 ms 4668 KB Output isn't correct
22 Incorrect 230 ms 4660 KB Output isn't correct
23 Incorrect 217 ms 4704 KB Output isn't correct
24 Incorrect 225 ms 4728 KB Output isn't correct
25 Incorrect 270 ms 4664 KB Output isn't correct