Codeforces Round #327 (Div. 2) (591A,591B,590A(找规律),590B(二分))

用deepseek对GPU服务器进行压力测试 利用 DeepSeek 模型对 GPU 服务器进行压力测试,核心思路是通过,验证 GPU 服务器在计算、显存、网络等维度的承载能力,同时观察稳定性与性能瓶颈。 阅读详情

Wizards' Duel

题目链接:

http://codeforces.com/problemset/problem/591/A

解题思路:

Let's start with determining the position of the first collision. Two impulses converge with a speed p + q, so the first collision will occur after  seconds. The coordinate of this collision is given by the formula .

Note, that the distance one impulse passes while returning to it's caster is equal to the distance it has passed from the caster to the first collision. That means impulses will reach their casters simultaneously, and the situation will be identic to the beginning of the duel. Hence, the second collision (third, fourth, etc) will occur at exactly the same place as the first one.

题目大意:

把问题简化成为:两物体相向而行,问相遇的地点(相对于第一个物体而言)。

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

int main(){
    double l,p,q;
    while(~scanf("%lf%lf%lf",&l,&p,&q)){
        printf("%.4lf\n",l/(p+q)*p);
    }
    return 0;
}

Rebranding

题目链接:

http://codeforces.com/problemset/problem/590/B

解题思路:

Trivial solution will just emulate the work of all designers, every time considering all characters of the string one by one and replacing all xiwith yi and vice versa. This will work in O(n·m) and get TL.

First one should note that same characters always end as a same characters, meaning the position of the letter doesn't affect the result in any way. One should only remember the mapping for all distinct characters. Let p(i, c) be the mapping of c after i designers already finished their job. Now:

  • p(0, c) = c
  • If p(i - 1, c) = xi, then p(i, c) = yi
  • Same, if p(i - 1, c) = yi, then p(i, c) = xi

This solution complexity is O(|Σ|·m + n) and is enough to pass all the tests.

Challenge: improve the complexity to O(Σ + n + m).

题目大意:

输入n和m, 然后再输入n个字母。再给你m个替换操作,输出替换后的字符串。 

算法思想:

不能直接操作,考虑到英文小写英文字母最多只有26个,直接对26个英文字母进行替换操作,然后再带进去即可。 

AC代码:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

char str[200005],change[30];

int main(){
    int n,m;
    while(~scanf("%d%d",&n,&m)){
        scanf("%s",str);
        char x,y,tmp;
        for(int i = 0; i < 26; i++)
            change[i] = i+'a';
        for(int i = 0; i < m; i++){
            getchar();
            scanf("%c%c%c",&x,&tmp,&y);
            for(int j = 0; j < 26; j++){
                if(change[j] == x)
                    change[j] = y;
                else if(change[j] == y)
                    change[j] = x;
            }
        }
        for(int i = 0; i < n; i++)
            str[i] = change[str[i]-'a'];
        printf("%s\n",str);
    }
    return 0;
}

Median Smoothing(找规律)

题目链接:

http://codeforces.com/problemset/problem/590/A

解题思路:

We will call the element of a sequence stable, if it doesn't change after applying the algorithm of median smoothing for any number of times. Both ends are stable by the definition of the median smoothing. Also, it is easy to notice, that two equal consecutive elements are both stable.

Now we should take a look at how do stable elements affect their neighbors. Suppose ai - 1 = ai, meaning i - 1 and i are stable. Additionaly assume, that ai + 1 is not a stable element, hence ai + 1 ≠ ai and ai + 1 ≠ ai + 2. Keeping in mind that only 0 and 1 values are possible, we conclude that ai = ai + 2 and applying a median smoothing algorithm to this sequence will result in ai = ai + 1. That means, if there is a stable element in position i, both i + 1 and i - 1 are guaranteed to be stable after one application of median smoothing. Now we can conclude, that all sequences will turn to stable at some point.

