QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#367554#7943. LIS on GridmcpqndqWA 5ms3604kbC++171.3kb2024-03-26 07:08:392024-03-26 07:08:40

Judging History

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

  • [2024-03-26 07:08:40]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:3604kb
  • [2024-03-26 07:08:39]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define F first
#define S second
#define pb push_back
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);
	ll tests;cin>>tests;
	while(tests--){
		ll n,m;cin>>n>>m;
		vi a(m);rep(i,0,m)cin>>a[i];
		vi og=a;

		vi o=a;sort(all(o));
		vi ps(m+1,0);
		rep(i,0,m)ps[i+1]=o[i]+ps[i];
		ll hi = min(n,m);
		rep(k,0,min(n,m)){
			ll right = k*(n-k);
			ll i = lower_bound(all(o),k+1)-o.begin();
			ll left = ps[m]-ps[i]-(m-i)*k;
			// cout<<k<<' '<<right<<" "<<left<<' '<<(ps.back()-ps[i])<<' '<<((m-i)*k)<<endl;
			if(left<=right) hi=min(hi,(ll)k);
		}
		ll k = hi;
		cout<<k<<'\n';
		vector<vector<bool>> g(n,vector<bool>(m,false));
		rep(i,0,n)a[i]=max(a[i],k);
		vi b=a;rep(i,0,m)b[i]-=k;
		rep(i,0,k){
			ll y = n-k+i;
			rep(x,0,m){
				g[y][x]=true;
				while(b[x]>0 && y>0 && !g[y-1][x]){
					g[--y][x]=true;
					b[x]--;
				}
			}
		}
		rep(x,0,m){
			ll tot = 0;
			rep(y,0,n){
				tot += g[y][x];
				if(tot>og[x]) g[y][x]=false;
			}
		}
		rep(i,0,n){
			rep(j,0,m)cout<<(g[i][j]?'#':'.');
			cout<<'\n';
		}


	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 3604kb

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 score (test case 844)