/ tabris /

记录详情

Runtime Error

/in/foo.cc:1:0: warning: ignoring #pragma comment  [-Wunknown-pragmas]
 #pragma comment(linker, "/STACK:102400000,102400000") 
 
/in/foo.cc: In function 'void dfs(int, int)':
/in/foo.cc:19:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<G[now].size();i++){
                 ~^~~~~~~~~~~~~~
# 状态 耗时 内存占用
#1 Accepted 126ms 19.078 MiB
#2 Runtime Error 68ms 21.344 MiB
#3 Accepted 4ms 3.195 MiB
#4 Accepted 4ms 3.949 MiB
#5 Accepted 4ms 4.57 MiB
#6 Accepted 4ms 2.824 MiB
#7 Accepted 154ms 18.398 MiB
#8 Accepted 25ms 5.547 MiB
#9 Accepted 149ms 16.266 MiB
#10 Accepted 189ms 20.176 MiB

代码

#pragma comment(linker, "/STACK:102400000,102400000") 
#include<bits/stdc++.h>
using namespace std;

const int N = 1e5+5;
const int mod =1000000007;
typedef long long ll;
struct node{
    int v,c;
};

vector<node>G[N];
int cnt[36][N];
ll XOR[N];
int SUM[N];
void dfs(int now,int fa){
    SUM[now]=1;
    for(int i=0;i<=31;i++)if((1ll<<i) & XOR[now])cnt[i][now]++;
    for(int i=0;i<G[now].size();i++){
        node NOW = G[now][i];
        int v = NOW.v,c = NOW.c;
        if(v==fa)continue;
            XOR[v] = XOR[now] ^ c;
            dfs(v,now);
            SUM[now] += SUM[v];
        for(int j=0;j<=31;j++)cnt[j][now] += cnt[j][v];
    }
}


int main(){
//    freopen("in.txt","r",stdin);

    int n;scanf("%d",&n);
    int u,v,c;
    for(int i=1;i<n;i++){
        scanf("%d%d%d",&u,&v,&c);
        G[u].push_back(node{v,c});
        G[v].push_back(node{u,c});
    }
        XOR[1]=0;
        dfs(1,1);
//    for(int i=1;i<=n;i++)printf("%d%c",SUM[i],i==n?'\n':' ');
    for(int i=1;i<=n;i++){
        ll ans = 0;
        for(int j=0;j<=31;j++)ans = (ans + (1ll<<j)*cnt[j][i]%mod*(SUM[i]-cnt[j][i])%mod)%mod;
        printf("%lld ",ans%mod);
    }
    puts("");
    return 0;
}

信息

递交者
类型
递交
语言
C++
递交时间
2019-06-12 20:56:16
评测时间
2019-06-12 20:56:16
评测机
分数
90
总耗时
730ms
峰值内存
21.344 MiB