考试的时候突然不会写暴力了。 然后我觉得没什么问题,不知道为什么只有50分。 求助各位大佬
#include<bits/stdc++.h>
using namespace std;
#define ll long long
template <typename T> void read(T &x)
{
int f=1;char c=getchar();x=0;
for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
for(;isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(c^48);
x*=f;
}
int n,a[10],b[10],c[10],d[10],e[10];
int A[10][1000],v[10][1000];
int ans=81;
int main()
{
freopen("lock.in","r",stdin);
freopen("lock.out","w",stdout);
read(n);
for(int i=1;i<=n;i++)
{
read(a[i]);read(b[i]);read(c[i]);read(d[i]);read(e[i]);
}
if(n==1) cout<<81;
else
{
for(int i=1;i<=n;i++)
{
priority_queue<int,vector<int>,greater<int> >q;
for(int j=1;j<=9;j++)
{
q.push((a[i]+j)%10*10000+b[i]*1000+c[i]*100+d[i]*10+e[i]);
q.push((b[i]+j)%10*1000+a[i]*10000+c[i]*100+d[i]*10+e[i]);
q.push((c[i]+j)%10*100+b[i]*1000+a[i]*10000+d[i]*10+e[i]);
q.push((d[i]+j)%10*10+b[i]*1000+c[i]*100+a[i]*10000+e[i]);
q.push((e[i]+j)%10+b[i]*1000+c[i]*100+d[i]*10+a[i]*10000);
q.push((a[i]+j)%10*10000+(b[i]+j)%10*1000+c[i]*100+d[i]*10+e[i]);
q.push(a[i]*10000+(b[i]+j)%10*1000+(c[i]+j)%10*100+d[i]*10+e[i]);
q.push(a[i]*10000+b[i]*1000+(c[i]+j)%10*100+(d[i]+j)%10*10+e[i]);
q.push(a[i]*10000+b[i]*1000+c[i]*100+(d[i]+j)%10*10+(e[i]+j)%10);
}
int t=0;
while(!q.empty())
{
int w=q.top();
q.pop();
A[i][++t]=w;
}
}
int cnt=0;
int i=1,j=1;
while(i<=81&&j<=81)
{
if(A[1][i]==A[2][j]) {cnt++;i++;j++;v[2][j]=0;}
else if(A[1][i]<A[2][j]) i++;
else if(A[1][i]>A[2][j]) j++;
}
for(int o=2;o<n;o++)
{
for(int j=1;j<=81;j++)
if(v[o][j]==0)
{
int ff=0;
for(int i=1;i<=81;i++)
{
if(A[o+1][i]==A[o][j])
{
A[o+1][i]=0;
ff=1;
}
if(ff==0) cnt--;
}
}
}
cout<<max(cnt,0);
}
return 0;
}