版本比较
2026.5.1 Happy Labor Day mock competition
正文
增加 198 行删除 32 行
1234567891011121324 行未改动3839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828317 行未改动10110210310410510610710810911011111253 行未改动1661671681691701711721731741751761771781791801811821831841851861871881891901916 行未改动# Score## Scorescore estimation: $100+100+40+0=240$。actual score: $100+60+40+0=200$。## Reason1. T2 does not write the correct binary solution.2. Although the classification discussion can pass, I am missing $6$ class in categories (how many?# Competition ProcessNot yet completed.::::info[Process]8:00 start8:00 T1 read8:02 T1 think 1/224 行未改动9:40 T2 write 3/?::::# Competition Way Of Thinking## T1The answer is in $[0,3]$.So if $\gcd\limits_{i=1}^{n}a_i=1$ then the answer is $0$.Because $\gcd(n,n-1)=1$ so the answer for all situations is $\le (n-n+1)+[n-(n-1)+1]=3$.If $\gcd(\gcd\limits_{i=1}^{n}a_i,n)=1$ then the answer is $n-n+1=1$.If $\gcd(\gcd\limits_{i=1}^{n}a_i,n-1)=1$ then the answer is $n-(n-1)+1=2$.If $\gcd(\gcd\limits_{i=1}^{n}a_i,n) \ne 1$ and $\gcd(\gcd\limits_{i=1}^{n}a_i,n-1) \ne 1$ then the answer is $3$.## T2Because $n \le 1500$,so the time should not exceed $O(n^2)$.Frist,find the longest horizontal chain,second longest horizontal chain,longest vertical chain,second longest vertical chain.Then,let classification discussion:1. The second longest horizontal chain is possible answers.And the second longest vertical chain is possible answers.2. The half of longest horizontal chain is possible answers.And the half of longest vertical chain is possible answers.3. If the longest horizontal chain and the longest vertical chain non intersecting,then the minimum value of the longest horizontal chain and the longest vertical chain is possible answers.Output all the possible answers max.## T3It is so hard.I can not AC.But I can do sub 1 and sub 2.Because $n \le 5000$,so the time should not exceed $O(n^2)$.Frist,calculate $a$.Then,Let $maxx_{i,j}$ represent $\max\limits_{k=i}^{j}a_k$.Find $maxx_{i,j}=\max(maxx_{i,i},maxx_{i+1,j})$.Attention $maxx_{i,i}=a_i$.Then,calculate $ans_i=\min\limits_{s=1}^{s+i-1 \le n}maxx_{s,s+i-1}$.Finally,calculate $g$ and output.## T4It is so hard.I can not AC.So I won't do it.# Code## T1::::info[AC code]```cpp#include<bits/stdc++.h>using namespace std;int n,a[100005],x;int main(){// freopen("unite.in","r",stdin);// freopen("unite.out","w",stdout);cin>>n>>x;for(int i=2;i<=n;i++){cin>>a[i];17 行未改动}```::::## T2::::info[AC code]```cpp#include<bits/stdc++.h>using namespace std;int n,sum;char s,c[1505][1505];struct node{53 行未改动}```::::## T3::::info[Sub1 and sub2]```cpp#include<bits/stdc++.h>#define int long longusing namespace std;int n,x,y,z,maxx[5005][5005],ans[5005],g[5005];signed main(){// freopen("value.in","r",stdin);// freopen("value.out","w",stdout);cin>>n>>x>>y>>z;for(int i=1;i<=n;i++)ans[i]=z;for(int i=1;i<=n;i++)maxx[i][i]=(maxx[i-1][i-1]*x+y)%z,ans[1]=min(ans[1],maxx[i][i]);for(int l=2;l<=n;l++)for(int start=1;start+l-1<=n;start++)maxx[start][start+l-1]=max(maxx[start][start],maxx[start+1][start+l-1]),ans[l]=min(ans[l],maxx[start][start+l-1]);for(int i=1;i<=n;i++)g[i]=(g[i-1]*x+ans[i]+y)%z;cout<<g[n];return 0;}```::::6 行未改动1234567891011121324 行未改动3839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828317 行未改动10110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326453 行未改动3183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563576 行未改动# Score## Scorescore estimation: $100+100+40+0=240$。actual score: $100+60+40+0=200$。## Reason1. I do not write the correct binary solution in T2.2. Although the classification discussion can pass, I missed $6$ class in categories (how many?# Competition ProcessNot yet completed.::::info[Process]8:00 start8:00 T1 read8:02 T1 think 1/224 行未改动9:40 T2 write 3/?::::# Competition Way Of Thinking## T1If $\gcd\limits_{i=1}^{n}a_i=1$ then the answer is $0$.Because $\gcd(n, n-1)=1$ so the answer for all situations is $\le (n-n+1)+[n-(n-1)+1]=3$.If $\gcd(\gcd\limits_{i=1}^{n}a_i, n)=1$ then the answer is $n-n+1=1$. If $\gcd(\gcd\limits_{i=1}^{n}a_i, n-1)=1$ then the answer is $n-(n-1)+1=2$.If $\gcd(\gcd\limits_{i=1}^{n}a_i, n) \ne 1$ and $\gcd(\gcd\limits_{i=1}^{n}a_i, n-1) \ne 1$ then the answer is $3$.## T2Because $n \le 1500$, so the time should not exceed $O(n^2)$.First, finding the longest horizontal chain, second longest horizontal chain, longest vertical chain, second longest vertical chain. Then, let classification discussion:1. The second longest horizontal chain is possible answer. And the second longest vertical chain is one of possible answers.2. The half of longest horizontal chain is possible answer. And the half of longest vertical chain is one of possible answers.3. If the longest horizontal chain and the longest vertical chain non intersecting, then the minimum value of the longest horizontal chain and the longest vertical chain is possible answer.Output all the possible answers max.## T3It is so hard. I can not AC. But I can do sub1 and sub2.Because $n \le 5000$, so the time should not exceed $O(n^2)$.First, calculate $a$.Then, Let $maxx_{i, j}$ represent $\max\limits_{k=i}^{j}a_k$. We should find $maxx_{i, j}=\max(maxx_{i, i}, maxx_{i+1, j})$. Attention $maxx_{i, i}=a_i$.Then, calculate $ans_i=\min\limits_{s=1}^{s+i-1 \le n}maxx_{s, s+i-1}$.Finally, calculate $g$ and output.## T4It is so hard. I can not AC. So I won't do it.# Competition Code## T1::::info[AC code]```cpp#include<bits/stdc++.h>using namespace std;int n,a[100005],x;int main(){freopen("unite.in","r",stdin);freopen("unite.out","w",stdout);cin>>n>>x;for(int i=2;i<=n;i++){cin>>a[i];17 行未改动}```::::## T2::::info[60 pts]```cpp#include<bits/stdc++.h>using namespace std;int n,sum;char s,c[1505][1505];struct node{int x,y,s;};vector<node>ex,ey;bool cmp(node rrr,node rrrr){return rrr.s>rrrr.s;}int main(){freopen("color.in","r",stdin);freopen("color.out","w",stdout);cin>>n;for(int i=1;i<=n;i++){for(int j=1;j<=n;j++)cin>>c[i][j];c[0][i]=c[i][0]=c[n+1][i]=c[i][n+1]='X';}c[0][0]=c[0][n+1]=c[n+1][0]=c[n+1][n+1]='X';//--------------------for(int i=1;i<=n;i++){for(int j=1;j<=n+1;j++){if(c[i][j]=='X'){if(sum)ex.push_back({i,j-1,sum}),sum=0;}else sum++;}}sum=0;//||||||||||||||||||||for(int i=1;i<=n;i++){for(int j=1;j<=n+1;j++){if(c[j][i]=='X'){if(sum)ey.push_back({i,j-1,sum}),sum=0;}else sum++;}}sort(ex.begin(),ex.end(),cmp),sort(ey.begin(),ey.end(),cmp);int i=ex[0].x,j=ex[0].y-ex[0].s+1,k=ey[0].x-ey[0].s+1,l=ey[0].y,o=ex[0].y,p=ey[0].x;//cout<<ex[1].s<<" "<<ey[1].s<<" "<<ex[0].s<<" "<<ey[0].s<<"\n";cout<<max(max(ex.size()>1?max(ex[1].s,ex[0].s/2):ex[0].s/2,ey.size()>1?max(ey[1].s,ey[0].s/2):ey[0].s/2),(l>=j&&l<=o&&i>=k&&i<=p?-1:min(ex[0].s,ey[0].s)));return 0;}```::::## T3::::info[Sub1 and sub2]```cpp#include<bits/stdc++.h>#define int long longusing namespace std;int n,x,y,z,maxx[5005][5005],ans[5005],g[5005];signed main(){freopen("value.in","r",stdin);freopen("value.out","w",stdout);cin>>n>>x>>y>>z;for(int i=1;i<=n;i++)ans[i]=z;for(int i=1;i<=n;i++)maxx[i][i]=(maxx[i-1][i-1]*x+y)%z,ans[1]=min(ans[1],maxx[i][i]);for(int l=2;l<=n;l++)for(int start=1;start+l-1<=n;start++)maxx[start][start+l-1]=max(maxx[start][start],maxx[start+1][start+l-1]),ans[l]=min(ans[l],maxx[start][start+l-1]);for(int i=1;i<=n;i++)g[i]=(g[i-1]*x+ans[i]+y)%z;cout<<g[n];return 0;}```::::## T4::::info[Nothing]```cpp//I can not AC.```::::# Sol## T1If $\gcd\limits_{i=1}^{n}a_i=1$ then the answer is $0$.Because $\gcd(n, n-1)=1$ so the answer for all situations is $\le (n-n+1)+[n-(n-1)+1]=3$.If $\gcd(\gcd\limits_{i=1}^{n}a_i, n)=1$ then the answer is $n-n+1=1$. If $\gcd(\gcd\limits_{i=1}^{n}a_i, n-1)=1$ then the answer is $n-(n-1)+1=2$.If $\gcd(\gcd\limits_{i=1}^{n}a_i, n) \ne 1$ and $\gcd(\gcd\limits_{i=1}^{n}a_i, n-1) \ne 1$ then the answer is $3$.## T2Because $n \le 1500$, so the time should not exceed $O(n^2)$.First, finding the longest horizontal chain, second longest horizontal chain, longest vertical chain, second longest vertical chain. Then, let classification discussion:1. The second longest horizontal chain is possible answer. And the second longest vertical chain is one of possible answers.2. The half of longest horizontal chain is possible answer. And the half of longest vertical chain is one of possible answers.3. If the longest horizontal chain and the longest vertical chain non intersecting, then the minimum value of the longest horizontal chain and the longest vertical chain is possible answer.4. If the longest horizontal chain and the longest vertical chain non intersecting is false, then the longest horizontal chain and the cut open longest vertical chain max min is possible answer.5. If the longest horizontal chain and the longest vertical chain non intersecting is false, then the longest vertical chain and the cut open longest horizontal chain max min is possible answer.Output all the possible answers max.## T3If $\max\limits_{i=l}^{r}a_i=k$, the $i \in [1,r-l+1]$, $f_i=\min(f_i,k)$.So we should find "left first max" and "right first max". So we should use stack to find.Calculate min difference $f$.## T4It is so hard. I can not AC. So I won't do it.# AC Code## T1::::info[AC code]```cpp#include<bits/stdc++.h>using namespace std;int n,a[100005],x;int main(){freopen("unite.in","r",stdin);freopen("unite.out","w",stdout);cin>>n>>x;for(int i=2;i<=n;i++){cin>>a[i];x=__gcd(x,a[i]);}if(x==1){cout<<0;return 0;}for(int i=n,j=1;i;i--,j++){if(__gcd(x,i)==1){cout<<j;return 0;}}// cout<<3;return 0;}```::::## T2::::info[AC code]```cpp#include<bits/stdc++.h>using namespace std;int n,sum;char s,c[1505][1505];struct node{53 行未改动}```::::## T3::::info[AC code]```cpp#include<bits/stdc++.h>#define int long longusing namespace std;const int N=1e7+5;int n,x,y,z,a[N],l[N],r[N],f[N],g;stack<int> s;signed main(){// freopen("value.in","r",stdin);// freopen("value.out","w",stdout);cin>>n>>x>>y>>z;for(int i=1;i<=n;i++)a[i]=(a[i-1]*x+y)%z,f[i]=1e18;for(int i=1;i<=n;i++){while(s.size()&&a[s.top()]<=a[i])s.pop();l[i]=(!s.empty()?s.top()+1:1);s.push(i);}while(s.size())s.pop();a[n+1]=1e18,s.push(n+1);for(int i=n;i>=1;i--){while(!s.empty()&&a[s.top()]<=a[i])s.pop();r[i]=s.top()-1;s.push(i);}for(int i=1;i<=n;i++)f[r[i]-l[i]+1]=min(f[r[i]-l[i]+1],a[i]);for(int i=n-1;i;i--)f[i]=min(f[i+1],f[i]);for(int i=1;i<=n;i++)g=(g*x+(f[i]==1e18?0:f[i])+y)%z;cout<<g;return 0;}```::::6 行未改动