求 hack Div2 T1 感觉自己写的很假
  • 板块灌水区
  • 楼主Buried_Dream
  • 当前回复7
  • 已保存回复7
  • 发布时间2022/4/10 18:33
  • 上次更新2023/10/28 04:03:13
查看原帖
求 hack Div2 T1 感觉自己写的很假
396974
Buried_Dream楼主2022/4/10 18:33
/*
	Work by: TLE_Automation
*/
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
//#define int long long
using namespace std;

const int N = 1e6 + 10;
const int MAXN = 2e5 + 10;

inline char readchar() {
	static char buf[100000], *p1 = buf, *p2 = buf;
	return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++;
}

inline int read() {
#define readchar getchar
	int res = 0, f = 0;
	char ch = readchar();
	for(; !isdigit(ch); ch = readchar()) if(ch == '-') f = 1;
	for(; isdigit(ch); ch = readchar()) res = (res << 1) + (res << 3) + (ch ^ '0');
	return f ? -res : res;
}

inline void print(int x) {
	if (x < 0 ) putchar('-'), x = -x;
	if (x > 9 ) print(x / 10);
	putchar(x % 10 + '0');
}

int p[N], ans[N], n;

bool Check() {
	for(int i = 1; i <= n; i++) if(ans[i] > 1000) return false;
	return true;
}
#define re register
void mian() {
	n = read();
	for(re int i = 1; i <= n; i++) p[i] = read();
	for(re int i = 1; i <= n; i++) p[i] = std::max(p[i], p[i - 1] + 1);
	for(re int i = 1; i <= n; i++) ans[i] = p[i] - p[i - 1];
	if(!Check()) {
		for(re int k = 1; k <= n; k++) {
			if(Check()) break;
			for(re int i = 1; i <= n; i++) {
				if( ans[i] >= 1000) {
					int C = ans[i] - 1000;
					ans[i + 1] += C;
					ans[i] = 1000;
					continue;
				}
				if(ans[i + 1] >= 1000) {
					int C = ans[i + 1] - 1000;
					ans[i] += C;
					ans[i + 1] = 1000;
					continue;
				}
				if( ans[i - 1] >= 1000) {
					i nt C = ans[i - 1] - 1000;
					ans[i] += C;
					ans[i - 1] = 1000;
					continue;
				}
			}
		}
	}
	for(re int i = 1; i <= n; i++) printf("%d ", ans[i]);
	cout << "\n";
}

signed main() {
	int T = read();
	while(T--) mian();
}
2022/4/10 18:33
加载中...