We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
#include<bits/stdc++.h>usingnamespacestd;#define int64 unsigned long long intint64prime=1000000007ULL;int64bin[1001][1001];int64binsum[1001][1001];intcs[1001][1001];int64power(int64abase,int64aexp){int64base=abase;int64exp=aexp;int64res=1;while(exp>0ULL){if(exp%2ULL==1ULL)res=(res*base)%prime;base=(base*base)%prime;exp/=2ULL;}returnres%prime;}int64fast_chi(intn,intm,intc){if(c==n){if((m+1)%2==0)return1ULL;elsereturn(prime-1ULL);}else{intlower_limit;intupper_limit;if((c<=m)&&(c<=(n-m+1))){lower_limit=1;upper_limit=c;}elseif((c>m)&&(c<=(n-m+1))){lower_limit=1;upper_limit=m;}elseif((c<=m)&&(c>(n-m+1))){lower_limit=c-(n-m);upper_limit=c;}else{lower_limit=c-(n-m);upper_limit=m;}int64lower_sum=0ULL;int64upper_sum=0ULL;int64answer;for(intx=lower_limit;x<(upper_limit+1);x+=2)lower_sum=(lower_sum+bin[n-c][m-x])%prime;if(lower_limit<upper_limit)for(intx=lower_limit+1;x<(upper_limit+1);x+=2)upper_sum=(upper_sum+bin[n-c][m-x])%prime;if((lower_limit+1)%2==0)answer=(lower_sum+((upper_sum*(prime-1))%prime))%prime;elseanswer=(upper_sum+((lower_sum*(prime-1))%prime))%prime;int64banswer=binsum[n-c][m-lower_limit];if(upper_limit<m)banswer+=(((prime-1)*binsum[n-c][m-upper_limit-1])%prime);if(m%2==0)banswer=(banswer*(prime-1))%prime;returnbanswer;}}int64chi(intn,intm,intc){if(2*m<(n+1)){if(c==1)returnbin[n-1][m-1];elseif(c<=m){int64total=0ULL;for(inti=0;i<c;i++){intx=i+1;if((x+1)%2==0)total=(total+bin[n-c][m-x])%prime;else{int64add=(bin[n-c][m-x]*(prime-1ULL))%prime;total=(total+add)%prime;}}returntotal;}elseif((c>m)&&(c<=(n-m+1))){int64total=0ULL;for(inti=0;i<m;i++){intx=i+1;if((x+1)%2==0)total=(total+bin[n-c][m-x])%prime;else{int64add=(bin[n-c][m-x]*(prime-1ULL))%prime;total=(total+add)%prime;}}returntotal;}elseif((c>(n-m+1))&&(c<n)){int64total=0ULL;for(intx=c-(n-m);x<(m+1);x++){if((x+1)%2==0)total=(total+bin[n-c][m-x])%prime;else{int64add=(bin[n-c][m-x]*(prime-1ULL))%prime;total=(total+add)%prime;}}returntotal;}else{if((m+1)%2==0)return1ULL;elsereturn(prime-1ULL);}}else{if(c==1)returnbin[n-1][m-1];elseif(c<=(n-m+1)){int64total=0ULL;for(inti=0;i<c;i++){intx=i+1;if((x+1)%2==0)total=(total+bin[n-c][m-x])%prime;else{int64add=(bin[n-c][m-x]*(prime-1ULL))%prime;total=(total+add)%prime;}}returntotal;}elseif((c>(n-m+1))&&(c<=m)){int64total=0ULL;for(intx=c-(n-m);x<(c+1);x++){if((x+1)%2==0)total=(total+bin[n-c][m-x])%prime;else{int64add=(bin[n-c][m-x]*(prime-1ULL))%prime;total=(total+add)%prime;}}returntotal;}elseif((c>m)&&(c<n)){int64total=0ULL;for(intx=c-(n-m);x<(m+1);x++){if((x+1)%2==0)total=(total+bin[n-c][m-x])%prime;else{int64add=(bin[n-c][m-x]*(prime-1ULL))%prime;total=(total+add)%prime;}}returntotal;}else{if((m+1)%2==0)return1ULL;elsereturn(prime-1ULL);}}}int64get_trace(intn,intm,inttrial){int64total=1;int64len_c=0ULL;for(inti=0;i<1001;i++){intexponent=cs[trial][i];if(exponent>0){int64base=fast_chi(n,m,i);int64ull_exp=(int64)exponent;len_c+=ull_exp;int64multiplier=power(base,ull_exp);total=(total*multiplier)%prime;}}int64dimension=fast_chi(n,m,1);total=(total*dimension)%prime;total=(total*chi(n,m,n))%prime;int64divisor=power(dimension,len_c);total=(total*power(divisor,prime-2))%prime;returntotal;}int64get_conjugacy_class_size(intn,intc){if(c==1)return1ULL;else{int64total=bin[n][c];for(inti=1;i<c;i++){int64multiplier=(int64)i;total=(total*multiplier)%prime;}returntotal;}}int64get_multiplier(intn,inttrial){int64long_n=(int64)n;int64answer=power(long_n,prime-2ULL);for(inti=0;i<1001;i++){intexponent=cs[trial][i];if(exponent>0){int64long_exp=(int64)exponent;int64base=get_conjugacy_class_size(n,i);answer=(answer*power(base,long_exp))%prime;}}returnanswer;}int64get_enumeration(intn,inttrial){int64total=0ULL;for(inti=1;i<(n+1);i++)total=(total+get_trace(n,i,trial))%prime;int64mult=get_multiplier(n,trial);total=(total*mult)%prime;returntotal;}intmain(){intT;cin>>T;for(inti=0;i<T;i++)for(intj=0;j<T;j++)cs[i][j]=0;intns[T];intms[T];for(inti=0;i<T;i++){intm;cin>>ns[i]>>m;ms[i]=m;for(intj=0;j<m;j++){intk;cin>>k;cs[i][k]+=1;}}intmax_n=0;for(inti=0;i<T;i++)if(ns[i]>max_n)max_n=ns[i];for(inti=0;i<(max_n+1);i++){for(intj=0;j<(i+1);j++){if(j==0)bin[i][j]=1ULL;elseif(j==i)bin[i][j]=1ULL;elsebin[i][j]=(bin[i-1][j]+bin[i-1][j-1])%prime;}}for(inti=0;i<(max_n+1);i++){for(intj=0;j<(i+1);j++){if(j==0)binsum[i][j]=1ULL;else{int64adder;if(j%2==0)adder=bin[i][j];elseadder=(bin[i][j]*(prime-1))%prime;binsum[i][j]=(binsum[i][j-1]+adder)%prime;}}}for(inti=0;i<T;i++){int64answer=get_enumeration(ns[i],i);cout<<answer<<endl;}return0;}
Quite interesting and valuable update for the students to avail the programming solutions. I truly admire the best essay writing service in usa help here that would be wise. Please continue with your further helping material please do share more.
C++ solution
Quite interesting and valuable update for the students to avail the programming solutions. I truly admire the best essay writing service in usa help here that would be wise. Please continue with your further helping material please do share more.
When i submit my code it continuously says it is processing. It never shows a timed out symbol or a wrong answer symbol. What's going on?