前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >【强烈推荐】全力冲刺2023年信息学CSP-J/S之【降龙十八掌】:看大佬怎么对付爆零

【强烈推荐】全力冲刺2023年信息学CSP-J/S之【降龙十八掌】:看大佬怎么对付爆零

作者头像
小码匠
发布2023-08-31 18:36:23
2060
发布2023-08-31 18:36:23
举报

2017年某场比赛代码(截取部分代码)

代码语言:javascript
复制
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
...
 
int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin >> N; p.resize(N);
	F0R(i,N) cin >> p[i].f >> p[i].s;
	sort(p.begin(),p.end());
	F0R(i,p.size()) solve(i);
	cout << ans;
}
 
// read!
// ll vs. int!

亮点

代码语言:javascript
复制
// read!
// ll vs. int!
2018年某场比赛代码(截取部分代码)
代码语言:javascript
复制
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
...
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n; a.resize(n);
    F0R(i,n) cin >> a[i];
    ...
    process(st,n-1);
    cout << ans;
}
 
// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)

亮点

代码语言:javascript
复制
// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)
2019年某场比赛代码(截取部分代码)
代码语言:javascript
复制
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>
 
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
 
typedef string str;
 
int main() {
	setIO(); string S; int K; re(S,K); 
	string T = S+S+S;
	vl ans(3);
    ...
	// ps(ans);
	// ps(ans);
	ps(ret);
	// you should actually read the stuff at the bottom
}
 
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?), set tle
	* do smth instead of nothing and stay organized
*/

亮点

代码语言:javascript
复制
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?), set tle
	* do smth instead of nothing and stay organized
*/
2020年某场比赛代码(截取部分代码)
代码语言:javascript
复制
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using db = double; 
using str = string; // yay python!
 
using pi = pair<int,int>;
 
str S;
 
void solve(int tc) {
	re(S);
	int ind = 0;
	while (ind < sz(S) && S[ind] == 'a') ind ++;
	if (ind == sz(S)) {
		ps(-1);
		return;
	}
	int ans = 0;
	while (ind > 1) {
		swap(S[ind],S[ind-1]), ans ++;
		ind --;
	}
	if ("atcoder" < S) ps(ans);
	else ps(ans+1);
}
 
int main() {
	setIO();
	int TC; re(TC);
	FOR(i,1,TC+1) solve(i);
}
 
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
*/

亮点

代码语言:javascript
复制
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
	* DON'T GET STUCK ON ONE APPROACH
*/

无忧公主(截取部分代码)

代码语言:javascript
复制
/*
 
  0. Enough array size? Enough array size? Enough array size? Integer overflow?
 
   
  1. Think TWICE, Code ONCE!
 
  Are there any counterexamples to your algo?
  
  2. Be careful about the BOUNDARIES!
 
  N=1? P=1? Something about 0?
 
 
  3. Do not make STUPID MISTAKES!
 
  Time complexity? Memory usage? Precision error?
 
*/

备战:4个一定,助力大家AK CSP-J/S

  • 一定要注意细节,细节决定成败;
  • 一定要少犯最好不犯的低级错误,让不开long long见祖宗一边呆着去;
  • 一定要和周边的学长或者大神取经,提高自己的认知;
本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2023-08-18,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 小码匠和老码农 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 2018年某场比赛代码(截取部分代码)
  • 2019年某场比赛代码(截取部分代码)
  • 2020年某场比赛代码(截取部分代码)
  • 无忧公主(截取部分代码)
  • 备战:4个一定,助力大家AK CSP-J/S
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档