链接: https://codeforces.com/contest/1272/problem/B 题意: Recently you have bought a snow walking robot and brought it home. Suppose your home is a cell (0,0) on an infinite grid. You also have the sequence of instructions of this robot. It is written as…
比赛传送门 Div3真的是暴力杯,比div2还暴力吧(这不是明摆的嘛),所以对我这种一根筋的挺麻烦的,比如A题就自己没转过头来浪费了很久,后来才醒悟过来了.然后这次竟然还上分了...... A题:爆搜 B题:字符串,简单贪心 C题:字符串,简单数学 D题:DP A. Three Friends time limit per test 1 second memory limit per test 256 megabytes input standard input output standard…
地址:http://codeforces.com/contest/1272 A. Three Friends 仔细读题能够发现|a-b| + |a-c| + |b-c| = |R-L|*2 (其中L = min{a, b, c}, R = max{a, b, c}) 那么本题的移动条件就只考虑两个端点L, R即可,答案即为 |(L+1)-(R-1)| 即L向右移动1,R向左移动1,在此之前判断一下原L,R之间的距离是否<=2,<=2输出0 #include <bits/stdc++.h&…
Three Friends Snow Walking Robot Yet Another Broken Keyboard Remove One Element Nearest Opposite Parity Two Bracket Sequences Three Friends \[ Time Limit: 1 s\quad Memory Limit: 256 MB \] 根据题意,把最大的减一,最小的加一,然后答案就是两倍他们的差值 view #include <map> #include…
题目链接:Codeforces Round #275 (Div. 2) C - Diverse Permutation 题意:一串排列1~n.求一个序列当中相邻两项差的绝对值的个数(指绝对值不同的个数)为k个.求序列. 思路:1~k+1.构造序列前段,之后直接输出剩下的数.前面的构造能够依据,两项差的绝对值为1~k构造. AC代码: #include <stdio.h> #include <string.h> int ans[200010]; bool vis[100010]; i…
A. Snow Footprints 题目连接: http://www.codeforces.com/contest/298/problem/A Description There is a straight snowy road, divided into n blocks. The blocks are numbered from 1 to n from left to right. If one moves from the i-th block to the (i + 1)-th blo…
题目链接:http://codeforces.com/contest/1272/problem/E 题意:给定n,给定n个数a[i],对每个数输出d[i]. 对于每个i,可以移动到i+a[i]和i-a[i](如果i+a[i]<=n,i-a[i]>=1) d[i]是指从i移动到任意一个j的步数,需满足条件a[i]和a[j]的奇偶性不同 不论奇偶,相连的边先放进vector邻接表中 如果i和i+a[i]奇偶性不同,那么ans[i]为1,把i放到queue队列里 同理,如果i和i-a[i]奇偶性不同…
链接: https://codeforces.com/contest/1272/problem/E 题意: You are given an array a consisting of n integers. In one move, you can jump from the position i to the position i−ai (if 1≤i−ai) or to the position i+ai (if i+ai≤n). For each position i from 1 to…
链接: https://codeforces.com/contest/1272/problem/D 题意: You are given an array a consisting of n integers. You can remove at most one element from this array. Thus, the final length of the array is n−1 or n. Your task is to calculate the maximum possib…
链接: https://codeforces.com/contest/1272/problem/C 题意: Recently, Norge found a string s=s1s2-sn consisting of n lowercase Latin letters. As an exercise to improve his typing speed, he decided to type all substrings of the string s. Yes, all n(n+1)2 of…
链接: https://codeforces.com/contest/1272/problem/A 题意: outputstandard output Three friends are going to meet each other. Initially, the first friend stays at the position x=a, the second friend stays at the position x=b and the third friend stays at t…
比赛情况 2h才刀了A,B,C,D.E题的套路做的少,不过ygt大佬给我讲完思路后赛后2min就AC了这题. 比赛总结 比赛时不用担心"时间短,要做多快",这样会匆匆忙忙,反而会做得慢.比赛时应该要不紧不慢,理性思考,内心平静,题目反而会迎刃而解. 这次比赛又看错了题(B,D). 解决办法:这次比赛看错题是因为不够细心,不够细心是因为急躁,怕做不完.所以沉稳冷静的分析,反而能更好地完成比赛. 那么就开始上题解吧! A cf常出的分类讨论题(OI好像不考?). 如果三个人的位置互不相同,…
C. Vladik and fractions 题目链接 http://codeforces.com/contest/743/problem/C 题面 Vladik and Chloe decided to determine who of them is better at math. Vladik claimed that for any positive integer n he can represent fraction as a sum of three distinct posit…
A. Alyona and mex 题目连接: http://codeforces.com/contest/739/problem/A Description Alyona's mother wants to present an array of n non-negative integers to Alyona. The array should be special. Alyona is a capricious girl so after she gets the array, she…
E. Brackets in Implications Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550/problem/E Description Implication is a function of two logical arguments, its value is false if and only if the value of the first argument is…
B. Kyoya and Permutation Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/553/problem/B Description Let's define the permutation of length n as an array p = [p1, p2, ..., pn] consisting of n distinct integers from range from…
C. The Closest Pair Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/C Description Currently Tiny is learning Computational Geometry. When trying to solve a problem called "The Closest Pair Of Points In The Plane…
上几次的一道cf题. 题目:http://codeforces.com/contest/376/problem/C 性质: (4)a与b的和除以c的余数(a.b两数除以c在没有余数的情况下除外),等于a,b分别除以c的余数之和(或这个和除以c的余数).例如,23,16除以5的余数分别是3和1,所以(23+16)除以5的余数等于3+1=4.注意:当余数之和大于除数时,所求余数等于余数之和再除以c的余数.例如,23,19除以5的余数分别是3和4,所以(23+19)除以5的余数等于(3+4)除以5的余…
B. Invariance of Tree Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/576/problem/B Description A tree of size n is an undirected connected graph consisting of n vertices without cycles. Consider some tree with n vertices. W…
http://codeforces.com/contest/465/problem/C 给定n和m,以及一个字符串s,s不存在长度大于2的回文子串,现在要求输出一个字典比s大的字符串,且串中字母在一定范围内,并且说同样不存在长度大于2的回文子串. 直接去递归构造即可,从最后一位开始,每次只要判断是否子串中含有回文串,其实仔细想想只要考虑是否存在一个字符和前两个字符中的一个相同即可.不卡时限,裸的判断都能过 #include <cstdio> #include <cstdlib> #…
E. Dasha and Puzzle 题目连接: http://codeforces.com/contest/761/problem/E Description Dasha decided to have a rest after solving the problem. She had been ready to start her favourite activity - origami, but remembered the puzzle that she could not solve…
D. Dreamoon and Sets 题目连接: http://www.codeforces.com/contest/476/problem/D Description Dreamoon likes to play with sets, integers and . is defined as the largest positive integer that divides both a and b. Let S be a set of exactly four distinct inte…
A. Exam Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/534/problem/A Description An exam for n students will take place in a long and narrow room, so the students will sit in a line in some order. The teacher suspects that…
题目链接: http://codeforces.com/contest/606/problem/D D. Lazy Student time limit per test2 secondsmemory limit per test256 megabytes 问题描述 Student Vladislav came to his programming exam completely unprepared as usual. He got a question about some strange…
B. Sea and Islands Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/544/problem/B Description A map of some object is a rectangular field consisting of n rows and n columns. Each cell is initially occupied by the sea but yo…
题目链接:http://codeforces.com/contest/1041/problem/E 题意:给出n - 1对pair,构造一颗树,使得断开其中一条边,树两边的最大值为 a 和 b . 题解:显示最大值出现的次数为n - 1,且i点出现的次数小于等于i.一个数字 i(< n)出现的次数为 i 到 n 的距离,可构造出一条链使得满足条件. #include <bits/stdc++.h> using namespace std; #define ll long long #de…
链接: https://codeforces.com/contest/1230/problem/B 题意: Ania has a large integer S. Its decimal representation has length n and doesn't contain any leading zeroes. Ania is allowed to change at most k digits of S. She wants to do it in such a way that S…
A. Alyona and copybooks time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little girl Alyona is in a shop to buy some copybooks for school. She study four subjects so she wants to have equal…
题意 给出一个1-n的集合   gcd 集合里面的所有数  得到的 一个 数   然后自己选择删去一个数   要使得到的数 构成的数列 的字典序最大 思路: gcd所有数 那gcd得到的数肯定要小于数组中最小的数  所以 刚开始都是1   所以优先删去1  那就要使gcd所有数经可能快得到 2 如何快速到2 呢 那就是把奇数全部删掉  那剩下得数最小就为2 了  此时为 2 4 6 8 10....  此刻就从2开始删   当n==3时 有 x ,2x,3x  此时 只有 删 x 2 x   3…