SMU Summer 2023 Contest Round 11(2022-2023 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2022))
SMU Summer 2023 Contest Round 11(2022-2023 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2022))
A. Ace Arbiter
用\(A\)和\(B\)代表\(Alice\)和\(Bob\),则轮到\(Alice\)发球时会给出\(A - B\)的比分,轮到\(Bob\)时给出\(B-A\)的比分,直接比较还是挺难的,但是如果统一的都是\(A-B\)或者\(B-A\)的比分,那我们只要去判断每一轮的\(Alice\)和\(Bob\)的比分是不是大于等于上一轮的分数,如果少了,说明这次记录是错误的,另外如果有一方到达11分了,那么比赛应该结束了,不可能还继续比赛,还有就是\(11-11\)这种比分是不可能出现的.
那么问题来了,我们怎么去统一这个比分呢?
题目已给出发球顺序\(A,B,B,A,A,B,B\dots\),可以看出,除了第一轮\(Alice\)单独发球外,其余都是四轮一循环,且每一轮必定有一方会加分,所以我们可以将分数减掉\(Alice\)那一次,然后去 \(\bmod 4\),得到\(0\)或者\(1\)就说明这次是\(Bod\)发球,这个时候我们将比分对调,然后按照上面说的去判断即可.
#include<bits/stdc++.h>
using namespace std;
int32_t main() {
int n;
cin >> n;
vector<int> a(n + 1), b(n + 1);
char op;
for (int i = 1; i <= n; i++)
cin >> a[i] >> op >> b[i];
bool end = false;
for(int i = 1;i <= n;i ++){
int sorce = max(a[i] + b[i] - 1,0);
if(sorce % 4 == 0 || sorce % 4 == 1)
swap(a[i],b[i]);
if(end && a[i] != a[i - 1] || end && b[i] != b[i - 1]|| a[i] == 11 && b[i] == 11){
cout << "error " << i << '\n';
return 0;
}
if(a[i] < a[i - 1] || b[i] < b[i - 1]){
cout << "error " << i << '\n';
return 0;
}
if(a[i] == 11 || b[i] == 11)
end = true;
}
cout << "ok\n";
return 0;
}
C. Coffee Cup Combo
每个1可以将后面两个数变成1,但是由0变化来的1不能影响后面的数,按题意模拟即可
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
string s;
cin >> n >> s;
string sss = s;
for(int i = 0;i < n;i ++){
if(s[i] == '1'){
sss[i] = '1';
if(i + 1 < n) sss[i + 1] = '1';
if(i + 2 < n) sss[i + 2] = '1';
}
}
int ans = 0;
for(auto i : sss)
ans += (i == '1');
cout << ans << '\n';
return 0;
}
D. Disc District
多写几组数据可发现,其实\((r,1)\)也是符合答案
#include<bits/stdc++.h>
using namespace std;
int main() {
long long r;
cin >> r;
cout << r << ' ' << 1 << endl;
return 0;
}
G. Graduation Guarantee(期望dp)
先将概率从大到小排序(肯定要先做概率大的才能拿分嘛),然后就是\(dp\)数组的初始化,初始就是前面\(i\)道题做错.
你要想在前\(i\)道题里做对\(j\)道题,要么就是做对第\(j\)题,那么你前\((i-1)\)道题就要做对\((j-1)\)道题,要么就是不做第\(j\)道题,那你前\((i-1)\)道题就要做对\(j\)道题,由此得出转移方程
\(dp[i][j] = p[i] \times dp[i-1][j-1] + (1 - p[i]) \times dp[i-1][j]\)
\(i - (i-k)/2\)是说你在做对超出\(k\)道题时需要做错相应的题使你的总对题数维持在\(k\)
#include<bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n,k;
cin >> n >> k;
std::vector<double> p(n + 1);
for(int i = 1;i <= n;i ++)
cin >> p[i];
vector dp(n + 1, vector<double>(n + 1,0));
sort(p.begin() + 1, p.end(),greater());
dp[0][0] = 1;
for (int i = 1; i <= n; ++i){
dp[i][0] = (1 - p[i]) * dp[i - 1][0];
}
for(int i = 1;i <= n;i ++)
for(int j = 1;j <= n;j ++)
dp[i][j] = p[i] * dp[i - 1][j - 1] + (1 - p[i]) * dp[i - 1][j];
double ans = 0.0;
for(int i = k;i <= n;i ++){
double sum = 0.0;
for(int j = i - (i - k) / 2;j <= i;j ++)
sum += dp[i][j];
ans = max(ans, sum);
}
cout << ans << '\n';
return 0;
}
H. Highest Hill
思路就是每次一个峰一个峰地去找,然后更新答案.
思路还是挺对的,就是刚开始题目里有个等距导致我读了个假题,然后就是wa了几发,啊我真该死啊,最后贴份队友代码吧
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int32_t main() {
int n;
cin >> n;
vector<int> a(n + 10);
a[n] = LLONG_MAX;
for (int i = 0; i < n; i++)cin >> a[i];
int a1, a2, a3;
int pos1, pos2, pos3;
int ans = 0;
for (int i = 0; i < n; i++) {
pos1 = i;
while (a[i] <= a[i + 1] && i < n)i++;
pos2 = i;
if (pos1 == pos2)continue;
while (a[i] >= a[i + 1] && i < n)i++;
pos3 = i;
if (i >= n)break;
i--;
a1 = a[pos1];
a2 = a[pos2];
a3 = a[pos3];
ans = max(ans, min(a2 - a1, a2 - a3));
}
cout << ans << endl;
return 0;
}
SMU Summer 2023 Contest Round 11(2022-2023 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2022))的更多相关文章
- ACM ICPC, JUST Collegiate Programming Contest (2018) Solution
A:Zero Array 题意:两种操作, 1 p v 将第p个位置的值改成v 2 查询最少的操作数使得所有数都变为0 操作为可以从原序列中选一个非0的数使得所有非0的数减去它,并且所有数不能 ...
- ACM ICPC, Amman Collegiate Programming Contest (2018) Solution
Solution A:Careful Thief 题意:给出n个区间,每个区间的每个位置的权值都是v,然后找长度为k的区间,使得这个区间的所有位置的权值加起来最大,输出最大权值, 所有区间不重叠 思路 ...
- (寒假GYM开黑)2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)
layout: post title: 2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018) author: &qu ...
- Nordic Collegiate Programming Contest 2015 B. Bell Ringing
Method ringing is used to ring bells in churches, particularly in England. Suppose there are 6 bells ...
- Nordic Collegiate Programming Contest 2015 G. Goblin Garden Guards
In an unprecedented turn of events, goblins recently launched an invasion against the Nedewsian city ...
- Nordic Collegiate Programming Contest 2015 E. Entertainment Box
Ada, Bertrand and Charles often argue over which TV shows to watch, and to avoid some of their fight ...
- Nordic Collegiate Programming Contest 2015 D. Disastrous Downtime
You're investigating what happened when one of your computer systems recently broke down. So far you ...
- Codeforces Gym101572 B.Best Relay Team (2017-2018 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2017))
2017-2018 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2017) 今日份的训练,题目难度4颗星,心态被打崩了,会的算法太少了,知 ...
- 2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)- D. Delivery Delays -二分+最短路+枚举
2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)- D. Delivery Delays -二分+最短路+枚举 ...
- 2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)-E. Explosion Exploit-概率+状压dp
2018-2019 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2018)-E. Explosion Exploit-概率+状压dp [P ...
随机推荐
- Service Mesh技术详解
深入探讨Service Mesh的基本概念和核心技术,涵盖了服务发现.负载均衡.断路器与熔断机制,以及数据平面与控制平面的详细工作原理和实现方法. 关注作者,复旦博士,分享云服务领域全维度开发技术.拥 ...
- Linux中的inode
inode是什么 一个文件由两部分组成:元信息和数据. 在Linux中,inode包含文件的元信息,具体来说有以下内容: Size 文件的字节数 Uid 文件拥有者的User ID Gid 文件的Gr ...
- Windows下USB声卡音量调整
买了一个绿联的USB声卡, 但是默认的音量太大了,最低音量都响的不行. 查了一下, 发现了一个叫EqualizerAPO的软件可以调整输出设备的音量. https://equalizerapo.com ...
- 记录EF 排序配上自定义的比较器
记录EF 排序配上自定义的比较器 前言 要求页面文件显示的时候能够按照序号去排序要求如下: 数据库有一个列存放文件名,如: 1.1文件 1.2文件 1.1.1文件 1.1.11文件1.0.txt 1. ...
- Android系统启动:.rc文件
Android系统启动:.rc文件 reference : https://www.jianshu.com/p/a4c17f0110d0 以init.rc为例. .rc文件 init.rc文件由系统第 ...
- Ubuntu访问samba共享文件
Ubuntu访问samba共享文件 参考:https://www.cnblogs.com/Wolf-Dreams/p/11241198.html 做法 安装samba-client.cifs-util ...
- STM32 CubeMX 学习:001-GPIO的使用
背景 在上一讲STM32 CubeMX 学习:搭建开发环境中,我们已经利用CubeMx搭建了可编译的工程. 今天就开始来介绍STM32 GPIO的有关知识,以及如何驱动它. HOST-OS : Win ...
- 【Kafka最佳实践】合理安排kafka的broker、partition、consumer数量
broker的数量最好大于等于partition数量 一个partition最好对应一个硬盘,这样能最大限度发挥顺序写的优势. 一个broker如果对应多个partition,需要随机分发,顺序IO会 ...
- WPF实现TextBlock呼吸灯效果
实现代码 <TextBlock Text="录像中" FontSize="48" Foreground="#ED4646" Horiz ...
- MyBatis xml文件头
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE configuration PUBLIC & ...