Note, that if there are two stable elements i and j with no other stable elements located between them, the sequence of elements between them is alternating, i.e. ak = (ai + k - i)mod2, where . One can check, that stable elements may occur only at the ends of the alternating sequence, meaning the sequence will remain alternating until it will be killed by effect spreading from ending stable elements.

The solution is: calculate max(min(|i - sj|)), where sj are the initial stable elements. Time complexity is O(n).

Challenge 1: hack the solution that just applies median smoothing until something changes.

Challenge 2: think of how to speed up the algorithm from challenge 1 using bitmasks (still gets TL).

题目大意:

给你了一段 0 1 组成的波,然后这个波的值可能会发生变化,不计起点和终点,如果某一位置上的值不等于其左右位置加上自己的中位数话,那么它会变成中位数,这样导致波会振荡一次,问波最终是否会稳定,不会输出-1。会,就输出其振荡次数与最终波的值。

算法思想:

首先可以判断最终波是一定会稳定的,不可能最终不稳定。因为只有0与1,边缘值a1与an不变了,所以他们只会往中间延伸这种稳定的状态。然后确定只要连着两个00 或者11 就不会改变,改变的只会是01交替出现的。然后不断更新即可。

AC代码:

#include<bits/stdc++.h>
using namespace std;

const int maxn = 505050;
int n;
int arr[maxn];

int modify(int l, int r){
    if(l == r)
        return 0;
    if(arr[l] == arr[r]){
        for(int i = l+1; i < r; i++)
            arr[i] = arr[l];
        return (r-l)/2;
    }
    else{
        int m = (l+r+1)/2;
        for(int i = l+1; i < m; i++)
            arr[i] = arr[l];
        for(int i = m; i < r; i++)
            arr[i] = arr[r];
        return (r-l-1)/2;
    }
}

int main(){
    while(~scanf("%d",&n)){
        for(int i = 0; i < n; i++)
            scanf("%d",&arr[i]);
                int ans = 0;
        int l = 0;
        for(int i = 0; i < n; i++){
            if(i == n-1 || arr[i] == arr[i+1]){
                ans = max(ans, modify(l, i));
                l  = i+1;
            }
        }
        printf("%d\n",ans);
        for(int i = 0; i < n-1; i++)
            printf("%d ",arr[i]);
        printf("%d\n",arr[n-1]);
    }
    return 0;
}

Chip 'n Dale Rescue Rangers(二分)

题目链接:

http://codeforces.com/problemset/problem/590/B

解题思路:

If the velocity of the dirigible relative to the air is given by the vector (ax, ay), while the velocity of the wind is (bx, by), the resulting velocity of the dirigible relative to the plane is (ax + bx, ay + by).

The main idea here is that the answer function is monotonous. If the dirigible is able to reach to target in  seconds, then it can do so in  seconds, for any x ≥ 0. That is an obvious consequence from the fact the maximum self speed of the dirigible is strictly greater then the speed of the wind at any moment of time.

For any monotonous function we can use binary search. Now we only need to check, if for some given value  it's possible for the dirigible to reach the target in  seconds. Let's separate the movement of the air and the movement of the dirigible in the air. The movement cause by the air is:

  • (xn, yn) = , if ;
  • (xn, yn) = , for .

The only thing we need to check now is that the distance between the point (xn, yn) and the target coordinates (x2, y2) can be covered moving with the speed vmax in  seconds assuming there is no wind.

Time complexity is , where C stands for the maximum coordinate, аnd ε — desired accuracy.

Challenge 1: think of the solution in case it's not guaranteed that the dirigible is faster than the wind.

Challenge 2: can you come up with O(1) solution?

物理问题,求飞船从一点到另一点的距离,有风速的影响。

orz,我当时怎么没想到呢,这题居然用二分,把飞船和风分开考虑,不然不断二分求解。太好了。

AC代码:

#include <bits/stdc++.h>
using namespace std;

