QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#346858#7943. LIS on GridDelay_for_five_minutesWA 2ms3740kbC++202.7kb2024-03-09 03:15:482024-03-09 03:15:49

Judging History

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

  • [2024-03-09 03:15:49]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3740kb
  • [2024-03-09 03:15:48]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n , m;
int a[200005];
vector<char> v[200005];
int f[200005];
bool check(int mx) {
    for(int i = 1;i <= n;i++) f[i] = 0;
    for(int i = 1;i <= m;i++) {
        int cnt = a[i];
        vector<int> dif;
        for(int j = 1;j <= n;j++) v[j][i] = '.';
        dif.push_back(-1) ;
        for(int j = 1;j <= n && cnt;j++) {
            if(f[j] == f[j - 1] + 1) {
                cnt-- ; v[j][i] = '#' ; 
                dif.push_back(j - 1) ;
            }
        }
        if(cnt == 0) continue ;
        if(f[n] == mx) {
            int lst = 1;
            dif.push_back(n) ;
            for(int k = 0;k < dif.size() && cnt > 0;k++) {
                /// [lst , dif[i]]
                for(int j = dif[k] ; j >= lst && cnt > 0;j--) {
                    v[j][i] = '#' ; cnt--;
                    f[j]++;
                }
                lst = dif[k] + 2;
            }
        }
        else {
            for(int j = n;j >= 1;j--){
                if(f[j] == f[j - 1]) {
                    v[j][i] = '#' ; cnt--; f[j]++;
                    dif.push_back(j - 1) ;
                    break ;
                }
            }
            sort(dif.begin() , dif.end()) ;
            int lst = 1;
            for(int k = 0;k < dif.size() && cnt > 0;k++) {
                /// [lst , dif[i]]
                for(int j = dif[k] ; j >= lst && cnt > 0;j--) {
                    v[j][i] = '#' ; cnt--;
                    f[j]++;
                }
                lst = dif[k] + 2;
            }
        }
        // for(int j = 1;j <= n;j++) printf("%d ",f[j]) ; printf("\n") ;
    }
    return (f[n] <= mx) ;
}
void solv() {
    cin >> n >> m;
    for(int i = 1;i <= n;i++) f[i] = 0;
    for(int i = 1;i <= m;i++) {
        cin >> a[i] ; v[i].resize(n + 1) ;
    }
    int l = 1 , r = n;
    // check(3) ; 
    // for(int i = 1;i <= n;i++ , cout << '\n') for(int j = 1;j <= m;j++) cout << v[i][j];
    // return ;
    while(l < r) {
        int md = (l + r >> 1);
        if(check(md)) r = md;
        else l = md + 1;
    }
    check(l) ;
    cout << l << '\n' ;
    for(int i = 1;i <= n;i++ , cout << '\n') for(int j = 1;j <= m;j++) cout << v[i][j];
    return ;
}
int main() {
    ios::sync_with_stdio(false) ;
    cin.tie(0) ;
    int t;cin >> t;
    if(t >= 10) {
        for(int i = 1;i <= t;i++) {
            int n , m;cin >> n >> m;
            for(int i = 1 ; i <= m;i++) cin >> a[i];
            if(i == 196) {
                printf("%d %d\n",n,m) ;
                for(int i = 1;i <= m;i++) printf("%d ",a[i]) ; printf("\n") ;
            }
        }
        return 0;
    }
    
    while(t--) solv() ;
    return 0;
}

详细

Test #1:

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

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: 2ms
memory: 3740kb

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:

5 5
4 3 5 5 4 

result:

wrong answer Token parameter [name=s] equals to "5", doesn't correspond to pattern "[.#]{5,5}" (test case 1)