B - WeirdSort】的更多相关文章

Solution 按照 \(p[i]\) 进行分段,如果某个 \(k\) 不存在 \(p[i]=k\),那么就把 \(i,i+1\) 分割开 处理出每一段的左端点和右端点 进而处理出每段的最小值和最大值 如果存在第 \(i\) 段的最大值大于第 \(i+1\) 段的最小值,就输出 NO #include <bits/stdc++.h> using namespace std; #define reset(x) memset(x,0,sizeof x) const int N = 1005; i…
output standard output You are given an array aa of length nn . You are also given a set of distinct positions p1,p2,…,pmp1,p2,…,pm , where 1≤pi<n1≤pi<n . The position pipi means that you can swap elements a[pi]a[pi] and a[pi+1]a[pi+1] . You can app…
You are given an array a of length n. You are also given a set of distinct positions p1,p2,-,pm, where 1≤pi<n. The position pi means that you can swap elements a[pi] and a[pi+1]. You can apply this operation any number of times for each of the given…
Codeforces Round #624 (Div.3) 题目地址:https://codeforces.ml/contest/1311 B题:WeirdSort 题意:给出含有n个元素的数组a,和m个元素的数组p,p中元素表示可调换(p=[3,2]表示a中下标为3和下标为3+1的元素可调换,2和2+1可调换),问能否使得原数组成为非降序数组 思路:暴力,模仿冒泡排序 AC代码: #include<bits/stdc++.h> typedef long long ll; using name…
A. Add Odd or Subtract Even 思路: 相同直接为0,如果两数相差为偶数就为2,奇数就为1 #include<iostream> #include<algorithm> using namespace std; int main(){ int kk; scanf("%d",&kk); while(kk--){ int n,m; cin>>n>>m; if(n==m) {printf("0\n&qu…