SMU Autumn 2023 Round 2(Div.1+2)
SMU Autumn 2023 Round 2(Div.1+2)
C. Chaotic Construction
把环展开的话就是\(1 \sim 2n\),若\(D\)的位置放上路障的话,在这个展开的环上就是\(D\)和\(D+n\)的位置,对于\(x,y\),我们就是去看\(D\)或者\(D+n\)是否处于\(x,y\)中间的位置,可以设置一个\(ans = 0\)表示最开始无路障时都能走通,然后对存进\(set\)里的路障二分找到\(x,y\)和\(y,x+n\)中间是否存在路标,若存在,则\(ans+1\),当\(ans = 2\)时说明无论向前还是向后都走不通
#include <bits/stdc++.h>
#define debug(a) cout<<#a<<"="<<a<<'\n';
using namespace std;
using i64 = long long;
typedef pair<i64, i64> PII;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, q;
map<int, int> f;
cin >> n >> q;
set<i64> road;
road.insert(0);
for (int i = 0; i < q; i ++) {
char op;
int x, y;
cin >> op >> x;
if (op == '?') {
cin >> y;
if (x > y) swap(x, y);
if (f[x] || f[y]) {
cout << "impossible\n";
continue;
}
int ans = 0;
auto p = *road.lower_bound(x),q = *road.lower_bound(y);
if(p != q) ans ++ ;
auto pq = *road.lower_bound(x + n);
if(pq != q) ans ++;
cout << (ans > 1 ? "impossible\n" : "possible\n");
} else {
if (op == '-') {
f[x] = 1;
road.insert(x), road.insert(x + n);
}
else {
f[x] = 0;
road.erase(x), road.erase(x + n);
}
}
}
return 0;
}
D. Diabolic Doofenshmirtz
\(1e12\)不会超过\(2^{42}\),所以询问的时候可以倍增地去问,每次记录上一次回答的长度,如果当某次的\(x\)小于了之前记录的长度,说明这个时候刚好已经跑过一圈了,而这个时候的\(x\)是跑了一圈之后的位置,\(now\)是现在跑了的路程,那么\(now - x\)即为一圈的长度了
#include <bits/stdc++.h>
#define debug(a) cout<<#a<<"="<<a<<'\n';
using namespace std;
using i64 = long long;
typedef pair<i64, i64> PII;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
i64 now = 1, last = 0;
for(int i = 1;i <= 42;i ++){
cout << "? " << now << endl;
i64 x;
cin >> x;
if(x <= last){
cout << "! " << now - x << endl;
break;
}
last = x;
now *= 2;
}
return 0;
}
E. Enjoyable Entree
规律题,如果你打表的话就会发现当\(n\)超过\(30\)之后,两个比例都会趋近一个极限\(33.333333\)和\(66.666667\),想到了这点就容易做了
#include <bits/stdc++.h>
#define debug(a) cout<<#a<<"="<<a<<'\n';
using namespace std;
using i64 = long long;
typedef pair<i64, i64> PII;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
i64 n;
cin >> n;
if(n == 1){
cout << "100 0\n";
}else if(n == 2){
cout << "0 100\n";
}else{
if(n > 30){
cout << "33.333333 66.666667\n";
}else{
double ans = 50, a = 50,b = 25;
for(int i = 5;i <= n;i ++){
ans = a / 2 + b / 2;
a = b;
b = ans;
}
if(n == 3)
cout << "50 50\n";
else if(n == 4)
cout << "25 75\n";
else
printf("%.6lf %.6lf\n",ans, 100 - ans);
}
}
return 0;
}
I. Improving IT
\(f[i]\)表示第\(i\)个月赚了多少钱,首先最开始\(dp[1]=0\)表示没有买\(CPU\)时的初值,此后每个月都减掉\(a\)表示新买一个\(CPU\)所花掉的钱,\(dp[i+j]=max(dp[i+j],dp[i]+b)\)则代表第\(i+j\)个月以\(b\)价格卖出第\(i\)月买的\(CPU\)是否会赚的更多
#include <bits/stdc++.h>
#define debug(a) cout<<#a<<"="<<a<<'\n';
using namespace std;
using i64 = long long;
typedef pair<i64, i64> PII;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,m;
cin >> n >> m;
vector<i64> f(n + 2,-LLONG_MAX);
f[1] = 0;
for(int i = 1;i <= n;i ++){
int a;
cin >> a;
f[i] -= a;
for(int j = 1;j <= min(m, n - i + 1);j ++){
int b;
cin >> b;
f[i + j] = max(f[i + j], f[i] + b);
}
}
cout << -f[n + 1] << '\n';
return 0;
}
K. K.O. Kids
当\(f=1\)时应该迈左脚,\(f=0\)时迈右脚,否则的话就丢掉一个人,正常模拟即可
#include <bits/stdc++.h>
#define debug(a) cout<<#a<<"="<<a<<'\n';
using namespace std;
using i64 = long long;
typedef pair<i64, i64> PII;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,k;
string s;
cin >> n >> k >> s;
bool f = 1;
int ans = k;
for(int i = 0;i < n;i ++){
if(f && s[i] != 'L')
ans --;
else if(!f && s[i] != 'R')
ans --;
else f ^= 1;
}
cout << max(0, ans) << '\n';
return 0;
}
L. Lots of Land
当整个矩形的面积不能整除\(n\)时说明不能划分成\(n\)个面积相等的矩形,,否则的话就取\(k = \frac{S}{n}\),则每个小矩形的面积就等于\(k\),则让\(k\)与边或宽取个最大公约数就能计算出小矩形的长和宽,然后就是正常模拟
#include <bits/stdc++.h>
#define debug(a) cout<<#a<<"="<<a<<'\n';
using namespace std;
using i64 = long long;
typedef pair<i64, i64> PII;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int l,w,n;
cin >> l >> w >> n;
vector<string> g(l, string(w, 'A'));
if((l * w) % n != 0){
cout << "IMPOSSIBLE\n" ;
}else{
int k = l * w / n;
char op = 'A';
int L = gcd(k, l), W = k / L;
for(int i = 0;i < l;i ++){
int p = 0;
for(int j = 0;j < w;j ++){
if(j && j % W == 0) p++;
g[i][j] = op + p;
}
if((i + 1) % L == 0) op = op + p + 1;
}
for(auto i : g)
cout << i << '\n';
}
return 0;
}
SMU Autumn 2023 Round 2(Div.1+2)的更多相关文章
- Codeforces Round #845 (Div. 2) and ByteRace 2023 A-D
Codeforces Round #845 (Div. 2) and ByteRace 2023 A-D A. Everybody Likes Good Arrays! 题意:对给定数组进行操作:删除 ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #262 (Div. 2) 1003
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...
- Codeforces Round #262 (Div. 2) 1004
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
- Codeforces Round #268 (Div. 2) ABCD
CF469 Codeforces Round #268 (Div. 2) http://codeforces.com/contest/469 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
随机推荐
- Nginx 静态站点配置不对导致301跳转的坑
背景 是这样的,我们前端服务器统一的入口是 kong网关 ,我们还有一个Nginx静态资源站点:static.mysite.com,根配置如下: location / { root /home/web ...
- 将静态文件打包进nuget里 Net Core
我之前写了一个.net core 生成验证码的小工具 需要使用者先单独下载字体文件到本地在 install-package 感觉这样很捞也很不方便,但当时忙着做其他需求现在更新下. 其实很简单 vis ...
- 记一次 MatPlotLib 报错及解决方案:AttributeError: module 'matplotlib.cbook' has no attribute '_Stack'
记一次 MatPlotLib 报错及解决方案 目录 记一次 MatPlotLib 报错及解决方案 解决方法 具体发生了什么 报错 log 1 内容 报错 log 2 内容 最近出现 MatPlotLi ...
- 09-CentOS软件包管理
简介 CentOS7使用rpm和yum来管理软件包. CentOS 8附带YUM包管理器v4.0.4版本,该版本现在使用DNF (Dandified YUM)技术作为后端.DNF是新一代的YUM,新的 ...
- Win11在VMWare中无tpm条件下安装
Win11在VMWare中无tpm条件下安装 在条件不满足提示的窗口下. 按shift+F10打开cmd, 输入regedit打开注册表, 按如下路径新建三个值后即可 [HKEY_LOCAL_MACH ...
- Linux 内核:设备驱动模型 学习总结
背景 其实之前就转载过别人针对Linux的设备驱动模型(Linux Device Driver Model,LDDM)的文章,但是受限于自身的能力,因此花了点时间重新学习了一下. 前人写的文章很好,我 ...
- Linux驱动:使用workqueue、tasklet处理中断
Linux驱动:使用workqueue.tasklet处理中断 背景 中断服务程序一般都是在中断请求关闭的条件下执行的,以避免嵌套而使中断控制复杂化.但是,中断是一个随机事件,它随时会到来,如果关中断 ...
- 高通Android平台 电池 相关配置
背景 在新基线上移植有关的代码时,在log中发现有关的东西,请教了有关的同事以后,解决了这个问题. [ 12.775863] pmi632_charger: smblib_eval_chg_termi ...
- dot net core使用BackgroundService运行一个后台服务
不管是在控制台程序还是asp.net core程序中,我们经常会有用到一个需要长时间运行的后台任务的需求.通常最直觉的方式是使用Thread实例来新建一个线程,但是这样需要自行管理线程的启动和停止. ...
- 案例分享!RK3568 + FPGA多通道AD采集处理与显示
案例展示 测试数据汇总 表 1 本文带来的是基于瑞芯微RK3568J + 紫光同创Logos-2的ARM + FPGA多通道AD采集处理与显示案例. 本次案例演示的开发环境如下: Wind ...