Codeforces Round #367 (Div. 2)

双目相机模型 近期想研究一下 双目相机 的内容,故先把 理论 弄清楚! 一、双目相机模型 针孔相机模型描述了 单个相机 的成像模型。然而,仅根据一个像素,我们是无法确定 这个空间点的具体位置的。这是因为,从相机光心到归一化平面连线上的所有点,都可以 投影至该像素上。只有当 P 的深度确定时(比如通过双目或 RGB-D 相机),我们才能确 切地知道它的空间位置。 测量像素距离(或深度)的方式有很多种,像人眼就可以根据左右眼看到的景物差异 (或称视差)来判断物体与我们的距离。双目相机的原理亦是如.. 阅读详情
                                                                                                                                    A. Beru-taxi
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Vasiliy lives at point (a, b) of the coordinate plane. He is hurrying up to work so he wants to get out of his house as soon as possible. New app suggested n available Beru-taxi nearby. The i-th taxi is located at point (xi, yi) and moves with a speed vi.

Consider that each of n drivers will move directly to Vasiliy and with a maximum possible speed. Compute the minimum time when Vasiliy will get in any of Beru-taxi cars.

Input

The first line of the input contains two integers a and b ( - 100 ≤ a, b ≤ 100) — coordinates of Vasiliy's home.

The second line contains a single integer n (1 ≤ n ≤ 1000) — the number of available Beru-taxi cars nearby.

The i-th of the following n lines contains three integers xi, yi and vi ( - 100 ≤ xi, yi ≤ 100, 1 ≤ vi ≤ 100) — the coordinates of the i-th car and its speed.

It's allowed that several cars are located at the same point. Also, cars may be located at exactly the same point where Vasiliy lives.

Output

Print a single real value — the minimum time Vasiliy needs to get in any of the Beru-taxi cars. You answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if .

Examples
Input
0 0
2
2 0 1
0 2 2
Output
1.00000000000000000000
Input
1 3
3
3 3 2
-2 3 6
-2 7 10
Output
0.50000000000000000000
Note

In the first sample, first taxi will get to Vasiliy in time 2, and second will do this in time 1, therefore 1 is the answer.

In the second sample, cars 2 and 3 will arrive simultaneously.


题意:求出所以租车到人该位置最短时间。


<span style="font-size:18px;">#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define eps 1e-7
using namespace std;
const int maxn=1010;
struct node{
   double x,y,t,dis,v;
}nod[maxn];
int main()
{
    double x,y;
    int n;
    while(~scanf("%lf %lf",&x,&y))
    {
        memset(nod,0,sizeof(nod));
        double a,b;
        double sum=100000000;
        scanf("%d",&n);
        for(int i=0;i<n;i++){
            scanf("%lf %lf %lf",&nod[i].x,&nod[i].y,&nod[i].v);
            nod[i].t=sqrt((nod[i].x-x)*(nod[i].x-x)+(nod[i].y-y)*(nod[i].y-y))/nod[i].v;
            //cout << nod[i].t <<endl;
            if(sum-nod[i].t>eps) sum=nod[i].t;
        }
        printf("%f\n",sum);
    }
    return 0;
}
</span>

                                                                                                        

                                                                                                                                  B. Interesting drink
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Vasiliy likes to rest after a hard work, so you may often meet him in some bar nearby. As all programmers do, he loves the famous drink "Beecola", which can be bought in n different shops in the city. It's known that the price of one bottle in the shop i is equal to xi coins.

Vasiliy plans to buy his favorite drink for q consecutive days. He knows, that on the i-th day he will be able to spent mi coins. Now, for each of the days he want to know in how many different shops he can buy a bottle of "Beecola".

Input

The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of shops in the city that sell Vasiliy's favourite drink.

The second line contains n integers xi (1 ≤ xi ≤ 100 000) — prices of the bottles of the drink in the i-th shop.

The third line contains a single integer q (1 ≤ q ≤ 100 000) — the number of days Vasiliy plans to buy the drink.

Then follow q lines each containing one integer mi (1 ≤ mi ≤ 109) — the number of coins Vasiliy can spent on the i-th day.

Output

Print q integers. The i-th of them should be equal to the number of shops where Vasiliy will be able to buy a bottle of the drink on the i-th day.

Example
Input
5
3 10 8 6 11
4
1
10
3
11
Output
0
4
1
5
Note

On the first day, Vasiliy won't be able to buy a drink in any of the shops.

On the second day, Vasiliy can buy a drink in the shops 1, 2, 3 and 4.

On the third day, Vasiliy can buy a drink only in the shop number 1.

