题解 [CF1604B] XOR Specia-LIS-t

传送门

并不能想到

发现当 \(n\) 为偶数的时候将序列分为 \(n\) 个长度为1的就可以
\(n\) 为奇数时若存在一个 \(a_i\geqslant a_{i+1}\) 则可以将这两个点分到一个子序列里,一样有解
同时不满足这两个条件的一定是长度为奇数的上升子序列
若将其划分为多个子序列,发现这些子序列长度之和为 \(n\)

  • 将一个整数划分为一些 \(a_1+a_2+...+a_n\),要求异或和为0:仅在n为偶数时有解
    证明:n为偶数时分为两个 \(\frac{n}{2}\) 即可
    n为奇数时不管怎么分,结果中一定含奇数个奇数,于是异或和的最后一位一定为1、
Code:
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define N 100010
#define ll long long
//#define int long long

char buf[1<<21], *p1=buf, *p2=buf;
#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf, 1, 1<<21, stdin)), p1==p2?EOF:*p1++)
inline int read() {
	int ans=0, f=1; char c=getchar();
	while (!isdigit(c)) {if (c=='-') f=-f; c=getchar();}
	while (isdigit(c)) {ans=(ans<<3)+(ans<<1)+(c^48); c=getchar();}
	return ans*f;
}

int n;
int a[N];

signed main()
{
	int T=read();
	while (T--) {
		n=read();
		for (int i=1; i<=n; ++i) a[i]=read();
		if (!(n&1)) {puts("Yes"); continue;}
		for (int i=1; i<n; ++i) if (a[i]>=a[i+1]) {puts("Yes"); goto jump;}
		puts("No");
		jump: ;
	}

	return 0;
}
posted @ 2021-11-12 19:21  Administrator-09  阅读(3)  评论(0编辑  收藏  举报