当前位置:网站首页>codeforce round#784(div4) A-H
codeforce round#784(div4) A-H
2022-04-22 23:06:00 【eva_ can(not)survive】
I just called cf A few days , If the explanation is not clear, please understand or leave a message in the comment area , And thank you for div4 The number of sessions makes me feel AK Happiness
Problem - A - CodeforcesCodeforces. Programming competitions and contests, programming community
https://codeforces.com/contest/1669/problem/AA There is no need to say more about the problem , Namely for+if else
inline void solve() {
int n;
scanf("%d", &n);
if (n <= 1399) {
printf("Division 4\n");
} else if (n > 1399 && n <= 1599) {
printf("Division 3\n");
} else if (n > 1599 && n <= 1899) {
printf("Division 2\n");
} else {
printf("Division 1\n");
}
}
Problem - B - Codeforces
https://codeforces.com/contest/1669/problem/B This problem is to count the numbers in the array , As long as a number appears 3 Once, you can directly output , It can be used map Realization
void solve() {
int n;
scanf("%d", &n);
map<int, int> mp;
int a;
bool flag = true;
for (int i = 1; i <= n; i++) {
scanf("%d", &a);
if (flag)
if (++mp[a] >= 3) {
printf("%d\n", a);
flag = false;
//break;
}
}
if (flag)
printf("-1\n");
}
Problem - C - CodeforcesCodeforces. Programming competitions and contests, programming community
https://codeforces.com/contest/1669/problem/C Directly record the first two digits of the array , Odd digit and odd digit last1 Parity is different or even digits are different from last If the parity is different, you can never get a fully even or fully odd sequence
inline void solve() {
int n;
scanf("%d", &n);
if (n == 2) {
printf("YES\n");
return;
}
int last1;
int last2;
scanf("%d %d", &last1, &last2);
int t;
bool flag = true;
for (int i = 3; i <= n; i++) {
scanf("%d", &t);
if (flag)
if (i & 1) {
if (last1 % 2 != t % 2) {
flag = false;
}
} else {
if (last2 % 2 != t % 2) {
flag = false;
}
}
}
if (flag) {
printf("YES\n");
} else {
printf("NO\n");
}
}
Problem - D - Codeforces
https://codeforces.com/contest/1669/problem/D Can think of meeting in W The length of any previous sequence is greater than or equal to 2 Of BR Sequences can be mimeographed from lottery tickets , But only R or B The sequence cannot be printed , Then simulate this operation .
inline void solve() {
int n;
scanf("%d", &n);
string s;
cin >> s;
if (n == 1 && s[0] != 'W') {
printf("NO\n");
return ;
}
int cnt = 0;
char last;
bool flag = true;
map<char, int> mp;
for (int i = 0; i < s.length(); i++) {
mp[s[i]] = 1;
if (flag)
if (s[i] == 'W') {
if (cnt == 1) {
flag = false;
}
if ((mp['B'] + mp['R']) % 2) {
flag = false;
}
cnt = 0;
mp['B'] = 0;
mp['R'] = 0;
} else {
cnt++;
}
}
if (cnt == 1 || (mp['B'] + mp['R']) % 2) {
flag = false;
}
if (flag) {
printf("YES\n");
} else {
printf("NO\n");
}
}
Problem - F - Codeforces
https://codeforces.com/contest/1669/problem/F The first A The candy you can eat from the left map Prepare for it , Then start eating one by one from the right , If the number of sweets eaten by two people can be less than or equal to n And if they eat the same food together, update the answer , If two people eat the same amount, but the total number of two people exceeds n You can exit directly , Because it can't be established after .
ll s[MAXN];
inline void solve() {
int n;
scanf("%d", &n);
map<ll, int> mp;
ll sum = 0;
for (int i = 1; i <= n; i++) {
scanf("%lld", s + i);
sum += s[i];
mp[sum] = i;
}
int t;
ll cnt = 0;
bool flag = true;
sum = 0;
for (int i = n; i >= 1; i--) {
sum += s[i];
//printf("%d ", t);
if (mp[sum]) {
if (mp[sum] + n - i + 1 > n) {
break;
}
cnt = mp[sum] + n - i + 1;
}
}
printf("%lld\n", cnt);
}
Problem - E - Codeforces
https://codeforces.com/contest/1669/problem/E Can pass map To record the number of first and second characters , It also records the number of times the string appears , When it is recorded to the i If a string is preceded by the same string as the first bit or the same string as the second bit, add , If this string has appeared before, subtract its *2, Because the first and second places are counted .
inline void solve() {
int n;
scanf("%d", &n);
string s;
map<string, int> mp;
map<char, int> mp1;
map<char, int> mp2;
ll ans = 0;
for (int i = 1; i <= n; i++) {
cin >> s;
ans += mp1[s[0]]++;
ans += mp2[s[1]]++;
ans -= mp[s] * 2;
mp[s]++;
}
printf("%lld\n", ans);
}
Problem - H - CodeforcesCodeforces. Programming competitions and contests, programming community
https://codeforces.com/contest/1669/problem/H The meaning of the question is very clear, which is to start from the highest position and find out whether to change that position 1, First record the number of occurrences of each bit of each number in the array , Then start from the highest level to see whether the remaining operations can support its change 1
ll a[MAXN];
inline void solve() {
int n, k;
int b[50] = {0};
scanf("%d %d", &n, &k);
for (int i = 1; i <= n; i++) {
scanf("%d", a + i);
for (int j = 0; j <= 30; j++) {
if ((a[i] >> j) & 1) {
b[j]++;
}
}
}
int ans = 0;
for (int i = 30; i >= 0; i--) {
if (k >= n - b[i]) {
k -= n - b[i];
ans |= 1 << i;
}
}
printf("%d\n", ans);
}
版权声明
本文为[eva_ can(not)survive]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204222257060161.html
边栏推荐
- 登录功能&新增文章功能的测试点提取以及测试用例编写
- Query uid from proc
- [Swift]代码触发UIButton的点击事件
- Cron expression
- Codeforce1669 A和B
- 常用搜索引擎及语法
- L1-069 胎压监测 (15 分)
- Quantitative-c language implementation of equivalent domino pairs
- WebRTC系列-WebRTC基础(七)NAT、stun和turn(2)
- Multi thread thread communication (wait notify, await single, park unpark)
猜你喜欢

