Codeforces Round 970 (Div. 3) 题解
A. Sakurako's Exam
签到,优先考虑\(2\)之间互相加减,所以只会剩下最多一个\(2\),用\(2\)个\(1\)来消除,最后判断剩下\(1\)的个数即可
code:
1234567891011121314151617181920212223242526272829#include <bits/stdc++.h>#define int long long#define x first#define y secondusing namespace std;typedef pair<int, int> PII;const int N = 200010;int T;int a, b;signed main(){ cin >> T; while (T--) { cin >> a >> b; b %= 2; a -= b * 2; if (a < 0 || a % 2) cout << "NO&qu ...
Codeforces Round 968 (Div. 2) 题解
A. Turtle and Good Strings
根据题意可知,一个好的字符串一定可以拆成两个满足条件的字符串,所以只需要令\(k=2\)进行操作即可
code:
123456789101112131415161718192021222324252627282930313233#include <bits/stdc++.h>#define int long long#define x first#define y second#define endl '\n'using namespace std;typedef pair<int, int> PII;const int N = 200010;int T;int n;string s;signed main(){ ios::sync_with_stdio(false); cin.tie(0), cout.tie(0); cin >> T; while (T--) { cin >> n >> ...
Codeforces Round 966 (Div. 3) 题解
A. Primary Task
暴力判断即可
code:
1234567891011121314151617181920212223242526272829303132333435363738394041#include <bits/stdc++.h>#define x first#define y second#define int long longusing namespace std;typedef pair<int, int> PII;const int N = 200010;int T;int n;int a[N];signed main(){ cin >> T; while (T--) { cin >> n; string s; while (n > 10) { s += n % 10 + '0'; n /= 10; ...
Educational Codeforces Round 169 (Rated for Div. 2) 题解
A. Closest Point
观察一下可以发现,只有当集合中的点数等于\(2\),并且这两个点的差值大于\(1\)时,才有满足条件的点可以插入
code:
123456789101112131415161718192021222324252627282930#include <bits/stdc++.h>#define int long long#define x first#define y secondusing namespace std;typedef pair<int, int> PII;const int N = 200010;int T;int n;int a[N];signed main(){ cin >> T; while (T--) { cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; if (n == 2 && abs(a[0] - a[1]) > ...
河南萌新联赛 2024 第(五)场 题解
A. 日历游戏
\(sg\) 函数板子题,就是需要多处理一个日期
code:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283#include <bits/stdc++.h>using namespace std;int T;int y, m, d;int bg, ed;map<int, int> f;int mon[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};bool check(int y){ return (y % 4 == 0 && y % 100) || y % 400 == 0;}int get_day(int y, int m, int d){ ...
河南萌新联赛2024第(四)场 题解
A. 该出奇兵了
$tarjan \(割点板子题,处理完割点以后\)dfs$ 求出每个点被删掉以后对答案的最小贡献
code:
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130#include <bits/stdc++.h>#define int __int128using namespace std;const int N = 100010;int n, m;int a[N];vector<int> h[N];int dfn[N], low[N], to ...