QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#142340#6636. Longest Strictly Increasing SequenceCrysflyAC ✓2ms5664kbC++17995b2023-08-18 23:38:032023-08-18 23:38:05

Judging History

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

  • [2023-08-18 23:38:05]
  • 评测
  • 测评结果:AC
  • 用时:2ms
  • 内存:5664kb
  • [2023-08-18 23:38:03]
  • 提交

answer

#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define int long long
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 200005
#define inf 0x3f3f3f3f

int n,b[maxn],a[maxn];
bool vis[maxn];
void work()
{
	n=read();
	For(i,1,n)b[i]=read(),vis[i]=0;
	For(i,1,n){
		if(b[1]!=1){
			puts("NO");
			return;
		}
		if(b[i]<b[i-1] || b[i]>b[i-1]+1){
			puts("NO");
			return;
		}
		vis[i]=b[i]-b[i-1];
	}
	puts("YES");
	int p1=n-b[n]+1,p2=n-b[n];
	For(i,1,n)
		if(vis[i])cout<<p1<<" ",++p1;
		else cout<<p2<<" ",--p2;
	puts("");
}

signed main()
{
	int T=read();
	while(T--)work(); 
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5664kb

input:

2
6
1 2 3 2 5 7
2
1 2

output:

NO
YES
1 2 

result:

ok t=2 (2 test cases)

Test #2:

score: 0
Accepted
time: 2ms
memory: 5500kb

input:

3483
5
2 3 5 1 1
2
8 1
10
1 2 3 4 4 5 6 6 6 7
10
1 1 2 2 2 2 3 4 4 5
2
5 8
3
7 10 8
5
4 1 3 3 8
10
1 2 2 2 2 2 2 3 3 3
10
1 1 2 3 4 5 5 5 5 6
9
1 2 3 4 5 5 6 6 7
7
8 8 8 8 9 1 2
5
8 9 8 3 5
10
1 2 3 3 3 3 4 4 4 5
5
7 1 6 4 3
7
5 6 8 6 1 5 5
10
1 2 2 3 4 4 4 4 5 5
3
10 4 5
3
1 5 3
5
2 8 1 2 1
3
7 8 3...

output:

NO
NO
YES
4 5 6 7 3 8 9 2 1 10 
YES
6 5 7 4 3 2 8 9 1 10 
NO
NO
NO
YES
8 9 7 6 5 4 3 10 2 1 
YES
5 4 6 7 8 9 3 2 1 10 
YES
3 4 5 6 7 2 8 1 9 
NO
NO
YES
6 7 8 5 4 3 9 2 1 10 
NO
NO
YES
6 7 5 8 9 4 3 2 10 1 
NO
NO
NO
NO
NO
NO
YES
6 5 4 7 3 8 2 9 1 
NO
NO
NO
NO
NO
NO
NO
YES
6 7 8 5 4 9 3 2 10 1 
YES
8 ...

result:

ok t=3483 (3483 test cases)