답안 #889647

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
889647 2023-12-20T04:25:58 Z vjudge1 Tourism (JOI23_tourism) C++17
5 / 100
5000 ms 13756 KB
#include <bits/stdc++.h>
using namespace std;/*
<<<<It's never too late for a new beginning in your life>>>>
Today is hard
  tomorrow will worse
  but the day after tomorrow will be the sunshine..
 
HARD WORK BEATS TALENT WHEN TALENT DOESN'T WORK HARD............
Never give up  */
//The most CHALISHKANCHIK
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define int long long
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vii;
const int N = 2e5+50, inf = 1e18, mod = 1e9+7;
vi g[N];
set<pii> mp, path;
set<int> chk;
void dfs(int pos, int pr){
	if(chk.empty())return;
	if(chk.count(pos) > 0){
		chk.erase(chk.find(pos));
		if(!path.empty()){
			for(auto i:path)mp.insert(i);
		}
	}
	for(auto to:g[pos]){
		if(to == pr)continue;
		path.insert({pos, to});
		dfs(to, pos);
		path.erase(path.find({pos, to}));
	}
}
void solve(){
	int n, m, q, a, b;
	cin >> n >> m >> q;
	for(int i = 0; i < n-1; i++){
		cin >> a >> b;
		g[a].pb(b);
		g[b].pb(a);
	}
	int pl[m+1]{};
	for(int i = 1; i <= m; i++){
		cin >> pl[i];
	}
	while(q--){
		int l, r;
		cin >> l >> r;
		for(int i = l; i <= r; i++)chk.insert(pl[i]);
		dfs(pl[l], -1);
		cout << mp.size()+1 << '\n';
		mp.clear();
		path.clear();
	}
}
main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int t = 1;
	//~ cin >> t;
	while(t--){
		solve();
	}
}

Compilation message

tourism.cpp:61:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   61 | main(){
      | ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 12 ms 5176 KB Output is correct
5 Correct 13 ms 4956 KB Output is correct
6 Correct 10 ms 4956 KB Output is correct
7 Correct 14 ms 4952 KB Output is correct
8 Correct 12 ms 5184 KB Output is correct
9 Correct 25 ms 4956 KB Output is correct
10 Correct 26 ms 5212 KB Output is correct
11 Correct 25 ms 4956 KB Output is correct
12 Correct 43 ms 4956 KB Output is correct
13 Correct 38 ms 4956 KB Output is correct
14 Correct 39 ms 4952 KB Output is correct
15 Correct 96 ms 5212 KB Output is correct
16 Correct 93 ms 5212 KB Output is correct
17 Correct 97 ms 5212 KB Output is correct
18 Correct 68 ms 4956 KB Output is correct
19 Correct 73 ms 5208 KB Output is correct
20 Correct 83 ms 5212 KB Output is correct
21 Correct 13 ms 4956 KB Output is correct
22 Correct 13 ms 5192 KB Output is correct
23 Correct 15 ms 5212 KB Output is correct
24 Correct 13 ms 4956 KB Output is correct
25 Correct 13 ms 4956 KB Output is correct
26 Correct 13 ms 5196 KB Output is correct
27 Correct 1 ms 4996 KB Output is correct
28 Correct 1 ms 4952 KB Output is correct
29 Correct 2 ms 4956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 12 ms 5176 KB Output is correct
5 Correct 13 ms 4956 KB Output is correct
6 Correct 10 ms 4956 KB Output is correct
7 Correct 14 ms 4952 KB Output is correct
8 Correct 12 ms 5184 KB Output is correct
9 Correct 25 ms 4956 KB Output is correct
10 Correct 26 ms 5212 KB Output is correct
11 Correct 25 ms 4956 KB Output is correct
12 Correct 43 ms 4956 KB Output is correct
13 Correct 38 ms 4956 KB Output is correct
14 Correct 39 ms 4952 KB Output is correct
15 Correct 96 ms 5212 KB Output is correct
16 Correct 93 ms 5212 KB Output is correct
17 Correct 97 ms 5212 KB Output is correct
18 Correct 68 ms 4956 KB Output is correct
19 Correct 73 ms 5208 KB Output is correct
20 Correct 83 ms 5212 KB Output is correct
21 Correct 13 ms 4956 KB Output is correct
22 Correct 13 ms 5192 KB Output is correct
23 Correct 15 ms 5212 KB Output is correct
24 Correct 13 ms 4956 KB Output is correct
25 Correct 13 ms 4956 KB Output is correct
26 Correct 13 ms 5196 KB Output is correct
27 Correct 1 ms 4996 KB Output is correct
28 Correct 1 ms 4952 KB Output is correct
29 Correct 2 ms 4956 KB Output is correct
30 Correct 627 ms 5312 KB Output is correct
31 Correct 833 ms 5456 KB Output is correct
32 Correct 1320 ms 5212 KB Output is correct
33 Correct 1338 ms 5384 KB Output is correct
34 Correct 1284 ms 5384 KB Output is correct
35 Correct 2461 ms 5384 KB Output is correct
36 Correct 2480 ms 5632 KB Output is correct
37 Correct 2568 ms 5376 KB Output is correct
38 Execution timed out 5050 ms 5684 KB Time limit exceeded
39 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 4 ms 4952 KB Output is correct
4 Execution timed out 5072 ms 13756 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Execution timed out 5071 ms 7628 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 3 ms 4956 KB Output is correct
4 Execution timed out 5048 ms 11352 KB Time limit exceeded
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Correct 12 ms 5176 KB Output is correct
5 Correct 13 ms 4956 KB Output is correct
6 Correct 10 ms 4956 KB Output is correct
7 Correct 14 ms 4952 KB Output is correct
8 Correct 12 ms 5184 KB Output is correct
9 Correct 25 ms 4956 KB Output is correct
10 Correct 26 ms 5212 KB Output is correct
11 Correct 25 ms 4956 KB Output is correct
12 Correct 43 ms 4956 KB Output is correct
13 Correct 38 ms 4956 KB Output is correct
14 Correct 39 ms 4952 KB Output is correct
15 Correct 96 ms 5212 KB Output is correct
16 Correct 93 ms 5212 KB Output is correct
17 Correct 97 ms 5212 KB Output is correct
18 Correct 68 ms 4956 KB Output is correct
19 Correct 73 ms 5208 KB Output is correct
20 Correct 83 ms 5212 KB Output is correct
21 Correct 13 ms 4956 KB Output is correct
22 Correct 13 ms 5192 KB Output is correct
23 Correct 15 ms 5212 KB Output is correct
24 Correct 13 ms 4956 KB Output is correct
25 Correct 13 ms 4956 KB Output is correct
26 Correct 13 ms 5196 KB Output is correct
27 Correct 1 ms 4996 KB Output is correct
28 Correct 1 ms 4952 KB Output is correct
29 Correct 2 ms 4956 KB Output is correct
30 Correct 627 ms 5312 KB Output is correct
31 Correct 833 ms 5456 KB Output is correct
32 Correct 1320 ms 5212 KB Output is correct
33 Correct 1338 ms 5384 KB Output is correct
34 Correct 1284 ms 5384 KB Output is correct
35 Correct 2461 ms 5384 KB Output is correct
36 Correct 2480 ms 5632 KB Output is correct
37 Correct 2568 ms 5376 KB Output is correct
38 Execution timed out 5050 ms 5684 KB Time limit exceeded
39 Halted 0 ms 0 KB -