题意
Solution
压位+前缀和
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
![](https://images.cnblogs.com/OutliningIndicators/ExpandedBlockStart.gif)
1 #include2 #include 3 #include 4 #include 5 #define ll int 6 using namespace std; 7 const ll mod=100000007; 8 inline void read(ll &k) 9 {10 ll f=1;char c=getchar();k=0;11 while (c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();12 while (c>='0'&&c<='9')k=k*10+c-'0',c=getchar();13 k*=f;14 }15 const int maxn=1000010;16 ll n,q,k,aa,bb,cc;17 ll last[maxn],next[maxn],tot,c[maxn],to[maxn],sum[maxn];long long cost[233];18 bool v[maxn];19 void dfs(ll now,ll fa)20 {21 v[now]=1;ll cur=last[now];22 while (cur)23 {24 if (!v[to[cur]])25 {26 sum[to[cur]]=sum[now]^(1<<(c[cur]-1));27 dfs(to[cur],now);28 }29 cur=next[cur];30 } 31 }32 int main()33 {34 freopen("mahou.in","r",stdin);35 freopen("mahou.out","w",stdout);36 read(n);read(q);read(k);37 // printf("..............qaq%lld%lld%lld\n",n,q,k);38 for (int i=1;i