QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#353589#7943. LIS on Griducup-team1004#WA 5ms3924kbC++141.4kb2024-03-14 11:38:222024-03-14 11:38:22

Judging History

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

  • [2024-03-14 11:38:22]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:3924kb
  • [2024-03-14 11:38:22]
  • 提交

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;
		int k=n;
		if(cur==mid){
			for(;k&&!f[k];k--);
		}
		for(int j=k,las=0;j>=1&&ret;j--){
			if(f[j])las=j;
			else{
				f[j]=1,ans[id(j,i)]=1;
				if(las)f[las]=0;
				else cur++;
				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: 0ms
memory: 3912kb

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: 5ms
memory: 3924kb

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 21)