2019.10.10口胡题

D1T1

``` 1 #include
2 #include
3 #include
4 #include
5 #include
6 #include
7 #define int long long
8 using namespace std;
9 const int N=1e6+10,mod=1e9+7;
12 {
13         register int sum,k=1;register char s;
14         while(s=getchar(),s<'0'||s>'9') if(s=='-') k=-1;sum=s-'0';
15         while(s=getchar(),s>='0'&&s<='9') sum=sum*10+s-'0';
16         return k*sum;
17 }
19 {
20         to[++tot]=y;
23 }
24 void dfs(int x,int fa)
25 {
26         f[x]=fa;
28         {
29                 int y=to[i];
30                 if(y==fa) continue;
31                 g[x]^=a[y];
32                 if(fa) s[fa]^=a[y];
33                 dfs(y,x);
34         }
35 }
36 signed main()
37 {
38         freopen("1.in","r",stdin);
39         freopen("1.out","w",stdout);
42         for(int i=1,x,y;i)
43         {
46         }
47         dfs(1,0);
48         for(int i=1,x,y,cnt;i<=m;i++)
49         {
51                 if(f[x]) g[f[x]]^=a[x]^y;
52                 if(f[f[x]]) s[f[f[x]]]^=a[x]^y;
53                 a[x]=y;
54                 cnt=a[x]^s[x]^g[x]^a[f[x]]^a[f[f[x]]];
55                 if(f[x]) cnt^=g[f[x]]^a[x];
56                 sum=(sum+(i*i%mod)*cnt%mod)%mod;
57         }
58         printf("%lld",sum);
59         return 0;
60 }```
T1

D1T2

D1T3

D2T1

D2T2T3