版本比较
2024CSP-J游记
标题
增加 1 行删除 1 行
11CSP-J游记2024CSP-J游记正文
增加 269 行删除 3 行
35 行未改动3637383940404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146471471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082 行未改动211212213214582152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273289 行未改动35 行未改动结论:能用硬判+for嵌套稍稍优化\然后用接近40分钟干完了写了一个49行的代码\——题外话,这里的40多分钟包括打开并使用虚拟机的时间,那个虚拟机不知道为什么卡得要死\总结:平时尤其是备赛时应该多刷水题\源代码:[T1](https://www.luogu.com.cn/paste/dq61n2rt)::::success[源代码]### **我本来写的是:**```cpp#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:```cpp#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```cpp#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分~~\源代码:[T2](https://www.luogu.com.cn/paste/kaot514i)::::success[源代码]### **第二题没有什么其他思路:**```cpp#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的时候就能超时\2 行未改动我突然想起来8的火柴棍数量为7,而题目要求摆出来的数尽可能的小\然后我开始推,模7余数0-6时的情况\~~结果有两个0写成了8,然后两个情况写错了,22的特例没考虑到~~\30pts ~~都怪机器卡了浪费我时间检查~~\源代码:[T3](https://www.luogu.com.cn/paste/yptdk3j0)::::error[源代码]### **第三题**摆上30pts代码:```cpp#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代码```cpp#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分)\9 行未改动