QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#717632#1873. ArrayzhaohaikunWA 0ms3784kbC++232.1kb2024-11-06 18:33:412024-11-06 18:33:42

Judging History

你现在查看的是最新测评结果

  • [2024-11-06 18:33:42]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3784kb
  • [2024-11-06 18:33:41]
  • 提交

answer

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,avx2,fma")
// MagicDark
#include <bits/stdc++.h>
#define debug cerr << "[" << __LINE__ << "] "
#define SZ(x) (int) x.size() - 1
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> inline void chkmax(T &x, T y) {x = max(x, y);}
template <typename T> inline void chkmin(T &x, T y) {x = min(x, y);}
template <typename T> inline void read(T &x) {
	x = 0; int f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	x *= f;
}
const int N = 2e5 + 10;
int n, b[N], vis[N], c[N], s[N], a[N];
// vector <int> v[N];
void zhk() {
	read(n);
	F(i, 1, n) vis[i] = -1, s[i] = 0;
	int low = 0, high = n;
	F(i, 1, n) {
		read(b[i]);
		if (b[i] != n + 1) chkmin(high, b[i] - i + 1);
	}
	if (b[1] == n + 1) return puts("No"), void();
	F(i, 1, n)
		if (b[i] < i) return puts("No"), void();
	b[n + 1] = n + 1;
	F(i, 1, n + 1)
		if (b[i] != b[i - 1]) vis[b[i]] = i - 1, s[i]++, s[b[i]]--;
	F(i, 1, n) chkmax(low, s[i] += s[i - 1]);
	// debug << low << ' ' << high << endl;
	low++;
	if (low > high) return puts("No"), void();
	// debug << low << ' ' << high << endl;
	int cnt = 1;
	queue <int> q;
	F(i, 1, n) {
		if (~vis[i]) c[i] = vis[i];
		else{
			if (cnt < low) c[i] = 0, cnt++;
			else {
				assert(q.size());
				c[i] = q.front(), q.pop();
			}
		}
		if (b[i + 1] == b[i]) q.push(i);
	}
	// debug << cnt << endl;
	// F(i, 1, n) cout << c[i] << ' '; debug << endl;
	int tot = 0;
	F(i, 1, n)
		if (!c[i]) a[i] = ++tot;
		else a[i] = a[c[i]];
	puts("Yes");
	F(i, 1, n) cout << a[i] << ' '; cout << '\n';
}
signed main() {
	int _ = 1;
	cin >> _;
	while (_--) zhk();
	return 0;
}
/* why?
*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3784kb

input:

3
4
3 3 5 5
7
4 6 6 7 8 8 8
5
2 3 4 4 6

output:

Yes
1 1 2 2 
Yes
1 2 3 4 2 1 3 
No

result:

wrong output format Expected integer, but "Yes" found