QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#696170#7943. LIS on Griducup-team1134WA 5ms3656kbC++232.5kb2024-10-31 21:42:542024-10-31 21:42:58

Judging History

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

  • [2024-10-31 21:42:58]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:3656kb
  • [2024-10-31 21:42:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pair<int,int>>
#define vll vector<pair<ll,ll>>
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define vvii vector<vector<pair<int,int>>>
#define vvll vector<vector<pair<ll,ll>>>
#define vst vector<string>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define mkunique(x) sort(all(x));(x).erase(unique(all(x)),(x).end())
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=15<<26;

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int Q;cin>>Q;
    while(Q--){
        int H,W;cin>>H>>W;
        vi A(W);
        for(int i=0;i<W;i++){
            cin>>A[i];
        }
        int le=0,ri=W;
        while(ri-le>1){
            int mid=(le+ri)/2;
            vi dp(W+1,INF);
            dp[0]=-1;
            bool ok=true;
            for(int j=0;j<W;j++){
                int cn=0;
                for(int i=H-1;i>=0;i--){
                    int d=lower_bound(all(dp),i)-dp.begin();
                    if(d<=mid){
                        cn++;
                        dp[d]=i;
                    }
                    if(cn==A[j]) break;
                }
                if(cn<A[j]) ok=false;
            }
            if(ok) ri=mid;
            else le=mid;
        }
        cout<<ri<<"\n";
        {
            vector<string> ans(H,string(W,'.'));
            int mid=ri;
            vi dp(W+1,INF);
            dp[0]=-1;
            bool ok=true;
            for(int j=0;j<W;j++){
                int cn=0;
                for(int i=H-1;i>=0;i--){
                    int d=lower_bound(all(dp),i)-dp.begin();
                    if(d<=mid){
                        cn++;
                        dp[d]=i;
                        ans[i][j]='#';
                    }
                    if(cn==A[j]) break;
                }
                if(cn<A[j]) ok=false;
            }
            
            for(int i=0;i<H;i++) cout<<ans[i]<<"\n";
        }
    }
}



详细

Test #1:

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

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

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:

4
.#..#
##..#
##.##
##.##
#####
3
...#
#..#
#.##
####
2
....#
....#
..###
#####
####.
2
.#.#
.###
###.
3
.#..#
.#.##
.####
#####
####.
2
#..#.
#..##
#..#.
####.
3
...##
...##
##.##
#####
#####
1
..###
..#..
###..
#....
#....
2
...#.
.####
.####
###..
###..
2
.....
.....
#####
#####
3
.#.#.
##.#.
###...

result:

wrong answer Jury found better answer than participant (test case 1)