J题被卡95% 感觉没错啊 自闭了 求bug

//code: #include<bits/stdc++.h> using namespace std; typedef long long ll; const ll mod = 1e9+7; const int maxn=1e5+100; int w[maxn]; vector<int>v[maxn];
int main() {     int n;     scanf("%d",&n);
    for(int i=2;i<=n;i++){         int x;         scanf("%d %d",&x,&w[i]);         v[x].push_back(i);     }
    w[1]=0;     queue<int>q;     q.push(1);     while(!q.empty()){         int root=q.front();         int len=v[root].size();         if(len)             for(int i=0;i<len;i++){                 int p=v[root][i];                 q.push(p);                 w[p]^=w[root];
            }         q.pop();     }     ll ans=0;     int ret;     for(int i=0;i<20;i++){         ret=0;         for(int j=1;j<=n;j++){             if((w[j]>>i)&1)                 ret++;         }         ans+=(1LL<<i)*(1LL*(ret)*(1LL*n-ret));         ans%=mod;     }     ans<<=1;     ans%=mod;     printf("%d\n",ans);     return 0; }
//这么写为什么只能过95%的样例啊,哭了orz

全部评论
数据有锅AC代码再输入的时候加一个 if(p>=i){     while(1){     } } 就会超时,得证数据并不满足输入描述中的pi<i
点赞 回复
分享
发布于 2019-06-06 13:04
我也是这样子。比赛时就WA了十多次,赛后又改来改去WA了不下三十次,检查到自闭。 应该是有个不合法的数据 if (p==i) return 1; 就会返回RE 这个数据不是一棵树,是不合法的。 询问管理员,管理员说修正了错误。但是现在提交还是同样的问题。
点赞 回复
分享
发布于 2019-06-15 20:40
联易融
校招火热招聘中
官网直投
感谢牛客管理员 这个问题现在应该解决了
点赞 回复
分享
发布于 2019-06-18 12:14

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务