CodeForces 622C】的更多相关文章

题目链接: http://codeforces.com/problemset/problem/622/C 题意: 给定序列,若干查询,每个查询给定区间和t,输出区间内任意一个不等于t的元素的位置. 分析: 最初没看样例直接钦定输出每个不等于t的元素位置,结果怎么想都是n2复杂度的,后来看了样例才发现是输出任意一个.. 对于一个区间,如果区间最大值和最小值相等,那么该区间元素值全部相同,那么我们维护区间的最大最小值,然后判断是否均等于t,若不等,输出最大值或最小值的位置即可,若相等, 则该区间所有…
题目链接 假设始终可以找到一种状态使得值为0, 那么两个1之间需要隔n-2个数, 两个2之间需要隔n-3个数, 两个3之间隔n-4个数. 我们发现两个三可以放到两个1之间, 同理两个5放到两个3之间....这样就构造好了. #include <iostream> #include <vector> #include <cstdio> #include <cstring> #include <algorithm> #include <cmat…
预处理p[i],p[i]表示:[p[i],i]这段闭区间上所有数字都是a[i] 询问的时候,如果xi==a[ri]并且p[ri]<=li,一定无解 剩下的情况都是有解的,如果xi!=a[ri],那么输出ri,否则输出p[ri]-1. 另外,看到有大牛博客说可以用线段树,大致是这样的: 线段树保存区间最大值与最小值, 如果询问的区间上最小值==最大值,那么无解: 剩下的情况都是有解:如果xi不等于最小值,那么输出最小值位置:如果xi不等于最大值,那么输出最大值位置. #include <stdi…
C. Not Equal on a Segment time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given array a with n integers and m queries. The i-th query is given with three integers li, ri, xi. For th…
题意: 给你一个数组,m个询问,l,r,x;让你输出在区间[ l , r ]上哪个位置不等于x. 思路: 额..我这个思路还是剽来的...不过真心赞啊. 开个p数组,直接记录数组每个元素的位置,并且实现是最右. 然后对于每个查询,直接询问下限位置的a[ i ]是否等于x,不等于直接输出,等于的话调用p数组,就可以知道,最右啊,然后判断一下最右+1是否<=上限.然后就好啦.这种效率超级提高啊.长见识,长见识. code- //#include <bits/stdc++.h> #includ…
A - Infinite Sequence  CodeForces - 622A 题目大意:给你一个这样的数列1,1,2,1,2,3,1,2,3,4,1,2,3,4,5....就是从1~n排列(n++).最后问你第n个位置是什么数字. 思路:如果你花点时间列数列的话会发现,1~n的最后一位对应的位置是1~n的和,那我们就大胆使用二分进行搜索这位数. #include<iostream> #include<algorithm> #include<cstdio> #incl…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants to reach cinema. The film he has bought a ticket for starts in t minutes. There is a straight road of length s from the service to the cinema. Let's…
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interview down without punctuation marks and spaces to save time. Thus, the interview is now a string s consisting of n lowercase English letters. There is…