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的更多相关文章

  1. 2015 Astar Contest - Round 3 题解

    1001 数长方形 题目大意 平面内有N条平行于坐标轴的线段,且不会在端点处相交 问共形成多少个矩形 算法思路 枚举4条线段的全部组合.分别作为矩形四条边.推断是否合法 时间复杂度: O(N4) 代码 ...

  2. Contest Round #451 (Div. 2)F/Problemset 898F Restoring the Expression

    题意: 有一个a+b=c的等式,去掉两个符号,把三个数连在一起得到一个数 给出这个数,要求还原等式,length <= 1e6 三个数不能含有前导0,保证有解 解法: 铁头过题法,分类然后各种判 ...

  3. 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 ...

  4. Sending messages to non-windowed applications -- AllocateHWnd, DeallocateHWnd

    http://delphi.about.com/od/windowsshellapi/l/aa093003a.htm Page 1: How Delphi dispatches messages in ...

  5. Codeforces 240 F. TorCoder

    F. TorCoder time limit per test 3 seconds memory limit per test 256 megabytes input input.txt output ...

  6. cf499B-Lecture 【map】

    http://codeforces.com/problemset/problem/499/B B. Lecture     You have a new professor of graph theo ...

  7. Codeforces 240F. TorCoder 线段树

    线段树统计和维护某一区间内的字母个数.. . . F. TorCoder time limit per test 3 seconds memory limit per test 256 megabyt ...

  8. 物联网学生科协第三届H-star现场编程比赛

    问题 A: 剪纸片 时间限制: 1 Sec 内存限制: 128 MB 题目描写叙述 这是一道简单的题目,假如你身边有一张纸.一把剪刀.在H-star的比赛现场,你会这么做: 1. 将这张纸剪成两片(平 ...

  9. [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 ...

  10. 水题 Codeforces Round #307 (Div. 2) A. GukiZ and Contest

    题目传送门 /* 水题:开个结构体,rk记录排名,相同的值有相同的排名 */ #include <cstdio> #include <cstring> #include < ...

随机推荐

  1. 结构型模式(Structural Pattern)

    模式介绍 结构型模式(Structural Pattern)的主要目的就是将不同的类和对象组合在一起,形成更大或者更复杂的结构体.该模式并不是简单地将这些类或对象摆放在一起,而是要提供它们之间的关联方 ...

  2. Lru-k在Rust中的实现及源码解析

    LRU-K 是一种缓存淘汰算法,旨在改进传统的LRU(Least Recently Used,最近最少使用)算法的性能.将其中高频的数据达到K次访问移入到另一个队列进行保护. 算法思想 LRU-K中的 ...

  3. 在Python中输出当前文件名和行号

    在Python中输出当前文件名和行号 用 inspect 库 info = inspect.currentframe() print('DEBUG!! ',info.f_code.co_filenam ...

  4. 【路径规划】OSQP曲线平滑 公式及代码

    参考与前言 apollo 代码:https://github.com/ApolloAuto/apollo/tree/master/modules/planning/math/smoothing_spl ...

  5. 3568F-物联网模块开发案例

  6. LaTeX 编辑协作平台 Overleaf 安装和使用教程

    在学术界和科技行业,LaTeX 已成为撰写高质量文档的标准工具.然而,传统的 LaTeX 使用体验常常伴随着以下挑战: 学习曲线陡峭 环境配置复杂 多人协作困难 实时预览不便 当然,市面上不乏很多在线 ...

  7. 粗枝大叶记录一下java9模块化改造一个项目的过程(Jigsaw)

    假设项目结构如下: 其中的依赖关系为 我实际用的jdk是17 1. common模块创建描述文件,在common的src/main/java下创建module-info.java, 内容默认 /** ...

  8. Win10 内存内存占用过高的一种解决方案

    前言 最近win10的电脑一开机,什么都没启动,内存占用率高达90%,笔记本虽然是8G的内存,但不应该如此不堪.在网上找到一个十分有效的解决方案. 正文 使用 win10系统自带内存诊断工具 按下 h ...

  9. 面试官:Java线程可以无限创建吗?

    哈喽,大家好,我是世杰. 本次给大家介绍一下操作系统线程和Java的线程以及二者的关联 1. 面试连环call Java线程可以无限创建吗? Java线程和操作系统线程有什么关联? 操作系统为什么要区 ...

  10. P1387

    #include<iostream> #include<utility> using namespace std; typedef long long ll; #define ...