Score'd still so bad, but this time more strange.
T1,15 minutes 49 seconds 6 minutes to come up with the 50 points T2 brought violence, less than an hour and a half time of 30 minutes T3 violence also completed. . .
Once submitted after 85 minutes no
15 minutes before the 10 points per minute average, three hours after 10 points per hour. . .
If the exam had only 16 minutes, I absolutely rank1 and can pull a second mile.
However, these are my yy, not the final exam was nothing it. . .
To two hours after, what I could not think, listen to someone yards, watching others get points that he sit still, a little desperate. . .
OJ way also died to see the results of the evaluation, the evaluation interface hang in the open on top of this thing is probably
T2 I think a lifetime is also thought out ah ah ah. . .
But I did not want to face I see my score. After the game look, ah, really not more than a minute. . .
However, Group B T2 original packaging is actually a bit of problem, or am I out of the examination room A, it will not actually do
I do not know the status of the problem or how
Training more than half. . .
Tense it. . .
T1: Maximum XOR and
Each node is taken away. So the last two people together is the score XOR XOR and all nodes.
If the total XOR is a bit on 0 and then two people score this one necessarily the same, will not pull out a gap.
Otherwise, this is a must win position, who is 1 whoever wins on this one.
However, small Q can choose their own node, and select any one of these is on a node 1, he will win.
If you do not must win position, namely XOR is zero, that is a draw.
1 #include<cstdio> 2 int main(){ 3 int t,n,X;scanf("%d",&t); 4 while(t--){ 5 scanf("%d",&n);X=0; 6 for(int i=1,x;i<=n;++i)scanf("%d",&x),X^=x; 7 for(int i=1,x,y;i<n;++i)scanf("%d%d",&x,&y); 8 puts(X?"Q":"D"); 9 } 10 }
T2: Simple brackets sequence
1 #include<cstdio> 2 #define mod 1000000007 3 int min(int a,int b){return a<b?a:b;} 4 int fac[200005],inv[200005],invv[200005],n,pre[200005],suf[200005],ans;char s[200005]; 5 int C(int b,int t){return 1ll*fac[b]*inv[t]%mod*inv[b-t]%mod;} 6 main(){ 7 scanf("%s",s+1);while(s[n+1])n++; 8 fac[0]=fac[1]=inv[1]=inv[0]=invv[1]=1; 9 for(int i=2;i<=n;++i)fac[i]=1ll*fac[i-1]*i%mod,invv[i]=mod-1ll*mod/i*invv[mod%i]%mod,inv[i]=1ll*inv[i-1]*invv[i]%mod; 10 for(int i=1;i<=n;++i)pre[i]=pre[i-1]+(s[i]=='('); 11 for(int i=n;i;--i)suf[i]=suf[i+1]+(s[i]==')'); 12 for(int i=1;i<=n;++i)if(s[i]==')')for(int j=1;j<=min(pre[i],suf[i]);++j) 13 ans=(ans+1ll*C(pre[i],j)*C(suf[i]-1,j-1))%mod; 14 printf("%d\n",ans); 15 }
Bottleneck expression $ \ sum \ limits_ {i = 1} ^ {min (pre, suf)} C_ {pre} ^ {i} \ times C_ {suf-1} ^ {i-1} $
$=\sum\limits_{i=1}^{min(pre,suf)}C_{pre}^{pre-i} \times C_{suf-1}^{i-1}$
Jujube two problems can be understood from the meaning: is $ C_ {pre + suf-1} ^ {pre-1} $
1 #include<cstdio> 2 #define mod 1000000007 3 int min(int a,int b){return a<b?a:b;} 4 int fac[200005],inv[200005],invv[200005],n,pre[200005],suf[200005],ans;char s[200005]; 5 int C(int b,int t){return 1ll*fac[b]*inv[t]%mod*inv[b-t]%mod;} 6 main(){ 7 scanf("%s",s+1);while(s[n+1])n++; 8 fac[0]=fac[1]=inv[1]=inv[0]=invv[1]=1; 9 for(int i=2;i<=n;++i)fac[i]=1ll*fac[i-1]*i%mod,invv[i]=mod-1ll*mod/i*invv[mod%i]%mod,inv[i]=1ll*inv[i-1]*invv[i]%mod; 10 for(int i=1;i<=n;++i)pre[i]=pre[i-1]+(s[i]=='('); 11 for(int i=n;i;--i)suf[i]=suf[i+1]+(s[i]==')'); 12 for(int i=1;i<=n;++i)if(s[i]==')')for(int j=1;j<=min(pre[i],suf[i]);++j) 13 ans=(ans+1ll*C(pre[i],j)*C(suf[i]-1,j-1))%mod; 14 printf("%d\n",ans); 15 }
T3: travel plans
Figure very dense, difficult to think of a matrix.
But this is not a power of multiplying fast, but block pretreatment.
Step 100 is a. Processing matrix P0 [i] [j] [k] i represents the shortest distance j from the step k.
p1 [i] [j] [k] represents a step 100i. p2 [i] [j] [k] represents at least steps i.
Note p0 and p2 to be processed to 150 instead of 100, when you need p2 [99] [x] [y] while it's true the number of steps may be greater than 100 and you do not then you deal with the WA90.
1 #include<cstdio> 2 #include<cstring> 3 using namespace std; 4 int min(int a,int b){return a<b?a:b;} 5 int dp0[155][52][52],dp1[105][52][52],dp2[155][52][52],E[52][52],r[52][52],n,m,q,x,y,v; 6 int main(){ 7 scanf("%d%d",&n,&m); 8 memset(E,0x3f,sizeof E);memset(dp0,0x3f,sizeof dp0); 9 memset(dp1,0x3f,sizeof dp1);memset(dp2,0x3f,sizeof dp2); 10 for(int i=1;i<=m;++i)scanf("%d%d%d",&x,&y,&v),E[x][y]=min(E[x][y],v); 11 for(int i=1;i<=n;++i)dp0[0][i][i]=dp1[0][i][i]=0; 12 for(int i=1;i<=150;++i)for(int j=1;j<=n;++j)for(int k=1;k<=n;++k)for(int l=1;l<=n;++l) 13 dp0[i][j][k]=min(dp0[i][j][k],dp0[i-1][j][l]+E[l][k]); 14 for(int i=1;i<=100;++i)for(int j=1;j<=n;++j)for(int k=1;k<=n;++k)for(int l=1;l<=n;++l) 15 dp1[i][j][k]=min(dp1[i][j][k],dp1[i-1][j][l]+dp0[100][l][k]); 16 for(int i=1;i<=n;++i)for(int j=1;j<=n;++j)for(int k=150;~k;--k) 17 dp2[k][i][j]=min(dp2[k+1][i][j],dp0[k][i][j]); 18 scanf("%d",&q); 19 while(q--){ 20 scanf("%d%d%d",&x,&y,&v);int ans=1000000000; 21 for(int i=1;i<=n;++i)ans=min(ans,dp1[v/100][x][i]+dp2[v%100][i][y]); 22 printf("%d\n",ans>900000000?-1:ans); 23 } 24 }