Finally, on the last day Vasiliy can buy a drink in any shop.


题意:求数组大于给定数x的个数。


解题思路:只要将数组小到大排序,然后二分查找第一个大于x的位置(由于数组从0开始),所以得到的位置就是满足条件数的个数。


<span style="font-size:18px;">#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<cstring>
using namespace std;
const int maxn=100010;
int a[maxn];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        for(int i=0;i<n;i++){
            scanf("%d",&a[i]);
        }
        sort(a,a+n);
        int q,x;
        scanf("%d",&q);
        for(int i=0;i<q;i++){
            scanf("%d",&x);
            int sum=upper_bound(a,a+n,x) - a;
            printf("%d\n",sum);
        }
    }
    return 0;
}

</span>


C. Hard problem
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Vasiliy is fond of solving different tasks. Today he found one he wasn't able to solve himself, so he asks you to help.

Vasiliy is given n strings consisting of lowercase English letters. He wants them to be sorted in lexicographical order (as in the dictionary), but he is not allowed to swap any of them. The only operation he is allowed to do is to reverse any of them (first character becomes last, second becomes one before last and so on).

To reverse the i-th string Vasiliy has to spent ci units of energy. He is interested in the minimum amount of energy he has to spent in order to have strings sorted in lexicographical order.

String A is lexicographically smaller than string B if it is shorter than B (|A| < |B|) and is its prefix, or if none of them is a prefix of the other and at the first position where they differ character in A is smaller than the character in B.

For the purpose of this problem, two equal strings nearby do not break the condition of sequence being sorted lexicographically.

Input

The first line of the input contains a single integer n (2 ≤ n ≤ 100 000) — the number of strings.

The second line contains n integers ci (0 ≤ ci ≤ 109), the i-th of them is equal to the amount of energy Vasiliy has to spent in order to reverse the i-th string.

Then follow n lines, each containing a string consisting of lowercase English letters. The total length of these strings doesn't exceed 100 000.

Output

If it is impossible to reverse some of the strings such that they will be located in lexicographical order, print  - 1. Otherwise, print the minimum total amount of energy Vasiliy has to spent.

Examples
Input
2
1 2
ba
ac
Output
1
Input
3
1 3 1
aa
ba
ac
Output
1
Input
2
5 5
bbb
aaa
Output
-1
Input
2
3 3
aaa
aa
Output
-1
Note

In the second sample one has to reverse string 2 or string 3. To amount of energy required to reverse the string 3 is smaller.

In the third sample, both strings do not change after reverse and they go in the wrong order, so the answer is  - 1.

In the fourth sample, both strings consists of characters 'a' only, but in the sorted order string "aa" should go before string "aaa", thus the answer is  - 1.


