QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#288465#7943. LIS on GridpeterWA 6ms4064kbC++141.1kb2023-12-22 18:25:112023-12-22 18:25:12

Judging History

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

  • [2023-12-22 18:25:12]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:4064kb
  • [2023-12-22 18:25:11]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

const int maxn=2e5+5;
int a[maxn],b[maxn];
vector<vector<char> > vec;

int main(){
	
	int q;
	
	scanf("%d",&q);
	
	while(q--){
		vec.clear();
		int n,m,sum=0;
		scanf("%d %d",&n,&m);
		for(int i=1;i<=m;i++){
			scanf("%d",&a[i]);
			sum+=a[i];
		}
		int l=1,r=n,k=r;
		while(l<=r){
			int mid=(l+r)>>1;
			if((n-mid)*mid+m*mid>=sum){
				k=mid;
				r=mid-1;
			}else l=mid+1;
		}
		// printf("kk%d\n",k);
		// exit(0);
		for(int i=0;i<n;i++){
			vector<char> tmp;
			tmp.clear();
			for(int j=0;j<m;j++) tmp.push_back('.');
			vec.push_back(tmp);
		}
		for(int i=0;i<m;i++) b[i]=a[i+1]-k;
		for(int i=n-k;i<n;i++){
			int now=i,cnt=n-k;
			// printf("%d : ",i+1);
			for(int j=0;j<m;j++){
				// printf("%d ",b[j]);
				if(b[j]<0){
					b[j]++;
					continue;
				}
				vec[now][j]='#';
				if(b[j]==0) continue;
				while(cnt&&b[j]){
					now--;
					vec[now][j]='#';
					b[j]--;
					cnt--;
				}
			}
			// puts("");
		}
		printf("%d\n",k);
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++) putchar(vec[i][j]);
			puts("");
		}
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3736kb

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: 6ms
memory: 4064kb

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 Wrong number of colored cells (test case 12)