Submission #25422

# Submission time Handle Problem Language Result Execution time Memory
25422 2017-06-22T06:31:08 Z 김동현(#1064) Synchronization (JOI13_synchronization) C++14
0 / 100
109 ms 15268 KB
#include <bits/stdc++.h>
using namespace std;

struct E{
	int x, i;
};

struct Inf{
	int t, x;
	bool operator<(const Inf &oth) const {
		return (t == oth.t) ? (x < oth.x) : (t > oth.t);
	}
};

int n, m, q, ch[100010];
vector<E> e[100010];
vector<int> tv[100010];

int f1(int x, int p, int t){
	int ret = 1;
	for(auto &i : e[x]){
		if(i.x == p) continue;
		int lt = (int)(upper_bound(tv[i.i].begin(), tv[i.i].end(), t) - tv[i.i].begin() - 1);
		if(lt < 0) continue;
		int nt;
		if(lt & 1) nt = tv[i.i][lt];
		else nt = t;
		ret += f1(i.x, x, nt);
	}
	return ret;
}

const int sz = 131072;
struct Seg{
	int mx[2 * sz], mn[2 * sz];
} S;

int main(){
	scanf("%d%d%d", &n, &m, &q);
	for(int i = 1, x, y; i <= n - 1; i++){
		scanf("%d%d", &x, &y);
		e[x].push_back({y, i});
		e[y].push_back({x, i});
	}
	for(int i = 1; i <= m; i++){
		scanf("%d", ch + i);
		tv[ch[i]].push_back(i);
	}
	if(q == 1){
		scanf("%d", &q);
		printf("%d\n", f1(q, 0, m + 1));
	}
	else{
		puts("0");
		return 0;
	}
}

Compilation message

synchronization.cpp: In function 'int main()':
synchronization.cpp:39:29: 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:41:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d%d", &x, &y);
                        ^
synchronization.cpp:46:22: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", ch + i);
                      ^
synchronization.cpp:50:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d", &q);
                  ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 9144 KB Output is correct
2 Correct 0 ms 9144 KB Output is correct
3 Correct 0 ms 9144 KB Output is correct
4 Correct 0 ms 9144 KB Output is correct
5 Correct 0 ms 9144 KB Output is correct
6 Correct 0 ms 9276 KB Output is correct
7 Correct 9 ms 9804 KB Output is correct
8 Correct 9 ms 9804 KB Output is correct
9 Correct 23 ms 9804 KB Output is correct
10 Incorrect 109 ms 14820 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 46 ms 15268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 9144 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 89 ms 14292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 9144 KB Output isn't correct
2 Halted 0 ms 0 KB -