제출 #383377

#제출 시각아이디문제언어결과실행 시간메모리
383377luciocfBitaro’s Party (JOI18_bitaro)C++14
14 / 100
129 ms21220 KiB
#include <bits/stdc++.h>

using namespace std;

const int maxn = 2e5+10;
const int inf = 1e9+10;

int n, m, q;
int dp[maxn];

bool mark[maxn], block[maxn];

vector<int> grafo[2][maxn], ord;

void dfs(int u)
{
	mark[u] = 1;

	for (auto v: grafo[1][u])
		if (!mark[v])
			dfs(v);

	ord.push_back(u);
}

int main(void)
{
	scanf("%d %d %d", &n, &m, &q);

	for (int i = 1; i <= m; i++)
	{
		int u, v;
		scanf("%d %d", &u, &v);

		grafo[0][u].push_back(v);
		grafo[1][v].push_back(u);
	}

	int source, m;
	scanf("%d %d", &source, &m);

	for (int i = 1; i <= m; i++)
	{
		int u;
		scanf("%d", &u);

		block[u] = 1;
	}

	dfs(source);

	for (int i = 1; i <= n; i++)
		dp[i] = -inf;

	dp[source] = 0;

	for (int i = (int)ord.size()-2; i >= 0; i--)
	{
		int u = ord[i];

		for (auto v: grafo[0][u])
			dp[u] = max(dp[u], 1 + dp[v]);
	}

	int ans = -inf;

	for (int i = 1; i <= n; i++)
		if (!block[i])
			ans = max(ans, dp[i]);

	if (ans == -inf) printf("-1\n");
	else printf("%d\n", ans);
}

컴파일 시 표준 에러 (stderr) 메시지

bitaro.cpp: In function 'int main()':
bitaro.cpp:28:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   28 |  scanf("%d %d %d", &n, &m, &q);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:33:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   33 |   scanf("%d %d", &u, &v);
      |   ~~~~~^~~~~~~~~~~~~~~~~
bitaro.cpp:40:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   40 |  scanf("%d %d", &source, &m);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
bitaro.cpp:45:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   45 |   scanf("%d", &u);
      |   ~~~~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...