10643 | 2024-04-07 16:56:35 | 111 | XORfa visszatér | cpp17 | Time limit exceeded 11/100 | 1.582s | 34132 KiB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N,Q;
cin>>N>>Q;
vector<vector<pair<int,int>>>g(N+1);
for(int i=0;i<N-1;i++){
int a,b,w;
cin>>a>>b>>w;
g[a].emplace_back(b,w);
g[b].emplace_back(a,w);
}
vector<int>v(N+1);
auto dfs=[&](auto self,int i,int p,int x)->void{
v[i]=x;
for(auto[j,w]:g[i]){
if(j==p){
continue;
}
self(self,j,i,x^w);
}
};
dfs(dfs,1,0,0);
set<int>s;
while(Q--){
int x;
cin>>x;
if(!s.insert(x).second){
s.erase(x);
}
int ans=0;
for(int i:s){
for(int j:s){
ans=max(ans,v[i]^v[j]);
}
}
cout<<ans<<'\n';
}
return 0;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Accepted | 3ms | 1824 KiB | ||||
2 | Accepted | 3ms | 2056 KiB | ||||
subtask2 | 11/11 | ||||||
3 | Accepted | 3ms | 2244 KiB | ||||
4 | Accepted | 3ms | 2472 KiB | ||||
5 | Accepted | 4ms | 2448 KiB | ||||
6 | Accepted | 3ms | 2536 KiB | ||||
7 | Accepted | 3ms | 2584 KiB | ||||
8 | Accepted | 3ms | 2928 KiB | ||||
9 | Accepted | 3ms | 2884 KiB | ||||
10 | Accepted | 4ms | 3144 KiB | ||||
11 | Accepted | 4ms | 3104 KiB | ||||
12 | Accepted | 4ms | 3104 KiB | ||||
13 | Accepted | 4ms | 3108 KiB | ||||
subtask3 | 0/13 | ||||||
14 | Accepted | 46ms | 12552 KiB | ||||
15 | Accepted | 61ms | 13480 KiB | ||||
16 | Time limit exceeded | 1.572s | 9704 KiB | ||||
17 | Time limit exceeded | 1.582s | 10548 KiB | ||||
18 | Time limit exceeded | 1.578s | 11784 KiB | ||||
19 | Time limit exceeded | 1.547s | 12808 KiB | ||||
20 | Time limit exceeded | 1.55s | 13720 KiB | ||||
21 | Time limit exceeded | 1.559s | 14836 KiB | ||||
22 | Accepted | 61ms | 20652 KiB | ||||
23 | Accepted | 61ms | 21652 KiB | ||||
subtask4 | 0/17 | ||||||
24 | Accepted | 254ms | 13732 KiB | ||||
25 | Accepted | 57ms | 13796 KiB | ||||
26 | Accepted | 663ms | 13776 KiB | ||||
27 | Accepted | 1.358s | 13712 KiB | ||||
28 | Time limit exceeded | 1.567s | 13056 KiB | ||||
29 | Accepted | 201ms | 14064 KiB | ||||
30 | Accepted | 312ms | 14108 KiB | ||||
31 | Accepted | 317ms | 14372 KiB | ||||
32 | Time limit exceeded | 1.57s | 13720 KiB | ||||
33 | Time limit exceeded | 1.582s | 13744 KiB | ||||
34 | Time limit exceeded | 1.565s | 14576 KiB | ||||
35 | Time limit exceeded | 1.557s | 13820 KiB | ||||
subtask5 | 0/59 | ||||||
36 | Time limit exceeded | 1.567s | 19224 KiB | ||||
37 | Time limit exceeded | 1.575s | 20348 KiB | ||||
38 | Time limit exceeded | 1.56s | 21468 KiB | ||||
39 | Time limit exceeded | 1.56s | 22804 KiB | ||||
40 | Time limit exceeded | 1.564s | 24300 KiB | ||||
41 | Time limit exceeded | 1.567s | 25572 KiB | ||||
42 | Time limit exceeded | 1.547s | 26740 KiB | ||||
43 | Time limit exceeded | 1.572s | 28072 KiB | ||||
44 | Time limit exceeded | 1.544s | 29328 KiB | ||||
45 | Time limit exceeded | 1.564s | 30816 KiB | ||||
46 | Time limit exceeded | 1.559s | 31720 KiB | ||||
47 | Time limit exceeded | 1.567s | 32500 KiB | ||||
48 | Time limit exceeded | 1.539s | 33456 KiB | ||||
49 | Time limit exceeded | 1.544s | 34132 KiB |