20231117
2023/11/17
前言:今天打的Educational Codeforces Round 153 (Rated for Div. 2),打的一坨,真的吐了。又开始自我批评了。。。。
A. Not a Substring
构造题:看他是A题,尝试了几种简单的构造方式,发现有两种是互斥的就是()()()和((()))。
还知道了string初始化的一些细节
B. Fancy Coins
少见的卡B题,赛时没好的思路。
思路:我们先算出需要的最少总硬币数,那么k价值的尽可能去满,然后用1填充。然后就开始4种情况的分类讨论了,发现都可以转化成上面这种方案。难想的一种无非就是1多,k少。那么我们就想把1的任务完成了之后,其他的转变成k就帮一下就行。
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define Acode ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define int long long
void solve()
{
int m, k, a1, ak;
cin >> m >> k >> a1 >> ak;
int x = m % k;
int xx = m / k;
int ans = 0;
if (a1 < x)
ans += x - a1;
else
ak += (a1 - x) / k;
if (ak < xx)
ans += xx - ak;
cout << ans << endl;
}
signed main()
{
Acode;
int T = 1;
cin >> T;
while (T--)
{
solve();
}
return 0;
}
C题: Game on Permutation
博弈论,这题先手选点后不能操作,一绕一下,不过只想必胜,必败态的话就不用考虑这个东西了
思路:那么如果一个点能到的点都是先手必败态,那么它就是先手必胜态。如果一个点能到一个先手必胜态,那么它就是先手必败态,因为先手操作完后,会转换先后手。
放一份数据结构暴力维护必胜,必败态的做法,其实可以只关注最小必胜态的大小的
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define Acode ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define int long long
const int N = 1e6 + 10;
int a[N];
int t[N];
int n;
int lowbit(int x)
{
return x & -x;
}
void add(int x, int val)
{
while (x <= n)
{
t[x] += val;
x += lowbit(x);
}
}
int getsum(int x)
{
int sum = 0;
while (x)
{
sum += t[x];
x -= lowbit(x);
}
return sum;
}
void solve()
{
cin >> n;
int ans = 0;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
t[i] = 0;
}
for (int i = 1; i <= n; i++)
{
int x = getsum(a[i]);
if (x == 0)
add(a[i], 1);
else if (x > 0)
{
add(a[i], -1e6);
ans++;
}
else
{
add(a[i], 1);
}
}
cout << ans << endl;
}
signed main()
{
Acode;
int T = 1;
cin >> T;
while (T--)
{
solve();
}
return 0;
}
D题思路会了,明天再写,挺经典的问题。
晚上 打 Codeforces Round 909 (Div. 3) solve(6/7)
只能说练的太少,感觉G题应该是要会的

浙公网安备 33010602011771号