题意:给你n个字符串,每个字符串可以倒过来(需要花费a[i[),问你是这n个字符串能否变成字典序排序(每个字符串可以倒过来,也可以为原状态),如果不行输出-1,否则输出费用最小值。


解题思路:一开始觉得就是模拟题,后来错了,然后比赛快结束推出了dp状态转移方程,不过来不及了。

每个字符串只有两种状态,假设S[i]为未反转的状态,s1[i]为反转过来的状态,dp[i][s]---->dp[i][0]表示第 i 个字符串未转换过来前 i 串得到的最优解,dp[i][1]表示第 i 个字符串反转过来前 i 串得到的最优解,那么状态转移方程为:

                        dp[i][0]=dp[i-1][0] (s[i]>=s[i-1])

                       dp[i][0]=dp[i-1][1]  (s[i]>=s1[i-1])

                       dp[i][1]=dp[i-1][0]+a[i] (s[i]>=s[i-1])

                        dp[i][1]=dp[i-1][1]+a[i] (s[i]>=s1[i-1])


<span style="font-size:18px;">#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<cstring>
#define inf 1e16
using namespace std;
string s[100010];
string s1[100010];
long long dp[100010][2];
int a[100010];
int main()
{
    int n;
    while(~scanf("%d",&n)){
        for(int i=1;i<=n;i++) scanf("%d",&a[i]);
        for(int i=0;i<=n+1;i++) dp[i][0]=dp[i][1]=inf;
        for(int i=1;i<=n;i++){
            cin>>s[i];
            int len=s[i].size();
            //cout << len << endl;
            for(int j=0,k=len-1;k>=0;k--,j++){
                s1[i]+=s[i][k];
            }
        }

        dp[1][0]=0;
        dp[1][1]=a[1];
        for(int i=2;i<=n;i++){
            int ans=0;
            if(s[i]>=s[i-1]){
                dp[i][0]=min(dp[i][0],dp[i-1][0]);
            }//else ans++;

            if(s[i]>=s1[i-1]){
                dp[i][0]=min(dp[i][0],dp[i-1][1]);
            }//else ans++;

            if(s1[i]>=s[i-1]){
                dp[i][1]=min(dp[i][1],dp[i-1][0]+a[i]);
            }//else ans++;

            if(s1[i]>=s1[i-1]){
                dp[i][1]=min(dp[i][1],dp[i-1][1]+a[i]);
            }//else ans++;

            //if(ans==4) flag=0;
        }
        //if(flag==0){
            //printf("-1\n");
            //continue;
        //}
        printf("%I64d\n",((min(dp[n][0],dp[n][1]))==inf) ? -1 : min(dp[n][0],dp[n][1]));
    }
    return 0;
}
</span>


SAP Integration Suite 与 SAP Cloud Integration 的关系解析 SAP Cloud Integration是SAP Integration Suite套件的核心组件,专注于消息与流程集成。两者关系可概括为:Integration Suite是SAP BTP上的集成平台套件(iPaaS),而Cloud Integration是其中负责应用与B2B集成的关键能力。日常所说的"CPI"实际指代的是Integration Suite中的Cloud Integration功能。该套件还包含API管理、事件网格等其他集成能力,共同构成企业集成解决方案。理解这一层 阅读详情

相关推荐

Python量化投资入门教程:从零构建你的第一个交易策略

量化投资教程以数学模型和计算机程序实现超额收益,选用Python工具链完成数据获取、策略构建及回测。通过移动平均线交叉策略示例,展示数据预处理、信号生成、收益计算及可视化全流程,结合收益率、最大回撤和夏普比率评估策略,并建议参数优化与策略融合提升稳健性。

ylmx5201314的博客 2456

Codeforces Round #367 (Div. 2)【贪心、差分、DP、字典树、二维链表】

Codeforces Round #367 (Div. 2) A. Beru-taxi 就是问,我们知道一个点,从其他点到它的最少花费的时间是多少? #include <iostream> #include <cstdio> #include <cmath> #include <string> #include <cstring&g...

既然弱小,就只顾变强就是了 256

STM32F4驱动ADS1220高精度ADC:从SPI配置到数据校准的完整实战指南

本文详细介绍了如何使用STM32F4微控制器驱动ADS1220高精度ADC,涵盖从SPI接口配置、寄存器设置到数据采集与校准的全过程。通过实战代码示例和硬件设计要点,帮助开发者快速构建高精度数据采集系统,适用于工业测量和精密仪器等应用场景。

weixin_26918763的博客 224

Codeforces Round #367 (Div. 2) C. Hard problem(DP)

Hard problem 题目链接: http://codeforces.com/contest/706/problem/C Description Vasiliy is fond of solving different tasks. Today he found one he wasn't able to solve himself, so he asks you to help...

dituonian8372的博客 139

Altium Designer20-柔性PCB绘制技巧

Altium Designer2020-柔性PCB绘制技巧 注:教程所用PCB随意找的,并没有完全绘制完,大家学习PCB折弯方法即可。 1.打开PCB,点击视图->板子规划模式1,如下图所示 2.点击设计->定义分割线,用两条分割线绘出要折弯的区域 3.点击设计->定义弯曲线(弯曲线呈现黄色) 4.用快捷键d,k进入layer manage stack(层叠管理器),在f...

weixin_44450279的博客 1万+

高频仿真:高频天线设计_(4).天线参数分析与优化

通过上述步骤,我们展示了如何综合使用解析方法、数值优化方法和实验数据来设计和优化一个高效宽带天线。首先,我们通过解析方法确定了天线的初步长度;然后,使用遗传算法优化了天线的直径以最大化增益;最后,通过实验数据验证了天线的性能,包括驻波比和带宽。这一综合性方法可以有效地提升天线的设计和优化效果,确保其在实际应用中表现出色。

2401_87715305的博客 923

Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)

Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b) of the coordinate plane. He is hurrying up to work so he wants to get out of his house as s...

dituonian8372的博客 180

【RT-DETR有效改进】为什么YOLO版本的RT-DETR训练模型不收敛精度差的问题

本文的内容同样为本专栏的前期预热文章,文章主要解释一下为什么有的人跑ultralytics仓库的RT-DETR精度很差,模型不收敛,mAP异常的情况。为了验证这一情况我也是跑了多个实验,从多个数据集出发,100-500的数据集我跑了大概5个数据集,1000的我跑了二个,2000的我跑了一个,4000的跑了一个,同时其中一些版本我也用了不同的batch_size来出发验证精度异常的情况。

Snu77的博客 9762

