Submission #112491

# Submission time Handle Problem Language Result Execution time Memory
112491 2019-05-20T08:44:52 Z njchung99 스파이 (JOI13_spy) C++14
0 / 100
229 ms 36644 KB
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
int dp[2010][2010];
int sum[2010][2010];
int p[2010];
int p1[2010];
int func(int here, int here1)
{
	if (here == 0 || here1 == 0)return 0;
	int &ret = dp[here][here1];
	if (ret != -1)return ret;
	ret = 0;
	ret =ret+ sum[here][here1]+func(p[here],here1)+func(here,p1[here1])-func(p[here],p1[here]);
	return ret;
}
int main()
{
	memset(dp, -1, sizeof(dp));
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++) {
		int q, w;
		scanf("%d %d", &q, &w);
		p[i] = q; p1[i] = w;
	}
	for (int i = 1; i <= m; i++) {
		int q, w;
		scanf("%d %d", &q, &w);
		sum[q][w]++;
	}
	for (int i = 1; i <= n; i++) {
		printf("%d\n", func(i, i));
	}
}

Compilation message

spy.cpp: In function 'int main()':
spy.cpp:23:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d %d", &n, &m);
  ~~~~~^~~~~~~~~~~~~~~~~
spy.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &q, &w);
   ~~~~~^~~~~~~~~~~~~~~~~
spy.cpp:31:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d", &q, &w);
   ~~~~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 16768 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 76 ms 22404 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 229 ms 36644 KB Output isn't correct
2 Halted 0 ms 0 KB -