SMU Autumn 2023 Round 4(Div.1+2)
SMU Autumn 2023 Round 4(Div.1+2)
A. Access Denied
通过分析样例可以得知如果所猜字符串与答案字符串长度不同,则只要\(5ms\),且答案最多\(20\)个字符,因此我们可以先猜20次去核对总字符串长度,如果核对过程中直接猜中了,那就不用继续猜了,又继续分析样例可以得知每遍历一个字符需要消耗\(9ms\),那我们可以对每一位答案的字母一位位地去猜,最多猜\(62\)次,然后最终确定答案字符串,我们在构造初始字符串的时候必须是\(62\)个字符以内的,且又因为构造的是\(62\)位字母内的,所以不排除答案的某些位和我们构造的初始字符串是一样的,导致我们去一位位猜测的时候会刚好有初始的某些位和答案的一样,所以程序就会继续跑,最后返回的结果不是比上一次猜测刚好多\(9ms\),而是更多
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
typedef pair<i64, i64> PII;
char ans[] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I',
'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4',
'5', '6', '7', '8', '9'};
int main() {
int t = 0;
string s, now;
for (int i = 1; i <= 20; i ++) {
t = 0;
s = string(i, '0');
cout << s << endl;
getline(cin, now);
if (now == "ACCESS GRANTED") exit(0);
for (auto j : now)
if (isdigit(j)) t = t * 10 + (j - '0');
if (t != 5) {
t = i;
break;
}
}
string res = string(t, '0');
int T;
for (int i = 0; i < t; i ++) {
for (int j = 0; j < 62; j ++) {
T = 0;
res[i] = ans[j];
cout << res << endl;
getline(cin, now);
if (now == "ACCESS GRANTED") exit(0);
for (auto k : now)
if (isdigit(k)) T = T * 10 + (k - '0');
if (T >= 5 + (i + 2) * 9)
break;
}
}
return 0;
}
J. Jet Set
由题目可知,极点经过了所有经线,且经过所有经线就认为是环游了世界,所以对于两个地点,如果它们的经度刚好相差180,那么这两点走经过经线的那段圆弧即是最短的,也就一定环游了世界,对于其余的点,我们只要看它们两者经度差与180比较,大于180的,说明走反着走更短,否则就正着走更短,且数据较小,我们可以直接循环去标记他经过哪些经线即可
#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;
cin >> n;
vector<int> Wei(n + 1);
for(int i = 0;i < n;i ++){
int x;
cin >> x >> Wei[i];
Wei[i] += 180;
}
Wei[n] = Wei[0];
vector<bool> vis(996,false);
for(int i = 1;i <= n;i ++){
if(abs(Wei[i] - Wei[i - 1]) == 180){
cout << "yes\n";
return 0;
}else if(abs(Wei[i] - Wei[i - 1]) > 180){
for(int j = 0;j <= min(Wei[i],Wei[i - 1]) * 2;j ++){
vis[j] = true;
}
for(int j = max(Wei[i], Wei[i - 1]) * 2;j <= 720;j ++){
vis[j] = true;
}
}else{
for(int j = min(Wei[i], Wei[i - 1]) * 2;j <= max(Wei[i], Wei[i - 1]) * 2;j ++)
vis[j] = true;
}
}
for(int i = 0;i <= 720;i ++){
if(!vis[i]){
printf("no %.1lf\n", (double)i / 2 - 180);
return 0;
}
}
cout << "yes\n";
return 0;
}
K. Knitpicking
题意就是给你一堆混合在一起的袜子,问你最少拿多少只袜子能够配队,\(left\)和\(right\)是分开配对,\(any\)则左右皆可,对于同一类型的袜子,最坏情况下肯定是拿到左右袜子中数量最多的那一堆,对于某类只有\(any\)类型的,我们只需拿\(1\)只即可,把这些加起来,最后随便再拿一只都能完成配对
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
typedef pair<i64, i64> PII;
map<string,array<int,3>> cs;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
bool match = false;
for(int i = 0;i < n;i ++){
string s1,s2;
int k;
cin >> s1 >> s2 >> k;
if(s2 == "left") cs[s1][0] = k;
else if(s2 == "right") cs[s1][1] = k;
else cs[s1][2] = k;
if(s2 == "any" && k > 1) match = true;
else if(s2 == "left" && cs[s1][1]) match = true;
else if(s2 == "right" && cs[s1][0]) match = true;
}
if(!match){
cout << "impossible\n";
}else{
int ans = 0;
for(auto [x,y] : cs){
if(!y[0] && !y[1]) ans ++;
else ans += max(y[0], y[1]);
}
cout << ans + 1 << '\n';
}
return 0;
}
SMU Autumn 2023 Round 4(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 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
随机推荐
- Typora行内公式识别不了
Typora行内公式识别不了,主要是因为行内公式属于LaTeX扩展语法,并非Markdown的通用标准 需要在Typora的"文件"-"偏好设置"-" ...
- FPGA对EEPROM驱动控制(I2C协议)
本文摘要:本文首先对I2C协议的通信模式和AT24C16-EEPROM芯片时序控制进行分析和理解,设计了一个i2c通信方案.人为按下写操作按键后,FPGA(Altera EP4CE10)对EEPROM ...
- 3568F-Docker容器部署方法说明
- Qt实现汽车仪表盘
在UI界面显示中,仪表盘的应用相对比较广泛,经常用于显示速度值,电压电流值等等,最终实现效果如下动态图片(文末提供给源工程下载): 主要包含以下绘制步骤: 绘制画布 /* * 绘制画布 */ void ...
- CF1860C 题解
显然是一个博弈论题,考虑 dp. 定义状态 \(dp_i\) 表示先手走到 \(i\) 之后是否有必胜策略,不难发现以下几点: 若走到 \(i\) 之后无路可走,那么就必败. 若走到 \(i\) 之后 ...
- Mac 版本10.15.4 安装 telnel工具
下载脚本 mac新版本安装telnel发生的变化,进入下面的链接,右键另存为,保存到桌面 https://raw.githubusercontent.com/Homebrew/install/mast ...
- 记一次centos7.9崩溃恢复操作(limits.conf配置失误),救援模式
引起故障的原因:调整了操作系统的内核参数文件limits.conf,* soft nproc 131072 * hard nproc 131072 * soft nofile 65536 * ...
- Python爬虫Post请求返回值为-1000
今天写了一个简单的爬虫程序,为了爬取kfc官网的餐厅数据,代码如下 # ajax的post请求--肯德基官网 def create_request(page): url='http://www.kfc ...
- 重磅消息:微软发布多平台应用UI框架 MAUI,网友直呼:牛x
本文内容来自微软开发博客:https://devblogs.microsoft.com/dotnet/introducing-net-multi-platform-app-ui/ 转载请注明来源,公众 ...
- 广州大学第十八届ACM大学生程序设计竞赛(同步赛)——题解
这套题我答的很失败.没有按照题目的难度去答题,前期浪费了不少时间. 题目: A-字符画 题解:思维.模拟.这道题我的通过率为62.5,没有过的原因是因为对细节的处理和把控不到位,对一些点忽视,我也记录 ...