# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
778649 |
2023-07-10T14:14:32 Z |
vjudge1 |
Deblo (COCI18_deblo) |
C++17 |
|
1000 ms |
14476 KB |
#include<iostream>
#include <vector>
#include <bitset>
using namespace std;
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define ll long long
#define pb push_back
#define N 100001
int arr[N];
vector<int> adj[N];
bitset<100001>isaret;
ll int dfs(int x,int once,int prevgel){
ll int topla=0;
if(isaret[x]==0)topla=prevgel^arr[x];
for(auto u:adj[x]){
if(u==once) continue;
topla+=dfs(u,x,prevgel^arr[x]);
}
return topla;
}
vector<int> yol;
void uff(int x,int once){
for(auto u:adj[x]){
if(u!=once)uff(u,x);
}
yol.pb(x);
}
int main(){
lalala;
int n;cin>>n;
for(int i=1;i<=n;i++)cin>>arr[i];
for(int i=0;i<n-1;i++){
int a,b;cin>>a>>b;
adj[a].pb(b);
adj[b].pb(a);
}
uff(1,0);
ll int cev=0;
for(int i=yol.size()-1;i>-1;i--){
cev+=dfs(yol[i],-1,0);
isaret[yol[i]]=1;
}
cout<<cev<<"\n";
}
Compilation message
deblo.cpp:6: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
6 | #pragma GCC optimization ("O3")
|
deblo.cpp:7: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
7 | #pragma GCC optimization ("unroll-loops")
|
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2660 KB |
Output is correct |
3 |
Correct |
1 ms |
2644 KB |
Output is correct |
4 |
Correct |
7 ms |
2644 KB |
Output is correct |
5 |
Correct |
10 ms |
2720 KB |
Output is correct |
6 |
Execution timed out |
1078 ms |
14476 KB |
Time limit exceeded |
7 |
Execution timed out |
1033 ms |
14404 KB |
Time limit exceeded |
8 |
Execution timed out |
1072 ms |
8152 KB |
Time limit exceeded |
9 |
Execution timed out |
1088 ms |
7480 KB |
Time limit exceeded |
10 |
Execution timed out |
1077 ms |
6856 KB |
Time limit exceeded |