CSP-J游记
(应付)
- 公元2024年10月26日,余于sssy学校,与csp。得绩有感,特作。
话说乃是赛前半月时。当时我们的语文老师是从河南来的
众所周知河南省的信息学是一个垃圾省份
他也许大概应该可能从来没有见过真正的信息学专训队。在这位年近五旬的老师的脑海里,永远只有两个东西:作业和上课。而我们这几个信息队的“叛逆”则常常不交作业、缺晚修,一天五个小时泡在电脑室。
不过我倒感觉当时我们班信息队把信息放在第一位的精神挺好的
到了比赛前的一个星期。我开始 疯狂 刷题,刷了四套左右吧
第一套爆0
第二套估分200,实际150
第三套估分280,实际117
第四套157
简单来说,我是个垃圾
再加上我初赛考-S的经历
——估分52.5实际43
弄得我从此几乎不敢估分\
到了比赛前一天,我们在学校宿舍。(今年考场在我们学校)
第二天,我们做了一件重要的事:
拜图灵、姚期智磕了64次
然后我们上考场结果我肚子疼
T1
第一眼:水题
第二眼:桶—结果想起来ASCII码不知道怎么处理(事实上可以处理)
第三眼:map—结果想起来map是个集合无法遍历(事实上不需要遍历)
第四眼:set—结果想起来还没学(事实上会打)
第五眼:硬判—结果想起来代码会很多很费手(也就24个判断+一层for)
结论:能用硬判+for嵌套稍稍优化
然后用接近40分钟干完了写了一个49行的代码
——题外话,这里的40多分钟包括打开并使用虚拟机的时间,那个虚拟机不知道为什么卡得要死
总结:平时尤其是备赛时应该多刷水题\
源代码
我本来写的是:
#include<iostream>
#include<cstdio>
using namespace std;
bool a[10][20];
const char f[]={'D','C','H','S'};
int tong[200];
int main()
{
freopen("poker.in","r",stdin);
freopen("poker.out","w",stdout);
int i,j,n,ans=0;
char flower,num;
cin >>n;
tong['A'] = 1;
tong['T'] = 10;
tong['J'] = 11;
tong['Q'] = 12;
tong['K'] = 13;
for(i = 1; i <= n; i++)
{
cin >> flower >> num;
for(j = 0; j < 4; j++)
{
if(flower == f[j])
{
if(isdigit(num))
{
a[j][num-'0'] = 1;
}
else
{
a[j][tong[num]] = 1;
}
break;
}
}
}
for(i = 0; i < 4; i++)
{
for(j = 1; j <= 13; j++)
{
if(!a[i][j])
ans++;
}
}
cout << ans;
return 0;
}事实上可以写map:
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
map<string,int> mp;
int main()
{
freopen("poker.in","r",stdin);
freopen("poker.out","w",stdout);
int i,j,n,ans=0;
string card;
cin >> n;
for(i = 1; i <= n; i++)
{
cin >> card;
if(mp[card] == 0)
mp[card] = 1, ans++;
}
cout << 52-ans;
return 0;
}或者用set
#include<iostream>
#include<cstdio>
#include<set>
using namespace std;
set<string> s;
int main()
{
freopen("poker.in","r",stdin);
freopen("poker.out","w",stdout);
int i,j,n,ans=0;
string card;
cin >> n;
for(i = 1; i <= n; i++)
{
cin >> card;
s.insert(card);
}
cout << 52-s.size();
return 0;
}垃圾代码
T2
机器人?地图?深搜?CCF怎么出这么水的题?
然后我才发现事实和我想的完全不一样:
这道题比深搜还简单
好吧,这道题我闭着眼睛都能写对
虽然我的同学只有50分\
源代码
第二题没有什么其他思路:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char g[1005][1005];
bool cnt[1005][1005];
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
int main()
{
freopen("explore.in","r",stdin);
freopen("explore.out","w",stdout);
int t,n,m,k,x,y,d,i,j,tx,ty,ans;
cin >>t;
while(t--)
{
cin >> n >> m >> k;
cin >> x >> y >> d;
ans = 0;
memset(cnt,0,sizeof(cnt));
memset(g,0,sizeof(g));
cnt[x][y] = 1;
for(i = 1; i <= n; i++)
{
for(j = 1; j <= m; j++)
{
cin >> g[i][j];
}
}
while(k--)
{
tx = x + dx[d];
ty = y + dy[d];
if(tx >= 1 && tx <= n && ty >= 1 && ty <= m && g[tx][ty] == '.')
{
x = tx;
y = ty;
cnt[tx][ty] = 1;
}
else
{
d = (d + 1) % 4;
}
}
for(i = 1; i <= n; i++)
for(j = 1; j <= m; j++)
if(cnt[i][j])
ans++;
cout << ans << endl;
}
return 0;
}T3
一看到火柴棍,我就有些恐惧了,因为我想起了08年的那道题
于是我打起了搜索
结果T=1,n=50的时候就能超时
但是在我看完第四题会看这题的时候,我才留意到特殊样例
7的倍数?模7余1?
我突然想起来8的火柴棍数量为7,而题目要求摆出来的数尽可能的小
然后我开始推,模7余数0-6时的情况
结果有两个0写成了8,然后两个情况写错了,22的特例没考虑到
30pts 都怪机器卡了浪费我时间检查\
源代码
第三题
摆上30pts代码:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int INF = 2e9;
const int d[] = {6,2,5,INF,4,INF,6,3,7,INF,8};
const int x[] = {88,18,10,26,28,68};
int main()
{
register int t,n,i;
register bool f;
cin >> t;
while(t--)
{
cin >> n;
if(n < 2)
{
cout << -1 << endl;
continue;
}
if(n <= 7)
{
for(i = 1; i <= 9; i++)
if(d[i] == n)
{
cout << i << endl;
break;
}
continue;
}
if(n % 7 == 0)
{
for(i = 1; i <= n / 7; i++)
cout << 8;
cout << endl;
continue;
}
cout << x[n % 7];
for(i = 1; i < n / 7; i++)
cout << 8;
cout << endl;
}
return 0;
}然后是100pts代码
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
const int INF = 2e9;
const int d[] = {6,2,5,INF,4,INF,6,3,7,INF,8};
const int x[] = {88,10,18,INF,20,28,68}; // 这里改了一些
int main()
{
register int t,n,i;
register bool f;
cin >> t;
while(t--)
{
cin >> n;
if(n < 2)
{
cout << -1 << endl;
continue;
}
if(n <= 7)
{
for(i = 1; i <= 9; i++)
if(d[i] == n)
{
cout << i << endl;
break;
}
continue;
}
if(n % 7 == 0)
{
for(i = 1; i <= n / 7; i++)
cout << 8;
cout << endl;
continue;
}
if(n == 10) // 加特判
{
cout << 22 << endl;
continue;
}
if(x[n % 7] == INF)
{
cout << 200;
for(i = 2; i < n / 7; i++)
cout << 8;
cout << endl;
continue;
}
cout << x[n % 7];
for(i = 1; i < n / 7; i++)
cout << 8;
cout << endl;
} // AC
return 0;
}T4
毫无头绪。
于是我看到了一种特例:n=1
于是我打了这种情况(应该是5分)
其余情况全部输出0——传说中的总司令
考完才想到可以用搜索骗分
早知道就学习随机数了
还是0分
总分:230
总结:做题要细致,尽量多检查,考前要认真刷题。