2021 "MINIEYE" cup Chinese college students algorithm design Super League

Game record 2021 / 10 / 6 Reference acknowledgment Field ...

Game record 2021 / 10 / 6

Reference acknowledgment

Field question A  

1010Smzzl with Tropical Taste

Main idea of the topic: there is iced black tea with a volume of V in a pool. The shop owner will pour iced black tea into the pool at the speed of qV per second, while another person drinks iced black tea at the speed of pV per second. Ask whether there is always time t for any iced black tea g, so that when t is greater than t, the number of iced black tea is greater than G.

Problem solving idea: the speed of drinking iced black tea per second is positively correlated with the speed and volume of iced black tea. When the speed of drinking is greater than the speed of adding, there will certainly be a time to finish drinking. At this time, the speed of adding becomes 0. All conditions must not be met. Only when the speed of adding is greater than or equal to the speed of drinking can iced black tea not be reduced or even more.

1007 base ring tree

Link with Limit If you build a graph and connect points to points and edges, the iterative process is essentially a process of walking on the graph. The original question is actually about each ring Whether the average value of point weight is the same, use any method to find all rings and find the average value. Post the beautiful base ring tree in the standard process to find the ring
#include <stdio.h> #include <queue> #define MN 100000 typedef long long ll; int n,a[MN+5],din[MN+5]; void solve(){ scanf("%d",&n); for(int i=1;i<=n;i++){ din[i] = 0; } for(int i=1;i<=n;i++){ scanf("%d",&a[i]); din[a[i]]++; } std::queue<int> Q;//A queue is a queue for(int i=1;i<=n;i++){ if(din[i]==0) Q.push(i); } while(!Q.empty()){ int u = Q.front(); Q.pop(); din[a[u]]--; if(din[a[u]]==0){ Q.push(a[u]); } } ll p=-1,q=-1; for(int i=1;i<=n;i++){ if(din[i]==0) continue; ll tp=0,tq=0; for(;din[i];i=a[i]){ tp += i; tq++; din[i] = 0; } if(p==-1){ p = tp; q = tq; }else{ if(p*tq!=q*tp){ puts("NO"); return; } } } puts("YES"); return; } int main(){ int T; scanf("%d",&T); while(T--) solve(); }

For ring finding, it is generally good to directly dfs. You can open a stack and save it

1003C (equal difference and equal ratio formula)

1004D feels like a clever math problem

1004 Link with Balls

Is to give 2n baskets, of which n can take multiple of i and the other n can take 0~i.

Then let you find the number of m schemes.

  Combination number template

#include<bits/stdc++.h> #define N 2000010 #define ll long long using namespace std; const int mod=1e9+7; ll Pow(ll x,int y)return ans;} ll fac[N],ifac[N]; void init(){ fac[0]=1; for(int i=1;i<N;i++)fac[i]=fac[i-1]*i%mod; ifac[N-1]=Pow(fac[N-1],mod-2); for(int i=N-2;i>=0;i--)ifac[i]=ifac[i+1]*(i+1)%mod; } ll C(int n,int m){ if(m<0||n<m)return 0; return fac[n]*ifac[m]%mod*ifac[n-m]%mod; } int main(){ init(); int T,n,m; scanf("%d",&T); while(T--){ scanf("%d%d",&n,&m); if(n<m) printf("%lld\n",(C(n+m,n)-C(m-1,n)+mod)%mod); else printf("%lld\n",C(n+m,n)); } return 0; }

1005 Link with EQ

The problem is too real.

Note that as long as you don't choose seat x ∈ the first and N seats will be taken sooner or later. And it must be the first choice on both sides of X (like sitting in the corner). Then the remaining problem is actually the problem of being a man in a continuous empty interval with people on the left side of the leftmost vacancy and the right side of the rightmost vacancy.

When there are people sitting on both sides and no one in the middle, we can consider it recursively  

1012

Find the value of all substrings with each letter as the last letter, and consider it according to different letters

For every additional letter, if this is the i-th letter, I will be added to the number of substrings of the whole string. At this time, just calculate the contribution of the I-New strings to the answer

#include<bits/stdc++.h> using namespace std; #define int long long const int maxn=1e5+5; const int mod=998244353; int T,n,m,ans,len,x; int tot[maxn],sum[maxn]; char s[200000]; signed main() { scanf("%lld",&T); while(T--) { scanf("%s",s+1); len=strlen(s+1); int ans=0; for (int i=1;i<=len;i++) { int x=s[i]-'a'; if (i==1) { sum[x]=1; tot[x]=1;} else { for (int j=0;j<=25;j++) ans=(ans+sum[j])%mod; sum[x]+=(2*tot[x] % mod +i)%mod; sum[x]=sum[x]%mod; tot[x]+=i; tot[x]%=mod; } } for(int i=0; i<26; i++) ans=(ans+sum[i])%mod; printf("%lld\n",ans); memset(tot,0,sizeof tot); memset(sum,0,sizeof sum); } return 0; }


1011

Divide and conquer ntt

6 October 2021, 11:09 | Views: 6418

Add new comment

For adding a comment, please log in
or create account

0 comments