题意:有一个一维的书架,\(L\)表示在最左端放一本书,\(R\)表示在最右端放一本书,\(?\)表示从左数或从右数,最少数多少次才能得到要找的书. 题解:我们开一个稍微大一点的数组,从它的中间开始模拟,\(L\)就--\(l\)放进去,\(R\)就++\(r\)放进去,然后每次更新某一本书的最新位置,因为后放的肯定离最左侧或最右侧最近,然后两端求差弄个最小值就行. 代码: int q; char c; int idx; int ans; int mp[2*N],now[2*N]; int ma…
http://codeforces.com/contest/1066/problem/C You have got a shelf and want to put some books on it. You are given qq queries of three types: L idid — put a book having index idid on the shelf to the left from the leftmost existing book; R idid — put…
Codeforces Round #515 (Div. 3) #include<bits/stdc++.h> #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<algorithm> #include<queue> #include<vector> #incl…
Bakery 题目链接: http://codeforces.com/contest/707/problem/B Description Masha wants to open her own bakery and bake muffins in one of the n cities numbered from 1 to n. There are m bidirectional roads, each of whose connects some pair of cities. To bake…
题目链接:http://codeforces.com/contest/1066 1066 A. Vova and Train 题意:Vova想坐火车从1点到L点,在路上v的整数倍的点上分布着灯笼,而在路上从l到r处停着别的火车,它挡着Vova的视线使他看不到灯笼.给定L,v,l,r求Vova能看到的灯笼数. 分析:从1到x上所有的灯笼数量为x/v个.则路上所有的灯笼数为L/v个,被挡住的则为 r/v - (l-1)/v 个,相减即为答案. #include<iostream> #include…
A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have decided to watch the best moments of some movie. There are two buttons on your player: Watch the current minute…
A. Contest time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully sub…
http://codeforces.com/contest/1066/problem/A Vova plans to go to the conference by train. Initially, the train is at the point 11 and the destination point of the path is the point LL. The speed of the train is 11 length unit per minute (i.e. at the…
任意门:http://codeforces.com/contest/1066/problem/B B. Heaters time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Vova's house is an array consisting of nn elements (yeah, this is the first probl…
E. Binary Numbers AND Sum 题目链接:https://codeforces.com/contest/1066/problem/E 题意: 给出两个用二进制表示的数,然后将第二个二进制不断地往右边移一位,每次答案加上这两个的交集,求最后的答案. 题解: 考虑第二个二进制每一位对答案的贡献就行了,然后对第一个二进制算前缀和就ok了. 代码如下: #include <bits/stdc++.h> using namespace std; typedef long long l…