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 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
随机推荐
- python 方法调用另一个方法报错,捕获的异常只有message,优化为trackback捕获详细的报错信息
A方法加了try...expect... B方法也加了try....expect... B方法调用了A方法,A方法查找元素,找不到报超时异常,实际B捕获到的异常,只有message\n,没有办法看出是 ...
- 01-前端开发Vscode插件配置
01 自动保存配置 02 空格渲染方式 配置好以后,可以看到代码的空格有几个,以点的方式呈现,1个点表示1个空格 03 图标插件 VSCode Great Icons 04 缩进 推荐使用2 05 v ...
- TrustZone与高通
改编自:https://blog.csdn.net/guyongqiangx/article/details/78020257 介绍 导读 Q:什么是Trust Zone A:Trust Zone:是 ...
- HTTP 协议学习:1-HTTP概述
背景 原文:HTTP概述 HTTP是一种能够获取如 HTML 这样的网络资源的 protocol(通讯协议).它是在 Web 上进行数据交换的基础,是一种 client-server 协议,也就是说, ...
- Linux 特权 SUID/SGID 的详解
导航 0 前言 1 权限匹配流程 2 五种身份变化 3 有效用户/组 4 特权对 Shell 脚本无效 5 Sudo 与 SUID/SGID 的优先级 6 SUID.SGID.Sticky 各自的功能 ...
- FPGA案例开发手册——基于全志T3+Logos FPGA核心板
前 言 本文档主要提供评估板FPGA端案例测试方法,适用的开发环境为Windows 7 64bit和Windows 10 64bit. 本文案例基于创龙科技的全志T3+Logos FPGA核心板,它是 ...
- Nuxt3 的生命周期和钩子函数(十一)
title: Nuxt3 的生命周期和钩子函数(十一) date: 2024/7/5 updated: 2024/7/5 author: cmdragon excerpt: 摘要:本文详细介绍了Nux ...
- VUE商城项目 -权限功能 - 手稿
- Java 集合元素排序接口Comparable
什么是Comparable public interface Comparable<T> { /** * Compares this object with the specified o ...
- Navicat for mysql 无法连接到虚拟机的linux系统下的mysql
最近在linux Centos7版本的虚拟机上安装了一个MySql数据库,发现本地可以正常ping通虚拟机,但Navicat则无法正常连接到虚拟机里的MySql数据库,经过一番琢磨,发现解决这个问题的 ...