这是我的考场代码:
#include<bits/stdc++.h>
using namespace std;
#define int long long
int rd() {
int m=0,s=0;char ch=getchar();
while(ch<'0'||ch>'9') {if(ch=='-')m=1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+(ch-'0'),ch=getchar();
return (m?-s:s);
}
int n,a[10],mp[100005],ans;
int hash() {
int h=0;
for(int i=1;i<=5;i++)
h=h*10+a[i];
return h;
}
signed main() {
freopen("lock.in","r",stdin);
freopen("lock.out","w",stdout);
cin>>n;
for(int i=1;i<=n;i++) {
for(int j=1;j<=5;j++)
a[j]=rd();
for(int j=1;j<=5;j++) {
for(int k=1;k<=10;k++) {
a[j]=(a[j]+1)%10;
mp[hash()]++;
}
}
for(int j=1;j<=4;j++) {
for(int k=1;k<=10;k++) {
a[j]=(a[j]+1)%10,a[j+1]=(a[j+1]+1)%10;
mp[hash()]++;
}
}
}
for(int i=0;i<=100000;i++) {
if(mp[i]==n)
ans++;
}
cout<<ans;
return 0;
}
好像很正确,但是由于 c++14 + 万能头 导致hash()函数冲突与关键字,痛失100pts,而在dev-c++上没有报错,甚至连提醒,警告都没有...
所以大家一定要养成良好的做题习惯,不要用万能头!!! \哭哭