牛客在哪里可以提交?发个链接好吗
by Chavapa @ 2019-11-16 15:38:57
@[Chavapa](/user/82593) https://ac.nowcoder.com/acm/contest/2344/
by ZhuMingYang @ 2019-11-16 15:44:28
@[ZhuMingYang](/user/128523)
by LHQing @ 2019-11-16 15:49:08
您代码哪来的
by LHQing @ 2019-11-16 15:49:17
您代码哪来的
@[ZhuMingYang](/user/128523)
by LHQing @ 2019-11-16 15:50:02
您代码哪来的
@[ZhuMingYang](/user/128523)
您代码哪来的
@[ZhuMingYang](/user/128523)
by LHQing @ 2019-11-16 15:52:28
@[LHQing](/user/167507) 重写的
by ZhuMingYang @ 2019-11-16 15:52:51
%orz
by LHQing @ 2019-11-16 15:53:53
@[ZhuMingYang](/user/128523)
因为我注册不了号,所以您可以将这份暴力在牛客和oitiku上测一下吗,THANKS
```
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
struct Node
{
int vl;
int fa;
vector<int> sn;
};Node a[500001];
int n;
int gt()
{
char c=getchar();
while(c!='('&&c!=')')
c=getchar();
if(c=='(')
return 1; return -1;
}
long long ret=0;
int c[500001],ct=0;
void dfs(int nw,int ls)
{
c[++ct]=a[nw].vl;
int tot=0;
for(int i=ct;i>=1;i--)
{
tot+=c[i];
if(tot>0)
break;
if(tot==0)
ls++;
}
//cout<<"nw="<<nw<<" "<<"ls="<<ls<<endl;
ret^=(long long)nw*ls;
for(int i=0;i<a[nw].sn.size();i++)
dfs(a[nw].sn[i],ls);
ct--; return ;
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
a[i].vl=gt();
for(int i=2;i<=n;i++)
{
scanf("%d",&a[i].fa);
a[a[i].fa].sn.push_back(i);
}
dfs(1,0);
printf("%lld\n",ret);
return 0;
}
```
by LHQing @ 2019-11-16 16:18:24
@[ZhuMingYang](/user/128523)
我牛客80分?艹!
请帮忙测一下oitiku,THANKS
by LHQing @ 2019-11-16 16:30:21