Codeforces Round 908 (Div. 2)视频详解

2023-11-09 09:31

本文主要是介绍Codeforces Round 908 (Div. 2)视频详解,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Educational Codeforces Round 157 (A--D)视频详解

  • 视频链接
  • A题代码
  • B题代码
  • C题代码
  • D题代码

视频链接

Codeforces Round 908 (Div. 2)视频详解

A题代码

#include<bits/stdc++.h>
#define endl '\n'
#define deb(x) cout << #x << " = " << x << '\n';
#define INF 0x3f3f3f3f
using namespace std;void solve()
{int n;cin >> n;string s;cin >> s;bool fa = false;bool fb = false;for(int y = 1; y <= n; y ++){for(int x = 1; x <= n; x ++){int ca = 0, cb = 0, cat = 0, cbt = 0;for(int i = 0; i < n; i ++){if(s[i] == 'A')ca ++;elsecb ++;if(ca == x){ca = 0, cb = 0;cat ++;}if(cb == x){ca = 0, cb = 0;cbt ++;}if(cat == y){if(i < n - 1)break;fa = true;}if(cbt == y){if(i < n - 1)break;fb = true;}}}}if(fa && !fb){cout << "A" << endl;}else if(fb && !fa){cout << "B" << endl;}	else{cout << "?" << endl;}
}void solve_1()
{int n;cin >> n;string s;cin >> s;cout << s.back() << endl;
}signed main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t;//t = 1;cin >> t;while(t--)solve_1();
}

B题代码

#include<bits/stdc++.h>
#define endl '\n'
#define deb(x) cout << #x << " = " << x << '\n';
#define INF 0x3f3f3f3f
using namespace std;void solve()
{int n;cin >> n;vector<int>a(n);map<int,int>st;for(int i = 0; i < n; i ++){cin >> a[i];st[a[i]] ++;}int cnt = 0;for(auto [a, b]: st)if(b >= 2)cnt ++;if(cnt < 2){cout << -1 << endl;return;}vector<int>b(n);int x = 1;for(int i = 0; i < n; i ++){if(!b[i] && st[a[i]] > 1){int col = 0;for(int j = i; j < n; j ++){if(a[j] == a[i]){b[j] = (col) % 2 + x;col ++;}}x ++;}if(x == 3)break;}for(int i = 0; i < n; i ++){if(!b[i])b[i] = 1;}for(int i = 0; i < n; i ++){cout << b[i] << " ";}cout << endl;
}signed main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t;//t = 1;cin >> t;while(t--)solve();
}

C题代码

#include <bits/stdc++.h>using namespace std;void solve() 
{int n, k;cin >> n >> k;vector<int> a(n + 1);for (int i = 1; i <= n; i++) {cin >> a[i];}k = min(k, n);int last = n;for (int i = 0; i < k; i++) {if (a[last] > n) {cout << "No\n";return;}last -= a[last];if(last <= 0)last += n;}cout << "Yes\n";
}signed main() {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t;cin >> t;while (t--) {solve();}
}

D题代码

#include<bits/stdc++.h>
#define endl '\n'
#define deb(x) cout << #x << " = " << x << '\n';
#define INF 0x3f3f3f3f
using namespace std;bool cmp(int x, int y)
{return x > y;
}
void solve()
{int n, m;cin >> n >> m;vector<int>a(n),b(m);for(int i = 0; i < n; i ++)cin >> a[i];for(int i = 0; i < m; i ++)cin >> b[i];sort(b.begin(), b.end(), cmp);int j = 0;for(int i = 0; i < n; i ++){while(j < m && b[j] >= a[i]){cout << b[j] << " ";j ++;}cout << a[i] << " ";}while(j < m)cout << b[j ++] << " ";cout << endl; 
}signed main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);int t;//t = 1;cin >> t;while(t--)solve();
}

这篇关于Codeforces Round 908 (Div. 2)视频详解的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/375319

相关文章

Python容器转换与共有函数举例详解

《Python容器转换与共有函数举例详解》Python容器是Python编程语言中非常基础且重要的概念,它们提供了数据的存储和组织方式,下面:本文主要介绍Python容器转换与共有函数的相关资料,... 目录python容器转换与共有函数详解一、容器类型概览二、容器类型转换1. 基本容器转换2. 高级转换示

HTML5的input标签的`type`属性值详解和代码示例

《HTML5的input标签的`type`属性值详解和代码示例》HTML5的`input`标签提供了多种`type`属性值,用于创建不同类型的输入控件,满足用户输入的多样化需求,从文本输入、密码输入、... 目录一、引言二、文本类输入类型2.1 text2.2 password2.3 textarea(严格

C++ move 的作用详解及陷阱最佳实践

《C++move的作用详解及陷阱最佳实践》文章详细介绍了C++中的`std::move`函数的作用,包括为什么需要它、它的本质、典型使用场景、以及一些常见陷阱和最佳实践,感兴趣的朋友跟随小编一起看... 目录C++ move 的作用详解一、一句话总结二、为什么需要 move?C++98/03 的痛点⚡C++

Python+FFmpeg实现视频自动化处理的完整指南

《Python+FFmpeg实现视频自动化处理的完整指南》本文总结了一套在Python中使用subprocess.run调用FFmpeg进行视频自动化处理的解决方案,涵盖了跨平台硬件加速、中间素材处理... 目录一、 跨平台硬件加速:统一接口设计1. 核心映射逻辑2. python 实现代码二、 中间素材处

MySQL中between and的基本用法、范围查询示例详解

《MySQL中betweenand的基本用法、范围查询示例详解》BETWEENAND操作符在MySQL中用于选择在两个值之间的数据,包括边界值,它支持数值和日期类型,示例展示了如何使用BETWEEN... 目录一、between and语法二、使用示例2.1、betwphpeen and数值查询2.2、be

python中的flask_sqlalchemy的使用及示例详解

《python中的flask_sqlalchemy的使用及示例详解》文章主要介绍了在使用SQLAlchemy创建模型实例时,通过元类动态创建实例的方式,并说明了如何在实例化时执行__init__方法,... 目录@orm.reconstructorSQLAlchemy的回滚关联其他模型数据库基本操作将数据添

Java中ArrayList与顺序表示例详解

《Java中ArrayList与顺序表示例详解》顺序表是在计算机内存中以数组的形式保存的线性表,是指用一组地址连续的存储单元依次存储数据元素的线性结构,:本文主要介绍Java中ArrayList与... 目录前言一、Java集合框架核心接口与分类ArrayList二、顺序表数据结构中的顺序表三、常用代码手动

JAVA线程的周期及调度机制详解

《JAVA线程的周期及调度机制详解》Java线程的生命周期包括NEW、RUNNABLE、BLOCKED、WAITING、TIMED_WAITING和TERMINATED,线程调度依赖操作系统,采用抢占... 目录Java线程的生命周期线程状态转换示例代码JAVA线程调度机制优先级设置示例注意事项JAVA线程

详解C++ 存储二进制数据容器的几种方法

《详解C++存储二进制数据容器的几种方法》本文主要介绍了详解C++存储二进制数据容器,包括std::vector、std::array、std::string、std::bitset和std::ve... 目录1.std::vector<uint8_t>(最常用)特点:适用场景:示例:2.std::arra

C++构造函数中explicit详解

《C++构造函数中explicit详解》explicit关键字用于修饰单参数构造函数或可以看作单参数的构造函数,阻止编译器进行隐式类型转换或拷贝初始化,本文就来介绍explicit的使用,感兴趣的可以... 目录1. 什么是explicit2. 隐式转换的问题3.explicit的使用示例基本用法多参数构造