当前位置: 首页 > news >正文

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();
}
http://www.lryc.cn/news/227591.html

相关文章:

  • 电路综合-基于简化实频的SRFT集总参数切比雪夫低通滤波器设计
  • Linux系统编程——实现cp指令(应用)
  • 20231112_DNS详解
  • 使用ssh上传数据到阿里云ESC云服务上
  • 【408】计算机学科专业基础 - 数据结构
  • SpringSpringBoot自动装配
  • k8s 部署mqtt —— 筑梦之路
  • 模型部署:量化中的Post-Training-Quantization(PTQ)和Quantization-Aware-Training(QAT)
  • C++模板元模板(异类词典与policy模板)- - - 题目答案
  • 二十三种设计模式全面解析-组合模式与迭代器模式的结合应用:构建灵活可扩展的对象结构
  • postgresql|数据库|提升查询性能的物化视图解析
  • Unity中Shader雾效的原理
  • chatgpt辅助论文优化表达
  • Vue3 源码解读系列(二)——初始化应用实例
  • 网络原理-UDP/TCP详解
  • C#多线程入门概念及技巧
  • c primer plus_chapter_four——字符串和格式化输入/输出
  • Python Fastapi+Vue+JWT实现注册、登录、状态续签【登录保持】
  • oracle-sql语句解析类型
  • 2023 年最新企业微信官方会话机器人开发详细教程(更新中)
  • 3、FFmpeg基础
  • c语言:用指针解决有关字符串等问题
  • 吃透 Spring 系列—Web部分
  • JAVA后端服务端与移动端客户端高精度时间同步思路
  • nsd的资料
  • 关于Maven中pom.xml文件不报错但无法导包解决方法
  • 使用决策树分类
  • STM32H563烧录后无法擦除
  • 2023最新最全【Adobe After Effection 2023】下载安装零基础教程【附安装包】
  • 【Spring之底层核心架构概念解析】