AtCoder Regular Contest 082 D Derangement 与下标相同与下个交换就好了.... Define a sequence of ’o’ and ’x’ of length N as follows: if pi ̸= i, the i-th symbol is ’o’, otherwise the i-th symbol is ’x’. Our objective is to change this sequence to ’ooo...ooo’.• If the…
题意:给你一个排列a,每次可以交换相邻的两个数.让你用最少的交换次数使得a[i] != i. 对于两个相邻的a[i]==i的数,那么一次交换必然可以使得它们的a[i]都不等于i. 对于两个相邻的,其中一个a[i]==i,另一个a[i]!=i的数,一次交换也必然可以使得它们的a[i]都不等于i. 于是可以把序列划分成多段连续的a[i]==i的段落,它所贡献的交换次数就是[(长度+1)/2]. #include<cstdio> using namespace std; int n,a[100005…
我都出了F了……结果并没有出E……atcoder让我差4分上橙是啥意思啊…… C - Together 题意:把每个数加1或减1或不变求最大众数. #include<cstdio> #include<algorithm> using namespace std; int read_p,read_ca; inline int read(){ read_p=;read_ca=getchar(); ') read_ca=getchar(); +read_ca-,read_ca=getch…
A #include<bits/stdc++.h> using namespace std; ]; int n,m; int main(){ cin>>n>>m; cout<<max(,n-m)<<endl; ; } B #include<bits/stdc++.h> using namespace std; ]; int n,m; int main(){ string s; cin>>s; string ans = &q…
Problem Statement You are given N points (xi,yi) located on a two-dimensional plane. Consider a subset S of the N points that forms a convex polygon. Here, we say a set of points S forms a convex polygon when there exists a convex polygon with a posi…
Problem Statement We have a sandglass consisting of two bulbs, bulb A and bulb B. These bulbs contain some amount of sand. When we put the sandglass, either bulb A or B lies on top of the other and becomes the upper bulb. The other bulb becomes the l…
AtCoder Regular Contest 094 C - Same Integers 题意: 给定\(a,b,c\)三个数,可以进行两个操作:1.把一个数+2:2.把任意两个数+1.求最少需要几次操作将三个数变为相同的数. 分析: 可以发现如果三个数的奇偶性相同直接加就可以了,对于奇偶性不同的,先把奇偶性相同的两个数都+1,然后按照相同的处理就可以了.可以证明没有更好的方案. #include <bits/stdc++.h> using namespace std; int a,b,c,…
D - Menagerie Time limit : 2sec / Memory limit : 256MB Score : 500 points Problem Statement Snuke, who loves animals, built a zoo. There are N animals in this zoo. They are conveniently numbered 1 through N, and arranged in a circle. The animal numbe…