QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#574297#7943. LIS on Gridrqoi031WA 4ms3836kbC++201.1kb2024-09-18 21:26:202024-09-18 21:26:20

Judging History

This is the latest submission verdict.

  • [2024-09-18 21:26:20]
  • Judged
  • Verdict: WA
  • Time: 4ms
  • Memory: 3836kb
  • [2024-09-18 21:26:20]
  • Submitted

answer

#include<stdio.h>
#include<algorithm>
#include<vector>
int a[200005],_a[200005];
char s[200005];
void solve() {
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i!=m;i++) {
        scanf("%d",a+i);
    }
    int k(0);
    while([&]()->bool {
        int c(0);
        for(int i=0;i!=m;i++) {
            c+=std::max(a[i]-k,0);
        }
        return c>k*(n-k);
    }()) {
        ++k;
    }
    for(int i=0;i!=m;i++) {
        _a[i]=std::max(a[i]-k,0);
    }
    std::vector<std::vector<bool>> b(n,std::vector<bool>(m,false));
    for(int i=k-1;i!=-1;i--) {
        for(int j=0,k=i;j!=m;j++) {
            b[k][j]=true;
            const int d(std::min(n-k-1,_a[j]));
            _a[j]-=d;
            for(int o=0;o!=d;o++) {
                b[++k][j]=true;
            }
        }
    }
    std::fill(_a,_a+m,0);
    printf("%d\n",k);
    for(int i=n-1;i!=-1;i--) {
        for(int j=0;j!=m;j++) {
            s[j]=b[i][j]&&_a[j]++<a[j]?'#':'.';
        }
        s[m]='\0';
        puts(s);
    }
}
int main() {
    int t;
    scanf("%d",&t);
    while(t--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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)