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 开学了,时间少,水题就不写题解了,不水的题也不写这么详细了 ...
随机推荐
- Vim编辑的小技巧
Vim编辑的小技巧 如何快速纠错 Ctrl + h 删除上一个字符, Ctrl + w 删除上一个单词, Ctrl + u 删除当前行. 从编辑模式快速切换到Nornal模式 1.Esc 2.Ctrl ...
- .NET 个人博客-给图片添加水印
个人博客-给图片添加水印 前言 需要用到的库 SixLabors.lmageSharp 2.1.3 SixLabors.lmageSharp.Web 2.0.2 SixLabors.Fonts 1.0 ...
- 格式化显示JSON数据
测试JSON {"took":1,"timed_out":false,"_shards":{"total":1,&quo ...
- 3568F-翼辉SylixOS国产操作系统演示案例
- AT_joisc2019_j 题解
先考虑这个式子: \[\sum_{j=1}^{M} |C_{k_{j}} - C_{k_{j+1}}| \] 一定是在 \(C\) 有序时取到,具体证明很简单各位读者自己证明. 那么现在式子变成: \ ...
- python3 socket 获取域名信息
可以当ping用,应用场景可以在一些没有安装ping工具的镜像容器中,诊断dns或域名的可用性. #-*- coding:utf-8 -*- import socket import tracebac ...
- 微服务网关Gateway使用
为什么需要网关? Gateway网关是我们服务的守门神,所有微服务的统一入口. 网关的核心功能特性 请求路由和负载均衡 一切请求都必须先经过gateway,但网关不处理业务,而是根据某种规则,把请求转 ...
- vue3 'alex' is defined but never used
解决方法 在package.json中的rules下加入 "no-unused-vars":"off" 即可
- mac idea快捷键整理
抽取局部变量 option+commamd+v 生成方法内变量 option+commamd+f 生成类的静态变量 找方法 2次shift 优化import Ctrl + Alt + O 格式化代码 ...
- python执行shell并获取结果
在Python中执行Shell命令并获取其结果,通常可以使用subprocess模块.这个模块允许我们启动新的进程,连接到它们的输入/输出/错误管道,并获取它们的返回码.下面是一个详细的示例,展示了如 ...