ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

CF1691B Shoe Shuffling

2022-06-04 08:02:01  阅读:183  来源: 互联网

标签:CF1691B 10 int Shuffling cdots Shoe need include define


洛谷题面

题目大意

求出每一个大小相同的“块”,如果有块的大小为 \(1\) 则无解。

否则,我们对于每个“块”,设组成此“块”的每个元素的下标为 \([i,i+1,\cdots,i+k]\),则答案排列为 \([i+k,i,i+1,\cdots,i+k-1]\)。

注意求无解和输出要分开操作。

代码

#include <iostream>
#include <cstdio>
#include <climits>//need "INT_MAX","INT_MIN"
#include <cstring>//need "memset"
#include <numeric>
#include <algorithm>
#include <cmath>
#include <map>
#define enter putchar(10)
#define debug(c,que) std::cerr << #c << " = " << c << que
#define cek(c) puts(c)
#define blow(arr,st,ed,w) for(register int i = (st);i <= (ed); ++ i) std::cout << arr[i] << w;
#define speed_up() std::ios::sync_with_stdio(false),std::cin.tie(0),std::cout.tie(0)
#define mst(a,k) memset(a,k,sizeof(a))
#define stop return(0)
const int mod = 1e9 + 7;
inline int MOD(int x) {
	if(x < 0) x += mod;
	return x % mod;
}
namespace Newstd {
	inline int read() {
		int ret = 0,f = 0;char ch = getchar();
		while (!isdigit(ch)) {
			if(ch == '-') f = 1;
			ch = getchar();
		}
		while (isdigit(ch)) {
			ret = (ret << 3) + (ret << 1) + ch - 48;
			ch = getchar();
		}
		return f ? -ret : ret;
	}
	inline double double_read() {
		long long ret = 0,w = 1,aft = 0,dot = 0,num = 0;
		char ch = getchar();
		while (!isdigit(ch)) {
			if (ch == '-') w = -1;
			ch = getchar();
		}
		while (isdigit(ch) || ch == '.') {
			if (ch == '.') {
				dot = 1;
			} else if (dot == 0) {
				ret = (ret << 3) + (ret << 1) + ch - 48;
			} else {
				aft = (aft << 3) + (aft << 1) + ch - '0';
				num ++;
			}
			ch = getchar();
		}
		return (pow(0.1,num) * aft + ret) * w;
	}
	inline void write(int x) {
		if(x < 0) {
			putchar('-');
			x = -x;
		}
		if(x > 9) write(x / 10);
		putchar(x % 10 + '0');
	}
}
using namespace Newstd;
 
const int N = 1e5 + 5;
int a[N];
int n;
inline void solve() {
	mst(a,0);
	n = read();
	bool mark = true;
	for (register int i = 1;i <= n; ++ i) {
		a[i] = read();
	}
	int L = 1,R = 1;
	while (R <= n) {
		while (R + 1 <= n && a[L] == a[R + 1]) R ++;
		if (L == R) {
			puts("-1");
			return;
		}
		L = R + 1;
		R ++;
	}
	L = R = 1;
	while (R <= n) {
		while (R + 1 <= n && a[L] == a[R + 1]) R ++;
		if (L == R) {
			puts("-1");
			return;
		}
		printf("%d ",R);
		for (register int i = L;i < R; ++ i) printf("%d ",i);
		L = R + 1;
		R ++;
	}
	puts("");
}
int main(void) {
	int T = read();
	while (T --) {
		solve();
	}
	
	return 0;
}

标签:CF1691B,10,int,Shuffling,cdots,Shoe,need,include,define
来源: https://www.cnblogs.com/Coros-Trusds/p/16341202.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有