CodeForces 669D Little Artem and Dance】的更多相关文章

题目链接: Codeforces 669D Little Artem and Dance 题目描述: 给一个从1到n的连续序列,有两种操作: 1:序列整体向后移动x个位置, 2:序列中相邻的奇偶位置互换. 问:q次操作后,输出改变后的序列? 解题思路: 刚开始只看了第一组样例,发现相邻的奇偶位一直在一起,于是乎就开始writing code,写完后发现并不是正解!!!!就去推了一下第三个样例,总是这组实例通过,那组实例卡死,,,,,,,最后终于成功的Mengbility.今天突然想起来,其实整体…
http://codeforces.com/problemset/problem/669/D 题意:n个数1~N围成一个圈.q个操作包括操作1:输入x, 所有数右移x.操作2:1,2位置上的数(swap(a[1], a[2])交换:3,4交换.... 题解:观察,发现所有奇数行为都是一样的,偶数同理,(对于操作1 两者相同,对于操作2 奇数位++,偶数位上--: 模拟1,2,即可,然后依次输出其它数字即可.(看清 ac代码: #define _CRT_SECURE_NO_WARNINGS #in…
模拟. 每个奇数走的步长都是一样的,每个偶数走的步长也是一样的. 记$num1$表示奇数走的步数,$num2$表示偶数走的步数.每次操作更新一下$num1$,$num2$.最后输出. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #i…
B. Little Artem and Dance time limit per test 2 second memory limit per test 256 megabytes input standard input output standard output Little Artem is fond of dancing. Most of all dances Artem likes rueda - Cuban dance that is danced by pairs of boys…
题目链接: D. Little Artem and Dance time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Artem is fond of dancing. Most of all dances Artem likes rueda — Cuban dance that is danced by pairs…
D. Little Artem and Dance 题目连接: http://www.codeforces.com/contest/669/problem/D Description Little Artem is fond of dancing. Most of all dances Artem likes rueda - Cuban dance that is danced by pairs of boys and girls forming a circle and dancing tog…
题目链接:http://codeforces.com/problemset/problem/669/D D. Little Artem and Dance time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Artem is fond of dancing. Most of all dances Artem like…
D. Little Artem and Dance Little Artem is fond of dancing. Most of all dances Artem likes rueda - Cuban dance that is danced by pairs of boys and girls forming a circle and dancing together. More detailed, there are n pairs of boys and girls standing…
题目链接: http://codeforces.com/contest/669/problem/D 题意: 给你一个初始序列:1,2,3,...,n. 现在有两种操作: 1.循环左移,循环右移. 2.1,2位置交换,3,4位置交换,...,n-1,n位置交换 现在问执行了q次操作之后序列是什么,每次操作可以是两种操作的任意一种 题解: 我们把数列按位置的奇偶分为两堆,无论哪种操作,始终都还是这两堆,最多就是整堆的对换和一个堆内部的偏移. 所以我们只要记录第一个位置和第二个位置的数的变化(相当于每…
题意:2种操作,转动或者奇偶位互换. 不论怎么交换,1的后两位一定是3,3的后两位一定是5.因此只要记录1,2的位置. //#pragma comment(linker,"/STACK:1024000000,1024000000") #include<iostream> #include<cstdio> #include<string> #include<cstring> #include<vector> #include&l…
题目链接:http://codeforces.com/problemset/problem/669/D Little Artem is fond of dancing. Most of all dances Artem likes rueda — Cuban dance that is danced by pairs of boys and girls forming a circle and dancing together. More detailed, there are n pairs…
Little Artem is fond of dancing. Most of all dances Artem likes rueda — Cuban dance that is danced by pairs of boys and girls forming a circle and dancing together. More detailed, there are n pairs of boys and girls standing in a circle. Initially, b…
题目链接: C. Artem and Array time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Artem has an array of n positive integers. Artem decided to play with it. The game consists of n moves. Each move g…
题目链接:http://codeforces.com/contest/814/problem/D 题意:给出奇数个舞者,每个舞者都有中心坐标和行动半径,而且这些点组成的园要么相互包含要么没有交集求,讲这些点分成两部分最大面积是多少. 面积计算方法详见题目,很好理解有图示. 题解:这题挺简单的就考虑一下包含与不包含的就行了.具体看一下代码挺好理解的,主要是题目给出的这些点组成的园要么相互包含要么没有交集求导致 这题变得很简单 #include <iostream> #include <cm…
题目链接:http://codeforces.com/contest/668/problem/C ------------------------------------------------------------------------------------------- 大概看一下发现题目给了一些条件限制 然后要解一个方程组 不过数据范围很大 如果直接去解的话显然很困难 考虑到此题是建立在概率的模型上的 因此我们可以用前缀和的方式先把输入处理一下 然后就转化为以下子问题 $0 <= x…
题目 感谢JLGG的指导! 思路: //把数据转换成一条折线,发现有凸有凹 //有凹点,去掉并加上两边的最小值//无凹点,直接加上前(n-2)个的和(升序)//数据太大,要64位//判断凹与否,若一边等于,一边大于,那中间这个也算是凹进去的,所以判断时要加上等于 //有凹点,去掉并加上两边的最小值 //无凹点,直接加上前(n-2)个的和(升序) //数据太大,要64位 //判断凹与否,若一边等于,一边大于,那中间这个也算是凹进去的,所以判断时要加上等于 #include<stdio.h> #i…
树状数组,$map$. 可以理解为开一个数组$f[i][j]$记录:$i$这个数字在时间$j$的操作情况. 操作$1$:$f[x][t]++$.操作$2$:$f[x][t]--$.操作$3$:$f[x][1]$至$f[x][t]$求和. 数组开不出来,但可以开$map$,状态最多$100000$个,所以还是不会超时的,数字范围有点大,可以离散化一下. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<…
模拟. 把操作记录一下,倒着复原回去. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #include<set> #include<…
目录 @description@ @solution@ @accepted code@ @details@ @description@ 给定两个 2-sat 问题,询问两个问题的解集是否相同. 如果不相同,构造一组解 {xi},使得这个解是其中一个问题的解同时不是另一个问题的解. 原题链接. @solution@ 如果两者解集都为空,那么解集相同. 如果两者只有一个解集为空,则取另一个问题的任意解即可. 如果都有解,先跑个 bitset 优化的传递闭包,方便接下来的处理. 此时有一些变量的值是确…
A - Little Artem and Presents (div2) 1 2 1 2这样加就可以了 #include <bits/stdc++.h> typedef long long ll; const int N = 1e5 + 5; int main() { int n; scanf ("%d", &n); int ans = n / 3 * 2; if (n % 3) { ans++; } printf ("%d\n", ans);…
D. Little Artem and Dance time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Little Artem is fond of dancing. Most of all dances Artem likes rueda — Cuban dance that is danced by pairs of boy…
题目连接:Codeforces 442C Artem and Array 题目大意:给出一个数组,每次删除一个数.删除一个数的得分为两边数的最小值,假设左右有一边不存在则算作0分. 问最大得分是多少. 解题思路:首先将连续的a,b,c,a > b && c > b的情况将c掉,获得min(a,b)分,这样处理后数组变成一个递増再递减的序列,除了最大和第二大的取不到.其它数字均能够得分. 例子:4 10 2 2 8 #include <cstdio> #include…
C. Little Artem and Random Variable 题目连接: http://www.codeforces.com/contest/668/problem/C Description Little Artyom decided to study probability theory. He found a book with a lot of nice exercises and now wants you to help him with one of them. Cons…
E. Little Artem and Time Machine 题目连接: http://www.codeforces.com/contest/669/problem/E Description Little Artem has invented a time machine! He could go anywhere in time, but all his thoughts of course are with computer science. He wants to apply thi…
C. Little Artem and Matrix 题目连接: http://www.codeforces.com/contest/669/problem/C Description Little Artem likes electronics. He can spend lots of time making different schemas and looking for novelties in the nearest electronics store. The new contro…
B. Little Artem and Grasshopper 题目连接: http://www.codeforces.com/contest/669/problem/B Description Little Artem found a grasshopper. He brought it to his house and constructed a jumping area for him. The area looks like a strip of cells 1 × n. Each ce…
A. Little Artem and Presents 题目连接: http://www.codeforces.com/contest/669/problem/A Description Little Artem got n stones on his birthday and now wants to give some of them to Masha. He knows that Masha cares more about the fact of receiving the prese…
Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque 题意: 给\(n(n <= 1000)\)个圆,圆与圆之间不存在相交关系,只存在包含与不包含关系,现在问你把这一堆圆分成两组,求每组圆的异或并和的最大值. 思路:最简单的做法是贪心的做法,算出每个圆被包含的次数,为偶数则贡献为正,奇数为贡献为负. 现在主要学习一下树形dp的做法 由于圆不存在相交的情况,所以可以把所有的圆建成树,即把每棵树上的点分成两组,分别建成…
传送门 题意: 有 n 个孩子编号为 1~n ,绕着圣诞树 dance: 编号为 i 的孩子可以记住ai1,ai2两个小孩,ai1,ai2是 i 在顺时针方向的相邻的两个小孩,但ai1,ai2不一定是按顺时针方向排列的: 给出每个孩子相邻两个孩子的信息,让你还原这个序列. 题解: 可以以任一孩子作为第一个孩子,假设以编号 1 为第一个,编号1有两个相邻的孩子信息 a,b 如果 b 在 a 的顺时针方向,那么第二个孩子就是 a,反之为 b. 确定了前两个孩子后 i 从 1 开始遍历,第 i 个孩子…
Artem and Array 经过分析我们能发现, 如果对于一个a[ i ] <= a[ i + 1 ] && a[ i ] <= a[ i - 1 ]可以直接删掉. 最后剩下一个先增后减的序列, 除了最大的两个都能加上. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<L…