QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#691192#7943. LIS on Gridrotcar07WA 4ms3600kbC++23792b2024-10-31 10:20:282024-10-31 10:20:28

Judging History

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

  • [2024-10-31 10:20:28]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3600kb
  • [2024-10-31 10:20:28]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
constexpr int maxn=2e5+5;
int a[maxn],b[maxn];
inline void solve(){
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=m;i++) cin>>a[i];
    int k=1;
    for(;;k++){
        long long sum=0;
        for(int i=1;i<=m;i++) sum+=max(0,a[i]-k);
        if(sum<=k*1ll*(n-k)) break;
    }
    cout<<k<<'\n';
    for(int i=1;i<=m;i++) b[i]=max(0,a[i]-k);
    vector<vector<int>>v(n+1,vector<int>(m+1,0));
    for(int i=1;i<=k;i++){
        int x=n-k+i;
        for(int i=1;i<=m;i++){
            v[x][i]=1;
            while(x>1&&b[i]) b[i]--,v[--x][i]=1;
        }
    }
    for(int i=1;i<=n;i++,putchar('\n'))
    for(int j=1;j<=m;j++)putchar(".#"[v[i][j]&&a[j]-->0]);
}
int main(){
    int t;cin>>t;
    while(t--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
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: 4ms
memory: 3600kb

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