Submission #35001

# Submission time Handle Problem Language Result Execution time Memory
35001 2017-11-17T09:19:26 Z antran2202 스파이 (JOI13_spy) C++14
0 / 100
136 ms 5468 KB
//code.cpp
#include <bits/stdc++.h>
using namespace std;
#define whole(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define pb push_back
#define mp make_pair
#define ins insert
#define _(a) #a << " : " << (a)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
//----------------------------------------------------------
const int inf = 1e9, maxn = 2001;
const ll inff = 1e18;
const ld eps = 1e-9, pi = acos (-1);
int n, k, m;
// Đi từ nút cần xét x có nút tương ứng y của cây ioi lên gốc, với mỗi i nút đếm các cặp công việc (i, j) sao cho j cx là bố của
struct job
{
	int s, r;
	job () {}
	job (int ss, int rr)
	{
		s = ss, r = rr;
	}
};
vector <job> jl;
int p, q[maxn], c[maxn], res[maxn];
vi adj[maxn], ja[maxn];
int cnt[maxn];
int hihi (int i)
{
	int res = 0;
	while (i != 0)
	{
		if (cnt[i]) res++;
		i = q[i];
	}
	return res;
}
void dfs (int i)
{
	for (int j : ja[i]) cnt[j] ++;
	res[i] = hihi (i);
	for (int j : adj[i])
		dfs (j);
	for (int j : ja[i]) cnt[j] --;
}
void input ()
{
	cin >> n >> m;
	for (int i = 1; i <= n; ++i)
		cin >> p >> q[i], adj[p].pb (i);
	int s, r;
	for (int i = 1; i <= m; ++i)
		cin >> s >> r, ja[s].pb (r);
}
void solve ()
{
	dfs (0);
	for (int i = 1; i <= n; ++i) cout << res[i] << '\n';
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie (NULL);
	cout.tie (NULL);
	input ();
	solve ();
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 2432 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 136 ms 5468 KB Execution killed because of forbidden syscall writev (20)
2 Halted 0 ms 0 KB -