QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#353600#7943. LIS on Griducup-team1004#WA 4ms3900kbC++141.6kb2024-03-14 11:56:032024-03-14 11:56:03

Judging History

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

  • [2024-03-14 11:56:03]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3900kb
  • [2024-03-14 11:56:03]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define all(a) (a).begin(),(a).end()
#ifdef DEBUG
template<class T>
ostream& operator << (ostream &out,vector<T> a){
	out<<'[';
	for(T x:a)out<<x<<',';
	return out<<']';
}
template<class T>
vector<T> ary(T *a,int l,int r){
	return vector<T>{a+l,a+1+r};
}
template<class T>
void debug(T x){
	cerr<<x<<endl;
}
template<class T,class...S>
void debug(T x,S...y){
	cerr<<x<<' ',debug(y...);
}
#else
#define debug(...) void()
#endif
const int N=2e5+10;
int T,n,m,a[N];
#define id(x,y) (((x)-1)*m+(y))
int ans[N],f[N];
bool chk(int mid){
	fill(ans,ans+1+n*m,0);
	fill(f+1,f+1+n,0);
	int cur=0;
	for(int i=1;i<=m;i++){
		int ret=a[i];
		for(int j=1;j<=n&&ret;j++){
			if(f[j])ans[id(j,i)]=1,ret--;
		}
		if(!ret)continue;
		if(!f[n]&&cur<mid){
			ret--,cur++,f[n]=ans[id(n,i)]=1;
		}
		int k=n-1;
		for(;k&&!f[k];k--);
		for(int j=k,las=0;j>=1&&ret;j--){
			if(f[j])las=j;
			else{
				f[j]=1,f[las]=0,ans[id(j,i)]=1;
				ret--,las=j;
			}
		}
		if(ret){
			for(int j=n,las=0;j>k&&ret;j--){
				if(f[j])las=j;
				else{
					if(!las)return 0;
					f[j]=1,f[las]=0,ans[id(j,i)]=1;
					ret--,las=j;
				}
			}
			if(ret)return 0;
		}
	}
	return 1;
}
void get(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	int l=0,r=min(n,m),mid;
	for(;l+1<r;){
		mid=(l+r)>>1;
		if(chk(mid))r=mid;
		else l=mid;
	}
	chk(r);
	printf("%d\n",r);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++)putchar(".#"[ans[id(i,j)]]);
		puts("");
	}
}
int main(){
	for(scanf("%d",&T);T--;)get();
	return 0;
}

詳細信息

Test #1:

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

input:

4
2 4
1 1 1 1
3 3
3 3 3
4 4
4 3 2 1
4 5
2 3 4 3 2

output:

1
....
####
3
###
###
###
2
####
#...
###.
##..
2
..###
.####
####.
###..

result:

ok Correct (4 test cases)

Test #2:

score: -100
Wrong Answer
time: 4ms
memory: 3900kb

input:

5699
5 5
4 5 1 3 5
4 4
3 1 2 4
5 5
2 2 3 3 4
3 4
1 3 2 2
5 5
2 5 3 4 4
4 5
4 1 1 4 1
5 5
3 3 2 5 5
5 5
3 1 3 1 1
5 5
2 4 4 3 2
4 5
2 2 2 2 2
5 5
4 5 3 4 1
5 4
5 4 1 4
5 4
1 1 1 3
4 2
2 4
5 5
2 5 5 2 5
5 5
5 1 2 1 3
5 5
4 4 2 2 3
5 2
5 2
3 5
2 3 3 1 3
5 5
4 2 5 1 1
5 5
4 5 4 1 5
5 4
3 2 5 3
5 5
5 4 1...

output:

3
.####
##..#
##.##
##..#
##.##
2
...#
####
#..#
#.##
2
....#
...##
..##.
###.#
#####
2
.###
.#..
####
3
.####
.#..#
.#.##
####.
#####
2
#####
#..#.
#..#.
#..#.
3
...##
.####
##.##
#..##
#####
1
..###
..#..
###..
#....
#....
2
..###
.##..
.#.##
####.
###..
2
.....
.....
#####
#####
3
.####
##.#.
###...

result:

wrong answer Jury found better answer than participant (test case 196)