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

2023-08-31 18:36:23 浏览数 (2)

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见祖宗一边呆着去;
  • 一定要和周边的学长或者大神取经,提高自己的认知;

0 人点赞