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 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
随机推荐
- Exception:kylin构建cube, Cannot modify mapReduce.queue.name at runtime
Failed to open new session: java.lang.IllegalArgumentException: Cannot modify tez.queue.name at runt ...
- 07-Linux文件权限管理
文件的类型 Linux的哲学思想:一切皆文件. Linux的文件分为多种类型. 可以通过ll命令查看文件的类型: ll #输出: -rw-------. 1 root root 1266 2月 29 ...
- 2019 香港区域赛 BDEG 题解
B.Binary Tree 题意:给你一棵二叉树.有两个游戏者,回合制,他们每次可以删去这棵二叉树中的一棵满二叉树.求最后谁赢. 解法:每一棵满二叉树有奇数个节点,那么每次游戏者只能删去奇数个节点,所 ...
- 用Tensorboard在VScode Remote ssh中显示图像
可以用Tensorboard在vscode的ssh连接中显示plot出的图像. 具体方法如下: from torch.utils.tensorboard import SummaryWriter wr ...
- Android Verified Boot 2.0 AVB详解(基于Android P)
原文地址:https://android.googlesource.com/platform/external/avb/+/master/ 译文地址:https://blog.csdn.net/sha ...
- 算法金 | Transformer,一个神奇的算法模型!!
大侠幸会,在下全网同名「算法金」 0 基础转 AI 上岸,多个算法赛 Top 「日更万日,让更多人享受智能乐趣」 抱个拳,送个礼 在现代自然语言处理(NLP)领域,Transformer 模型的出现带 ...
- Java JVM——11. 执行引擎
1.概述 执行引擎属于JVM的下层,里面包括:解释器.即时编译器.垃圾回收器. 执行引擎是Java虚拟机核心的组成部分之一."虚拟机"是一个相对于"物理机"的概 ...
- SpringBoot学习备忘
在 mapper.xml 中的 like 的写法 db1.name like "%"#{name}"%" 参考mybatis mapper.xml中like的写 ...
- Web 安全:OWASP TOP10 漏洞介绍
OWASP TOP 10漏洞是指由Open Web Application Security Project(OWASP)发布的十大最严重. 最普遍的Web应用程序安全漏洞.这些漏洞在当今的Web应用 ...
- 容器技术Docker知识精讲【形成知识体系篇】
作者的经验分享,包括很多实战过程和总结,为着手系统化学习Docker容器的朋友提供. 环境要求 Linux操作系统(Centos),建议在虚拟机VMware或VirtualBox下安装Centos D ...