QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#288256#7943. LIS on GridEdwin_VanCleefRE 0ms3812kbC++141.9kb2023-12-22 12:11:382023-12-22 12:11:39

Judging History

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

  • [2023-12-22 12:11:39]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:3812kb
  • [2023-12-22 12:11:38]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace my_IO{
    #define ll long long
    #define ull unsigned long long
    #define ld long double
    #define spc putchar(' ')
    #define et putchar('\n')
    #define eb emplace_back
    #define gc getchar
    #define pc putchar
    #define pb push_back
    #define lb lower_bound
    template<class T>
    void read(T &num){
        T x=0,f=1;
        char c=gc();
        while(!isdigit(c)){
            if(c=='-') f=-1;
            c=gc();
        }
        while(isdigit(c)){
            x=(x<<3)+(x<<1)+c-48;
            c=gc();
        }
        num=f*x;
    }
    template<class T>
    void write(T x){
        static char buf[40];
        static int len=-1;
        if(x<0) pc('-'),x=-x;
        do{
            buf[++len]=x%10+48;
            x/=10;
        }while(x);
        while(len>=0) pc(buf[len--]);
    }
}
using namespace my_IO;
const int maxn=2e5+10;
int n,m,a[maxn],k,b[maxn];
void solve(){
	read(n),read(m);
	for(int i=1;i<=m;i++) read(a[i]),b[i]=a[i];
	for(int i=1;i<=n;i++){
		int sum=0;
		for(int j=1;j<=m;j++) sum+=max(0,a[j]-i);
		if(i*(n-i)>=sum){
			k=i;
			break;
		}
	}
	write(k),et;
	for(int i=1;i<=m;i++) b[i]=max(0,b[i]-k);
	vector<vector<int>> mp,ans;
	mp.resize(n+10),ans.resize(n+10);
	for(int i=1;i<=n;i++) mp[i].resize(m+10),ans[i].resize(m+10);
	for(int i=1;i<=k;i++){
		int now=n-k+i;
		for(int j=1;j<m;j++){
			mp[now][j]=1;
			while(b[j]&&now!=1){
				now--;
				mp[now][j]=1;
				b[j]--;
			}
		}
		mp[now][m]=1;
		while(now!=i){
			now--;
			mp[now][m]=1;
		}
	}
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			if(!a[i]) break;
			if(mp[j][i]) ans[j][i]=1,a[i]--;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(ans[i][j]) pc('#');
			else pc('.');
		}
		et;
	}
}
int main(){
	int t;
	read(t);
	while(t--) solve();
}

详细

Test #1:

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

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
Runtime Error

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:


result: