답안 #57792

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
57792 2018-07-16T06:26:56 Z YaDon4ick 동기화 (JOI13_synchronization) C++14
0 / 100
180 ms 15112 KB
//By Don4ick
//#define _GLIBCXX_DEBUG

#include <bits/stdc++.h>

typedef long long ll;
typedef long double ld;
typedef unsigned int ui;

#define forn(i, n) for (int i = 1; i <= n; i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define y1 qwer1234

const double PI = acos(-1.0);
const int DIR = 4;
const int X[] = {1, 0, -1, 0};
const int Y[] = {0, 1, 0, -1};

const int N = (int)2e5 + 228;

using namespace std;

int n, m, q, l[N], r[N], st[N];
vector < pair < int, int > > g[N];

int dfs(int v, int t, int pr)
{
	int res = 1;
	for (auto e : g[v])
	{
		int to = e.first, id = e.second;
		if (to == pr)
			continue;	
		if (l[id] > t)
			continue;
		res += dfs(to, min(t, r[id]), v);	
	}
	return res;
}

int main()
{
	//ios_base::sync_with_stdio(false);
	//cin.tie(NULL);
	//cout.tie(NULL);

	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);

	//~read
	scanf("%d%d%d", &n, &m, &q);
	forn(i, n - 1)
	{
		int v, u;
		scanf("%d%d", &v, &u);
		g[v].pb({u, i}), g[u].pb({v, i});
	}
	forn(i, m)
	{
		int e;
		scanf("%d", &e);	
		if (st[e])
		{
			l[e] = st[e], r[e] = i;			
			st[e] = 0;
		}
		else
		{
			st[e] = i;
			l[e] = i, r[e] = m;
		}
	}
	//~solve
	forn(i, q)
	{
		int v;
		scanf("%d", &v);
		printf("%d\n", dfs(v, m, -1));
	}	


	return 0;
}

Compilation message

synchronization.cpp: In function 'int main()':
synchronization.cpp:52:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d", &n, &m, &q);
  ~~~~~^~~~~~~~~~~~~~~~~~~~~~
synchronization.cpp:56:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &v, &u);
   ~~~~~^~~~~~~~~~~~~~~~
synchronization.cpp:62:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &e); 
   ~~~~~^~~~~~~~~~
synchronization.cpp:78:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &v);
   ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 5112 KB Output is correct
2 Correct 6 ms 5356 KB Output is correct
3 Correct 6 ms 5356 KB Output is correct
4 Correct 6 ms 5356 KB Output is correct
5 Incorrect 7 ms 5356 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 66 ms 15112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 15112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 180 ms 15112 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 15112 KB Output is correct
2 Incorrect 6 ms 15112 KB Output isn't correct
3 Halted 0 ms 0 KB -