SMU Summer 2023 Contest Round 4
SMU Summer 2023 Contest Round 4
A. Telephone Number
满足第一个8后面存在10个字符即可
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
int n,m;
void solve(){
cin >> n;
string s;
cin >> s;
int p = s.find_first_of('8') ;
if(p > n - 11 || p == -1 || n < 11)
cout << "NO" << endl;
else
cout << "YES" << endl;
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int Ke_scholar = 1;
cin >> Ke_scholar;
while(Ke_scholar--)
solve();
return 0;
}
B. Lost Numbers
因为只有6个数,所以可以直接用\(next\_permutation\)全排列暴力匹配,不要关闭流同步!!!
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
int n,m;
void solve(){
int res[5];
for(int i = 1;i <= 4;i ++){
cout << "? " << i << ' ' << i + 1 << endl;
fflush(stdout);
cin >> n;
res[i] = n;
}
int ans[] = {0,4,8,15,16,23,42};
do{
if(ans[1] * ans[2] == res[1] && ans[2] * ans[3] == res[2] && ans[3] * ans[4] == res[3] && ans[4] * ans[5] == res[4]){
cout << '!';
for(int i = 1;i <= 6;i ++)
cout << ' ' << ans[i];
cout << endl;
fflush(stdout);
break;
}
}while(next_permutation(ans + 1,ans + 7));
}
signed main()
{
// ios::sync_with_stdio(false);
// cin.tie(nullptr);cout.tie(nullptr);
int Ke_scholar = 1;
// cin >> Ke_scholar;
while(Ke_scholar--)
solve();
return 0;
}
C. News Distribution
用并查集维护每个人所在的圈子,然后循环每个人所在的圈子\(++\)
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
int n,m;
void solve(){
cin >>n >> m;
vector<int> fa(n + 1);
vector<int> ans(n + 1,0);
iota(fa.begin(),fa.end(),0);
auto find = [&](auto self,int x)->int {
return fa[x] == x ? x : (fa[x] = self(self,fa[x]));
};
auto add = [&](int x,int y){
fa[find(find,x)] = find(find,y);
};
for(int i = 1;i <= m;i ++){
int k,o,p;
cin >> k;
if(k) cin >> o;
for(int j = 1;j < k;j++){
cin >> p;
add(o,p);
}
}
for(int i = 1;i <= n;i++)
ans[find(find,i)]++;
for(int i = 1;i <= n;i ++){
cout << ans[find(find,i)] << ' ';
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int Ke_scholar = 1;
// cin >> Ke_scholar;
while(Ke_scholar--)
solve();
return 0;
}
D. Bicolored RBS
\(r\)和\(b\)左右括号每相隔一个交叉染色即可
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define inf 0x3f3f3f3f
using namespace std;
int n,m;
int zr,zb;
void solve(){
string s;
cin >> n >> s;
stack<char> r,b;
for(int i = 0;i < n;i ++){
if(s[i] == '('){
if(zr & 1){
cout << 0;
}else{
cout << 1;
}
zr++;
}else{
if(zb & 1){
cout << 0;
}else{
cout << 1;
}
zb++;
}
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
int Ke_scholar = 1;
// cin >> Ke_scholar;
while(Ke_scholar--)
solve();
return 0;
}
SMU Summer 2023 Contest Round 4的更多相关文章
- 2015 Astar Contest - Round 3 题解
1001 数长方形 题目大意 平面内有N条平行于坐标轴的线段,且不会在端点处相交 问共形成多少个矩形 算法思路 枚举4条线段的全部组合.分别作为矩形四条边.推断是否合法 时间复杂度: O(N4) 代码 ...
- Contest Round #451 (Div. 2)F/Problemset 898F Restoring the Expression
题意: 有一个a+b=c的等式,去掉两个符号,把三个数连在一起得到一个数 给出这个数,要求还原等式,length <= 1e6 三个数不能含有前导0,保证有解 解法: 铁头过题法,分类然后各种判 ...
- Codeforces Round #284 (Div. 2)A B C 模拟 数学
A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Sending messages to non-windowed applications -- AllocateHWnd, DeallocateHWnd
http://delphi.about.com/od/windowsshellapi/l/aa093003a.htm Page 1: How Delphi dispatches messages in ...
- Codeforces 240 F. TorCoder
F. TorCoder time limit per test 3 seconds memory limit per test 256 megabytes input input.txt output ...
- cf499B-Lecture 【map】
http://codeforces.com/problemset/problem/499/B B. Lecture You have a new professor of graph theo ...
- Codeforces 240F. TorCoder 线段树
线段树统计和维护某一区间内的字母个数.. . . F. TorCoder time limit per test 3 seconds memory limit per test 256 megabyt ...
- 物联网学生科协第三届H-star现场编程比赛
问题 A: 剪纸片 时间限制: 1 Sec 内存限制: 128 MB 题目描写叙述 这是一道简单的题目,假如你身边有一张纸.一把剪刀.在H-star的比赛现场,你会这么做: 1. 将这张纸剪成两片(平 ...
- [cf contest 893(edu round 33)] F - Subtree Minimum Query
[cf contest 893(edu round 33)] F - Subtree Minimum Query time limit per test 6 seconds memory limit ...
- 水题 Codeforces Round #307 (Div. 2) A. GukiZ and Contest
题目传送门 /* 水题:开个结构体,rk记录排名,相同的值有相同的排名 */ #include <cstdio> #include <cstring> #include < ...
随机推荐
- Java基础(二)继承剖析
继承剖析 1 若是要直接调用父类的构造方法,不调用子类的方法则需要使用的是super()关键字 Publicclass Child extends Parent { Public C ...
- nacos v2.2 k8s部署启动报错:nacos server did not start because dumpservice bean construction failure. errMsg102, errllsg dataSource or tableName is null
背景 最近搭建个nacos环境,用的镜像是2.2版本的,yaml如下: nacos-conf apiVersion: v1 kind: ConfigMap metadata: name: nacos- ...
- textFieldShouldReturn: 方法无效化!
问题描述 不管如何在键盘上点击return,textFieldShouldReturn:方法一直没有调用. 问题代码 @interface ViewController : UIViewControl ...
- Linux下挂载NTFS格式的U盘
NTFS是Windows下的格式,在Linux下是识别不了的,要想在Linux上挂载NTFS格式的U盘需要安装软件以提供支持.软件名为ntfs-3g. 1.下载安装包 https://tuxera.c ...
- 打开ftp服务器上的文件夹时发生错误,请检查是否有权限访问该文件夹
产生这种现象有很多方面的原因 如果你能用命令行的方式访问ftp服务器,但是不能用资源管理器访问,那么请看下去. 1.打开IE浏览器,点击设置 2.点击Internet选项,进入高级 3.取消勾选 大功 ...
- Freertos学习:08-信号量
--- title: rtos-freertos-08-ipc-semaphore date: 2020-06-23 11:01:12 categories: tags: - freertos - i ...
- 瑞芯微RK3568J如何“调节主频”,实现功耗降低?一文教会您!
RK3568J主频模式说明 为降低RK3568J功耗,提高运行系统健壮性,在产品现场对RK3568J实现主频调节则显得尤为重要. 图 1 RK3568J官方数据手册主频模式描述 normal模式 根据 ...
- 脚本与数据的解耦 + Page Object模型
标签(空格分隔): 脚本与数据的解耦 + Page Object模型 测试脚本和数据的解耦 你现在已经掌握了一些基本的 GUI 自动化测试用例的实现方法,是不是正摩拳擦掌准备批量开发 GUI 自动化脚 ...
- Spring(注解方式)简单入门
环境准备 maven jdk Spring Eclipse 项目创建 pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0 ...
- CF717E
这道题属于是那种看上去很有思路,然后无从下手,写了个dfs感觉实在是不行. 后面仔细看了一下,这个题是用的构造dfs,基本是树上dfs,时间复杂度是O(V+E) 新构造的一个参数作为根,整个dfs表示 ...