2026.5.1 Happy Labor Day mock competition
miller2014 · · 个人记录
Score
Score
score estimation:
actual score:
Reason
- I do not write the correct binary solution in T2.
- Although the classification discussion can pass, I missed
6 class in categories (how many?Competition Process
Not yet completed. ::::info[Process] 8:00 start
8:00 T1 read
8:02 T1 think 1/2
8:03 T1 think 2/2
8:06 T1 write 1/1
8:08 T1 debug 1/3
8:08 T1 debug 2/3
8:09 T1 debug 3/3
8:10 T1 hand make debug 1/1
8:10 T2 read
8:12 T2 think 1/1
8:13 T3 read
8:17 T4 read
8:23 T2 write 1/3
8:25 T2 write 2/3
8:28 [say]
8:29 [hack]
8:39 [mistake] T2 think 0
8:45 T2 sub1&2 think 1/1
8:49 T2 sub1&2 write 1/?
8:54 T2 sub1&2 write 2/2
9:04 T2 sub1&2 debug 0/?
9:07 T2 sub1&2 debug 0/?
9:10 T2 sub1&2 debug 1/?
9:11 [break]
9:32 T1 debug 2/3
9:33 T1 debug 3/3
9:40 T2 write 3/?
::::Competition Way Of Thinking
T1
If
\gcd\limits_{i=1}^{n}a_i=1 then the answer is0 .
Because
If
If
T2
Because
First, finding the longest horizontal chain, second longest horizontal chain, longest vertical chain, second longest vertical chain. Then, let classification discussion:
- The second longest horizontal chain is possible answer. And the second longest vertical chain is one of possible answers.
- The half of longest horizontal chain is possible answer. And the half of longest vertical chain is one of possible answers.
- 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.
T3
It is so hard. I can not AC. But I can do sub1 and sub2.
Because
First, calculate
Then, Let
Then, calculate
Finally, calculate
T4
It is so hard. I can not AC. So I won't do it.
Competition Code
T1
::::info[AC code]
#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[60 pts]
#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]
#include<bits/stdc++.h>
#define int long long
using 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]
//I can not AC.
::::
Sol
T1
If
Because
If
If
T2
Because
First, finding the longest horizontal chain, second longest horizontal chain, longest vertical chain, second longest vertical chain. Then, let classification discussion:
- The second longest horizontal chain is possible answer. And the second longest vertical chain is one of possible answers.
- The half of longest horizontal chain is possible answer. And the half of longest vertical chain is one of possible answers.
- 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.
- 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.
- 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.
T3
If
Calculate min difference
T4
It is so hard. I can not AC. So I won't do it.
AC Code
T1
::::info[AC code]
#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]
#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({j-1,i,sum}),sum=0;
}
else sum++;
}
}
if(!ex.size())return (cout<<0)&&0;
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(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))),
l>=j&&l<=o&&i>=k&&i<=p?max(max(min(l-j,ey[0].s),min(o-l,ey[0].s)),max(min(i-k,ex[0].s),min(p-i,ex[0].s))):-1);
return 0;
}
::::
T3
::::info[AC code]
#include<bits/stdc++.h>
#define int long long
using 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;
}
::::
T4
::::info[Nothing]
//I can not AC.
::::