int main(){
    double x1,y1,x2,y2,vmax,t,vx,vy,wx,wy;
    while(~scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2)){
        scanf("%lf%lf",&vmax,&t);
        scanf("%lf%lf%lf%lf",&vx,&vy,&wx,&wy);
        double l = 0, r = 1e9;
        for(int i = 0; i < 100; i++){
            double mid = (l+r)/2;
            double x = x1 + min(mid, t) * vx + max(mid - t, 0.0) * wx;
            double y = y1 + min(mid, t) * vy + max(mid - t, 0.0) * wy;
            (hypot(x - x2, y - y2) > vmax * mid ? l : r) = mid;
            //hypot计算直角三角形的斜边长
        }
        printf("%.6lf\n",l);
    }
    return 0;
}



华为昇腾云平台适配Baichuan2大模型记录 文件发现报错:ValueError: The pipeline stage 2 in auto_parallel_context is not equal to the pipeline_stage 1 in the config.run_baichuan2_7b.yaml`,发现默认设备数是16卡,对应的pipeline_stage为2,但实际是8卡,那就改成下面的试试看。,将Baichuan2_7B_Chat.ckpt文件复制进去,将。点击镜像管理,突然发现有个2_2_0,赶紧新建了一个,成功。 阅读详情

相关推荐

【Docker】如何让docker容器正常使用nvidia显卡

描述了如何在docker容器中使用英伟达显卡的过程和问题解决方法。

NameLoadingFailed的博客 8384

Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1)C. Save the Nature

Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1)C. Save the Nature 题意:一批商品,位置为a的倍数和b的倍数可以获利,问最少几个商品出售可以获利k 做法:对答案二分,即需要多少个上可以达到k,对这种情况下进行最优check 为什么每次二分都想不到二分。。。。 #include&l...

想要一只银渐层 356

Office Tool Plus:正版Office干净部署指南

Office部署是Windows新机配置的关键环节,涉及版本选择、架构匹配、语言支持与合规激活等基础技术问题。其核心原理基于微软官方Office Deployment Tool(ODT)的声明式XML配置机制,通过标准化流程确保安装可复现、可审计、无第三方捆绑。技术价值在于规避官网安装器的版本锁定、架构误配和语言缺失等常见风险,提升部署稳定性与安全性。典型应用场景包括企业批量部署、IT运维标准化、隐私敏感型用户自主安装。本文以Office Tool Plus为实践载体,深入解析ODT底层逻辑、XML配置规范

1245

Simulink电感矩阵奇异值报错:从原理到排查的工程实践指南

在电力系统电磁暂态仿真中,电感矩阵是描述电路网络电感与互感关系的核心数学工具,其本质源于基尔霍夫定律和电磁感应原理。一个非奇异的电感矩阵是电路状态可被唯一求解、仿真得以稳定运行的基础,这直接关系到模型的物理正确性与数值稳定性。当矩阵出现奇异或病态时,往往意味着模型存在违反物理定律的拓扑或参数设置,例如形成了纯电感回路或互感参数不满足可实现条件,导致仿真初始化失败。这类问题在包含复杂电机、变压器及电力电子开关的并网系统(如风电场)仿真中尤为常见。本文聚焦于Simulink/Simscape Electrica

weixin_33904756的博客 446

树莓派4B保姆级教程:从零配置Python虚拟环境到PySide2开发全流程(含避坑指南)

本文提供树莓派4B上配置Python虚拟环境及PySide2 GUI开发的完整教程。针对armv7l架构的特殊性,详细讲解了从系统准备、虚拟环境创建到PySide2安装的避坑指南,并重点解决了跨平台UI文件处理等常见难题,帮助开发者构建稳定高效的开发环境。

9q8w7e6r5的博客 828

企业网络改造必看:如何用华为S5700三层交换机解决多部门隔离通信?

本文详细介绍了如何利用华为S5700三层交换机解决企业多部门网络隔离与通信需求。通过划分VLAN实现逻辑隔离,并配置三层路由实现受控互通,结合ACL进行精细访问控制,构建安全高效的企业网络。文章提供了从拓扑规划、地址分配到核心配置的完整实战指南。

weixin_29260291的博客 270

Codeforces Round #591 Div. 2

1223A CME 题意:给定一个数0≤n≤1e90 \le n \le 1e90≤n≤1e9,把它分成三个数a,b,c使得a + b = c。问至少要增加多少才能分? 题解: 当n==2时,至少需要2。因为最小的等式是1+1=2。 当n>2分两种情况 ,n为偶数时,令c=n/2,a=⌊n/2⌋,b=⌈n/2⌉c = n/2, a = \lfloor n / 2 \rfloor,b = \l...

kdh的专栏 517

抖音直播参数逆向实战:手把手教你用Python获取ttwid和x-bogus(附完整代码)

本文深入解析抖音直播接口的反爬机制,重点剖析核心防护参数ttwid和x-bogus的生成原理与作用。通过Python实战,手把手教你逆向获取ttwid、webid等关键参数,并构建稳定的数据采集方案,为开发者提供企业级数据获取能力。

weixin_29196891的博客 1061

Codeforces Round #591 (Div. 2)

A. CME 题目链接:https://codeforces.com/contest/1241/problem/A 题意: 你有 N 根火柴 , 多少根火柴就可以组成多大的数(如 三根火柴可以表示 3), 现在要求你用火柴组成任意三个数 A , B , C 使得 A + B = C 关系成立 如果无论怎么组都无法使等式成立 , 则你可以额外购入 X 根火柴来重新组数使得关系成立 , 求 X 的...

qq_38227632的博客 99

PCL 从LAS文件中获取点云的颜色【2027最新版】

PCL从LAS文件中获取点云的RGB信息(pcl::PointXYZRGB)并进行可视化。博客长期更新,本文最新更新时间为:2026年12月1日。

点云侠的博客 1735

一文让你轻松理解802.11ax RU的概念

RU

1042484520@qq.com(邮箱) 3389

Codeforces Round #327 (Div. 2) 591ABC题解

题目链接:点击打开链接 A: 两个人在两端相向而行, 第一次碰面后掉头, 到端点后又掉头, 问第二次碰面时候距离左端点的距离. 脑洞题目, 第二次和第一次碰面在同一个地方, 要求精度在1e-4以内, 输出5位小数即可. AC代码: #include "iostream" #include "cstdio" #include "cstring" #include "algorithm

GKHack's Blog 1123

SAP Clean Core 对传统 ABAP 开发人员来说意味着什么:机遇和挑战

SAP Clean Core是一种战略方法,旨在优化和现代化 SAP S/4HANA 系统,通过尽量减少定制,确保核心系统的稳定性、高效性和对云环境的兼容性。Clean Core 作为一种设计思路,致力于让 ERP 系统的核心功能保持简洁、规范,避免不必要的复杂化,最终维持一个标准化的核心,使系统更容易升级、性能更优越,同时支持快速的创新能力。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 627

Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1)

打cf的过程中遭受到了DDOS攻击,导致最终无法进行下去,也算是奇闻一件了 A. CME 思路:看似像个火柴游戏,实则只是个判断奇偶的水题 /* Author Owen_Q */ #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 1e7+5; i...

Owen_Q的博客 449

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

Codeforces Round #691 (Div. 2)

文章目录A. Red-Blue ShuffleB. Move and TurnC. Row GCD A. Red-Blue Shuffle 题目 There are n cards numbered 1,…,n. The card i has a red digit ri and a blue digit bi written on it. We arrange all n cards in random order from left to right, with all permutations of

一只小蒟蒻的博客 1510

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

【CF】Day28——Codeforces Round 591 (Div. 2, based on Technocup 2020 Elimination Round 1) C

典还是一道很简单的题的,我们可以观察到一个显然的贪心,我们肯定是要把大的数放在收益多的位置,同时题目不需要我们输出位置什么的,所以我们直接将原数组降序排序,然后计算即可我们可以利用二分答案,每次二分选 mid 张票,然后check一下行不行具体看代码。

qq_61422664的博客 222

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

Codeforces Round #327 (Div. 2) C. Median Smoothing 找规律

http://codeforces.com/problemset/problem/591/C 这道题的原意是对一个数组进行中值滤波,也就是让一个数等于自己,左边右边的中位数。问什么时候数组不再发生变化。 首先,如果一个数组不发生变化,我们很容易想到这样的数组中每个数至少和左边或者右边相等。那么只有01交替的数组才会发生变化。 那么我们写几个数组在实验一下 010101 —-&gt; 000...

limn204的专栏 185

Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) B

https://codeforces.com/contest/1241/problem/B #include <bits/stdc++.h> using namespace std; #define LL long long #define LD long double #define SC(t,x) static_cast<t>(x) #define AR(t) ve...

king9666的博客 162

Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) 题解

A..B略 C 对当前的值排序,再二分答案,然后对于(i%x==0 && i%y==0)放入大的,再放其他的贪心解决即可。 #include<iostream> #include<stdio.h> #include<string.h> #include<algorithm> #include<map&g...

qq_40921866的博客 232

Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) C. Save the Nature(二分)

题目链接:https://codeforces.com/contest/1241/problem/C 思路:题目的答案具有单调性,(如果3是答案的话,小于3的数都不是答案),所以可以二分,直接二分位置即可,因为要满足res >= k 的最小答案,所以位置一定是%a,或者%b ,或者%(a + b)为 0的位置,然后对每个位置采用贪心的思路,让最大的数字*最大的倍率。 代码: #include...

一只谜谜怪的博客 166

Codeforces 591 B Rebranding【Codeforces Round #327 (Div. 2)】

B. Rebranding time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The name of one small but proud corporation consists of

代码改变世界 822

Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1)补题

文章目录A - CMEB - Strings EqualizationC - Save the NatureD - Sequence SortingE - Paint the Tree 题目 A - CME #include<bits/stdc++.h> using namespace std; int main(){ int q; scanf("%d",&q); while(...

qq_44290978的博客 577

Codeforces Round #591 (Div. 2)D. Sequence Sorting(思路)

题目链接: https://codeforces.com/problemset/problem/1223/D 题面: 题意: 一次操作可以把一种数字(不一定是只有一个)移动到最左边或最右边,问最少经过几次操作可以使序列变成不下降序列。 ps:没初始化wawawa了,数组开小了rerere,我sb了orz。orz。orz。 思路: 考虑不需要移动的(也就是本身连续不减)数,这里用邻接表的形式存某...

nuoyanli的博客 1640

Codeforces Round #591 (Div. 2, based on Technocup 2020 Elimination Round 1) A

https://codeforces.com/contest/1241/problem/A #include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int q,n;...

king9666的博客 261

Codeforces Round #591 (Div. 1)A.Save the Nature

Wrong answer on test2 15ms 0KB 感觉思路上就有问题,把问题搞复杂了?心态爆炸。。。心情好了再改???? #include <iostream> #include <vector> #include <cstring> #include <string> #include <map&...

YGLeeeon的博客 343

Codeforces Round #591 (Div. 1, based on Technocup 2020 Elimination Round 1)

A.Save the Nature: 题意: 你是一名售票员,有N张票待售,需要你通过决定售票的顺序来使你的抽成最多。 称售票的次序为“名次”。名次仅为a的倍数,可以抽成x%;名次仅为b的倍数,可以抽成y%;名次既为a的倍数又为b的倍数,可以抽成(x + y)%。 ...

Masker 300
上一篇: Codeforces Round #259(454A,454B,453A(排列组合))
下一篇: BestCoder Round #61 (div.2)(hdu5522,hdu5523,hdu5524,hdu5525(数论:费马小定理))
yphacker
博客等级 码龄12年 199粉丝 540原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址