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 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
随机推荐
- 01-Linux系统介绍、安装与入门
关于Linux 背景 最先出现的是Unix操作系统,这种操作系统收费,而且适用于大型机上面. Linus想做一个免费的,传播自由的操作系统.他就仿照Unix的操作,做了一个类Unix系统:Linux内 ...
- Java面试知识点(六)hashmap深度理解
1.hashmap 的数据结构 要知道 hashmap 是什么,首先要搞清楚它的数据结构,在 java 编程语言中,最基本的结构就是两种,一个是数组,另外一个是模拟指针(引用),所有的数据结构都可以用 ...
- Java中代码Bug记录--泛型失效、数组删除、HashMap死循环
最近在工作的过程中,遇到了不少奇怪自己或者同事的Bug,都是一些出乎意料的,不太容易发现的,记录一下来帮助可能也遇到了这些Bug的人 1. 编译时泛型校验失效 Map<String, Strin ...
- Servlet之Request和Response的快速上手
阅读提示: 前置内容 MyBatis知识点总结 HTTP和Servlet入门 目录 1.Request和Response概述 2.Request对象 2.1 Request继承体系 2.2 Reque ...
- Java-EL表达式替换和简化jsp页面中java代码的编写
概念:Expression Language 表达式语言 作用:替换和简化jsp页面中java代码的编写 语法:$ 注意: jsp默认支持el表达式,如果要忽略el表达式 设置jsp中page指令中: ...
- Zabbix 5.0 LTS URL 健康监测
更多细节详情看[zabbix官方文档] 需求 Zabbix 的URL健康监测功能允许你检测 Web 地址是否可用.正常工作以及响应速度.这对于监控网站的可用性和性能非常有用.例如,你可以监控公司网站. ...
- 网易数帆内核团队:memory cgroup 泄漏问题的分析与解决
memory cgroup 泄露是 K8s(Kubernetes) 集群中普遍存在的问题,轻则导致节点内存资源紧张,重则导致节点无响应只能重启服务器恢复:大多数的开发人员会采用定期 drop cach ...
- WebGL压缩纹理实践
0x01 本文将讲述压缩纹理在实际项目中的使用的案例.最近的一个项目是这样的:项目由于涉及到的建筑物特别多,大概有近40栋的建筑,而每一栋建筑物,又有10层楼,每层楼里面又有很多的设备.这就导致我们需 ...
- [oeasy]python0095_乔布斯求职_雅达利_atari_breakout_打砖块_布什内尔_游戏机_Jobs
编码进化 回忆上次内容 上次 我们回顾了 电子游戏的历史 从 电子游戏鼻祖 双人网球 到 视频游戏 PingPong 再到 街机游戏 Pong 雅达利 公司 来了 嬉皮士 捣乱? 布什内尔 会如何 应 ...
- Django 用户认证系统使用总结
Django用户认证系统使用总结 by:授客 QQ:1033553122 测试环境 Win7 Django 1.11 使用Django认证系统 本文按默认配置讲解Django认证系统的用法.如果默 ...