Codeforces Round #367 (Div. 2) B Interesting drink【二分】

Codeforces Round #367 (Div. 2) B Interesting drink 【二分】

SaySomething 387

下载igv报错:Error loading genome hg38raw.githubusercontent.com...如何解决?

🏆本文收录于 《全栈 Bug 调优(实战版)》 专栏。专栏聚焦真实项目中的各类疑难 Bug,从成因剖析 → 排查路径 → 解决方案 → 预防优化全链路拆解,形成一套可复用、可沉淀的实战知识体系。无论你是初入职场的开发者,还是负责复杂项目的资深工程师,都可以在这里构建一套属于自己的「问题诊断与性能调优」方法论,助你稳步进阶、放大技术价值 。

**My Coding Family** 989

黑猫带你学eMMC协议第22篇:emmc可靠写详解(Write Reliability)

1 前言 1.1 声明 本文依据eMMC JEDEC5.1、网络资料及个人工作经验整理而成,如有部分错误请留言。 本文部分内容可能源自网络,侵删。 本文结合eMMC JEDEC5.1协议手册查看效果更佳。 1.2 内容提要 1、什么是可靠性写属性(Write Reliability)? 2、可靠写和普通的写有什么区别? 3、设置可靠写的流程及流程框图。 4、可靠写需要遵循哪些规则? 1.3 参考链接 本文主要参考链接:http://www.up48.com/cn/support/8_37.html 2 什么

黑猫奥利奥的博客 3122

Codeforces Round #367 (Div. 2) C. Hard problem

题目链接:Codeforces Round #367 (Div. 2) C. Hard problem 题意: 给你一些字符串,字符串可以倒置,如果要倒置,就会消耗vi的能量,问你花最少的能量将这些字符串排成字典序 题解: 当时1点过头太晕了,看错题了,然后感觉全世界都会,就我不会,- -!结果就是一个简单的DP, 设dp[i][0]表示第i个字符串不反转的情况,dp[i][1]表示第i...

weixin_30470857的博客 96

uniapp(全端兼容) - 超详细接入百度统计功能,给uniapp全平台各端项目引入添加百度统计的插件统计流量详细的步骤教程(提供最新的百度统计源代码,详细的示例代码复制粘贴即可快速搞定!)

uniapp h5 app 使用加入接入百度统计,uniapp百度统计,uniapp详细引入百度统计的教程,uniapp接入百度统计,uniapp如何实现加入百度的统计代码,uniapp怎么植入百度统计详细教程,uniapp如何对接百度统计,uniapp百度统计不生效怎么办,uniapp使用百度统计不生效常见问题,uniapp引入百度统计后没有生效,uniapp h5网页接入百度统计代码后没有统计无效,uniapp最新接入使用百度统计功能,uniapp增加百度统计代码,uniapp app如何接入百度统计,

✅ 精选推荐文章 1万+

【codeforces】Codeforces Round #367 (Div. 2)

最近几天刷CF渐渐有些手感了…… md英语能力++ 在想要不要打CR#374…… 到时候应该是在北京学习ingQAQ 嘛嘛 这几天被卡的简直爽 23333333 来吧写题解 A 第一次写A题…… 记录下double的一些事情 cout一个double的话他会不...

chuiren0937的博客 113

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

【解题报告】Codeforces Round #367 (Div. 2)

简略的解题报告。

TRiddle的博客 1279

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

Codeforces Round #367 (Div. 2)E. Working routine

链接:http://codeforces.com/contest/706/problem/E 题意:给定一个n*m的矩阵,给定q次剪切交换,每次给出a,b,c,d,h,w表示将左上角为(a,b)和左上角为(c,d)的高h宽w的矩阵交换,保证两个矩形不重叠没有公共边。 分析:对每个格子建一个十字链表,每次剪切的时候我们只需要将周围的那些链表交换即可。O(q*(n+m)) 代码: #inclu

Fsss 2万+

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

Codeforces Round #367 (Div. 2) E. Working routine

原题网址:http://codeforces.com/contest/706/problem/E 用四向链表维护每个点上下左右分别是哪些点,每次修改只要修改矩形周围一圈,复杂度O(q(n+m))。 然而Pascal四向链表强行被卡T,改成双向链表(向右和向下)才卡过(估计下来此题Pascal有C++4倍常数左右)。 里面有好几处精妙细节,所以我不得不标记出来以免我以后注意不到。//四向

MintGreen 477
上一篇: HDU 3234 Exclusive-OR(加权并差集)
下一篇: HDU 2089 不要62(数位DP)
hellohelloC
博客等级 码龄12年 15粉丝 107原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值