Codeforces Round #806 (Div. 4)
Codeforces Round #806 (Div. 4)
A
挨个判断字符是不是等于大小写的"YES"
// Problem: A. YES or YES?
// Contest: Codeforces - Codeforces Round #806 (Div. 4)
// URL: https://codeforces.com/contest/1703/problem/A
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char a[3];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
cin >> a;
if ((a[0] == 'Y' || a[0] == 'y') && (a[1] == 'e' || a[1] == 'E') && (a[2] == 'S' || a[2] == 's'))
cout << "YES" << endl;
else
cout << "NO" << endl;
}
return 0;
}
B
模拟,如果第一次出现则多加一次
// Problem: B. ICPC Balloons
// Contest: Codeforces - Codeforces Round #806 (Div. 4)
// URL: https://codeforces.com/contest/1703/problem/B
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[26];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
memset(a, 0, sizeof a);
int n;
cin >> n;
int sum = 0;
for (int i = 0; i < n; i++)
{
char x;
cin >> x;
a[x - 'A']++;
sum++;
if (a[x - 'A'] == 1)
sum++;
}
cout << sum << endl;
}
return 0;
}
C
模拟,即可解决或的变化
// Problem: C. Cypher
// Contest: Codeforces - Codeforces Round #806 (Div. 4)
// URL: https://codeforces.com/contest/1703/problem/C
// Memory Limit: 256 MB
// Time Limit: 1000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[110];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i];
for (int i = 0; i < n; i++)
{
int k;
cin >> k;
int res = a[i];
while (k--)
{
char x;
cin >> x;
if (x == 'D')
{
res = (res + 11) % 10;
}
else
{
res = (res + 9) % 10;
}
}
cout << res << " ";
}
cout << endl;
}
return 0;
}
D
模拟,对每个字符串的各个位置进行判断
// Problem: D. Double Strings
// Contest: Codeforces - Codeforces Round #806 (Div. 4)
// URL: https://codeforces.com/contest/1703/problem/D
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
vector<string> v;
map<string, int> m;
for (int i = 0; i < n; i++)
{
string s;
cin >> s;
v.push_back(s);
m[s]++;
}
for (int i = 0; i < n; i++)
{
bool flag = 0;
for (int j = 1; j < v[i].size(); j++)
{
string s1 = v[i].substr(0, j);
string s2 = v[i].substr(j);
if (m.count(s1) && m.count(s2))
flag = 1;
if (flag)
break;
}
if (flag)
cout << 1;
else
cout << 0;
}
cout << endl;
}
return 0;
}
E
只有01,那么每个位置反转后的3个位置如果0多,则将1变为0,如果1多,则将0变为1
// Problem: E. Mirror Grid
// Contest: Codeforces - Codeforces Round #806 (Div. 4)
// URL: https://codeforces.com/contest/1703/problem/E
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char c[110][110];
int a[110][110];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--)
{
int n;
cin >> n;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
{
cin >> c[i][j];
a[i][j] = c[i][j] - '0';
}
int sum = 0;
for (int i = 0; i < (n + 1) / 2; i++)
{
for (int j = 0; j < n / 2; j++)
{
int temp = a[i][j];
temp = temp + (a[j][n - 1 - i] + a[n - 1 - i][n - 1 - j] + a[n - 1 - j][i]);
sum += min(temp, 4 - temp);
// cout << sum << endl;
}
}
cout << sum << endl;
}
return 0;
}
F
将所有的数存入新的数组v,取数对满足
// Problem: F. Yet Another Problem About Pairs Satisfying an Inequality
// Contest: Codeforces - Codeforces Round #806 (Div. 4)
// URL: https://codeforces.com/contest/1703/problem/F
// Memory Limit: 256 MB
// Time Limit: 2000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int tt;
cin >> tt;
for (int i = 1; i <= tt; i++)
{
int n;
cin >> n;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
}
long long res = 0;
vector<int> v;
for (int i = 1; i <= n; i++)
{
if (a[i] >= i)
{
continue;
}
res += (long long)(lower_bound(v.begin(), v.end(), a[i]) - v.begin());
v.push_back(i);
}
cout << res << '\n';
}
}
G
一定是先用完好钥匙再用坏钥匙
所以用了坏钥匙之后的30个箱子之后硬币会变成0
dp
// Problem: G. Good Key, Bad Key
// Contest: Codeforces - Codeforces Round #806 (Div. 4)
// URL: https://codeforces.com/contest/1703/problem/G
// Memory Limit: 256 MB
// Time Limit: 3000 ms
//
// Powered by CP Editor (https://cpeditor.org)
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin >> t;
while (t--)
{
int n, k;
cin >> n >> k;
int a[n];
for (int i = 0; i < n; i++)
{
cin >> a[i];
}
long long ans = 0;
long long sum = 0;
for (int i = -1; i < n; i++)
{
long long now = sum;
for (int j = i + 1; j < min(n, i + 32); j++)
{
int copy = a[j];
copy >>= j - i;
now += copy;
}
ans = max(ans, now);
if (i + 1 != n)
{
sum += a[i + 1] - k;
}
}
cout << ans << endl;
}
return 0;
}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!