社区讨论
发个帖子谴责一下自己
P9752[CSP-S 2023] 密码锁参与者 18已保存回复 24
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 24 条
- 当前快照
- 1 份
- 快照标识符
- @lo0v457x
- 此快照首次捕获于
- 2023/10/22 10:41 2 年前
- 此快照最后确认于
- 2023/11/02 11:59 2 年前
这是我的考场代码:
CPP#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++上没有报错,甚至连提醒,警告都没有...
所以大家一定要养成良好的做题习惯,不要用万能头!!! \哭哭
回复
共 24 条回复,欢迎继续交流。
正在加载回复...