Enter a formula in the Visio text box

C add log4net log (console and file) to console application

CVPR 2022: is smile recognition also sexist? Zhejiang University and Wuhan University jointly set up a fairness improvement framework
![[Error]dyld: Library not loaded:](/img/41/bb00c6f34021bcda0e666455a08c1c.png)
[Error]dyld: Library not loaded:
![[reproduction of thesis code] errors encountered in the translation embeddings for modeling multi relational data](/img/80/43b7cedaa4c5e98cac61c79dfa37bd.png)
[reproduction of thesis code] errors encountered in the translation embeddings for modeling multi relational data

GDB调试程序的核心技术-ptrace系统调用与使用示例

Utilisation et principes de base de minio

Dart:在循环中使用 Async 和 Await
![Le Code [SWIFT] déclenche l'événement de clic d'uibutton](/img/23/444cfab44afe32d0476ba26f64bfdf.png)
Le Code [SWIFT] déclenche l'événement de clic d'uibutton

CSV column extract column extraction
随机推荐
how to become professional
Basic use and principle of Minio
新闻速递 I MobTech通过中国信通院“安全专项评测”
Online yaml to XML tool
在线YAML转XML工具
不谈赛道,不聊风口,开源数据库巨头Cassandra如何在国内讲好“新故事”
LeetCode 16. 最接近的三数之和(中等、数组)day13
KunlunDB对MySQL私有DML语法的支持
加密模式介绍(ECB、CBC、PCBC、CFB、OFB、CTR)
高数 | 【多元函数微分学及应用】易错题 及 李林880详解
L1-068 调和平均 (10 分)
解决require is not defined的报错问题
L1-065 嫑废话上代码 (5 分)
SQL语言详解
光学指纹模组解锁方案设计指纹锁方案
How to modify the QR code style when scanning the code and logging in the background management system of enterprise wechat
News Express I mobtech passed the "special safety evaluation" of China Academy of information and communications
挖财学堂的证券账户可靠吗?现在开户安全不?用哪个券商比较好?
L1-073 人与神 (5 分)
辰视工业级机器视觉 | 焊缝检测解决方案