您当前的位置: 首页 > 

先求一个导

暂无认证

  • 1浏览

    0关注

    291博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

2021-08-19,20级限时训练

先求一个导 发布时间:2021-08-19 23:46:58 ,浏览量:1

CF987E 思维题 在这里插入图片描述 没有思路,经典不会就搜,坏习惯。 可以发现3n 和 7n+1奇偶性不同,就从这里下手。 思路: 假设最终的序列中逆序对数量为k. 每次交换都会使逆序对+1或者-1,假设+1数量为x,-1数量为y. 对于3n的操作。x + y = 3n, x - y = k. 所以2x = 3n + k. 所以3n 和 k同奇或同偶。 所以判断一下逆序对个数和3*n的奇偶性即可。

20级带lao写了O(n)的做法,与permutation性质有关,tql,我不会,只会树状数组。

// Problem: E. Petr and Permutations
// Contest: Codeforces - Codeforces Round #485 (Div. 2)
// URL: https://codeforces.com/problemset/problem/987/E
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 
// Powered by CP Editor (https://cpeditor.org)

#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define OldTomato ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define fir(i,a,b) for(int i=a;iT;
   read(T);
   while(T--)
   {
   	 solve();
   }
   return 0;
}

晚安。

关注
打赏
1662037414
查看更多评论
立即登录/注册

微信扫码登录

0.0387s