# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
778437 | 2023-07-10T10:16:49 Z | vjudge1 | Deblo (COCI18_deblo) | C++17 | 92 ms | 65536 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define faster ios_base::sync_with_stdio(false);cin.tie(NULL); #define OYY 1000000005 #define mod 998244353 #define mid (start+end)/2 int dizi[100005],n,cev=0; vector <int> v[100005]; int dp[100005][35][2]; //// left-shifting an integer “a” with an integer “b” denoted as ‘(a<<b)’ is equivalent to multiplying a with 2^b //// right-shifting an integer “a” with an integer “b” denoted as ‘(a>>b)‘ is equivalent to dividing a with 2^b. //// a=a/(2^b) inline int fast(int x,int y){ int ans=1; x%=mod; while(y!=0){ if(y&1!=0)ans*=x; x*=x; y>>=1; } return ans; } inline int bit(int x,int y){ } inline void dfs(int node,int ata){ for(int i=0;i<32;i++) { if((dizi[node]>>i)%2==1)dp[node][i][1]=1; else dp[node][i][0]=1; } /*for(int i=0;i<20;i++){ cout<<dp[node][i][0]<<" "<<dp[node][i][1]<<endl; }*/ for(int i=0;i<v[node].size();i++){ int go=v[node][i]; if(go==ata)continue; dfs(go,node); for(int j=0;j<32;j++){ int l=dp[go][j][1]; int r=dp[go][j][0]; // int hu=max(l*dp[node][j][0],r*dp[node][j][1]); int hu=(l*dp[node][j][0]+r*dp[node][j][1]); //cev+=hu;// cev+=(hu<<j); /* int gec=(hu<<j); cout<<gec<<endl;*/ int k=(dizi[node]>>j)&1; //cout<<k<<endl; dp[node][j][k]+=r; dp[node][j][k^1]+=l; //cout<<dp[node][j][k]<<" "<<dp[node][j][k^1]<<endl; } } } int32_t main(){ faster cin>>n; int c=0; for(int i=1;i<=n;i++){ cin>>dizi[i]; cev+=dizi[i]; } for(int i=1;i<n;i++){ int a,b; cin>>a>>b; v[a].push_back(b); v[b].push_back(a); } dfs(1,-1); cout<<cev<<'\n'; return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2644 KB | Output is correct |
2 | Correct | 1 ms | 2644 KB | Output is correct |
3 | Correct | 1 ms | 2772 KB | Output is correct |
4 | Correct | 3 ms | 3284 KB | Output is correct |
5 | Correct | 2 ms | 3284 KB | Output is correct |
6 | Runtime error | 59 ms | 65536 KB | Execution killed with signal 9 |
7 | Runtime error | 56 ms | 65536 KB | Execution killed with signal 9 |
8 | Correct | 75 ms | 63444 KB | Output is correct |
9 | Correct | 71 ms | 62684 KB | Output is correct |
10 | Correct | 92 ms | 61900 KB | Output is correct |