CF699A Launch of Collider 题解】的更多相关文章

Content 有 \(n\) 辆车在一条数轴上,第 \(i\) 辆车在 \(a_i\) 上,每辆车要么向左,要么向右.开始,它们以 \(1\) 个单位每秒的速度在行驶.问你第一次撞车发生在第几秒的时候,或者根本不会撞车. 数据范围:\(1\leqslant n\leqslant 2\times 10^5,0\leqslant x_i\leqslant x_{i+1}\leqslant 10^9\). Solution 我们可以很容易的发现,当且仅当相邻的两个车,左边的向右开,右边的向左开时会发…
A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n parti…
A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n parti…
A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n parti…
A. Launch of Collider time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output   There will be a launch of a new, powerful and unusual collider very soon, which located along a straight line. n par…
维护最新的R,遇到L时如果R出现过就更新答案. #include <cstdio> #include <algorithm> using namespace std; int n,x,r=-1,ans=-1; char a[200005]; int main(){ scanf("%d%s",&n,a); for(int i=0;i<n;i++){ scanf("%d",&x); if(a[i]=='R') r=x; el…
题目链接: http://codeforces.com/problemset/problem/699/A 题目大意: 给N个点,向左或向右运动,速度均为1,问最早什么时候有两个点相撞.无解输出-1 题目思路: [模拟] 模拟一下,记录往左往右的位置即可. // //by coolxxx ////<bits/stdc++.h> #include<iostream> #include<algorithm> #include<string> #include<…
枚举相邻两个$a[i]$与$a[i+1]$,如果$s[i]=R$并且$s[i+1]=L$,那么$i$和$i+1$会碰撞,更新答案. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #incl…
好久没做手生了,不然前四道都是能A的,当然,正常发挥也是菜. A:Launch of Collider 题意:20万个点排在一条直线上,其坐标均为偶数.从某一时刻开始向左或向右运动,速度为每秒1个单位长度.输入给出每个点的坐标及其移动的方向,求发生第一次碰撞的时间,若不会碰撞,则输出-1 最先发生碰撞的是一定是初始时相邻的两个点,因此只需对每个点循环一边,判断其是否会与下一个点碰撞,并求出其时间即可. #include<stdio.h> #include<stdlib.h> int…
Problem A Launch of Collider 题目大意 在x轴上有n个点,坐标均为偶数.每个点或向左移动或向右移动,每秒移动距离为1. 使所有点同时开始移动,求最早有点相遇的时间或无解. 解题分析 对于每一个向右移动的点,找右边最近的一个向左的点.向左移动同理. 正反扫两遍即可. 参考程序 #include <map> #include <set> #include <stack> #include <queue> #include <cm…