QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#514360#7943. LIS on GridSwarthmore#WA 0ms3552kbC++202.2kb2024-08-11 00:50:402024-08-11 00:50:40

Judging History

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

  • [2024-08-11 00:50:40]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3552kb
  • [2024-08-11 00:50:40]
  • 提交

answer

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a) - 1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define sz(x) (int)(x).size()
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

const char nl = '\n';

int N, M;
vi A;

vector<string> ans;

bool ok(int K) {
    //int val[N+1]; F0R(i, N+1) val[i] = 0;
    F0R(i, N) F0R(j, M) ans[i][j] = '.';
    vi cur = A;
    int cb = M;
    F0R(v, N+M+2*K+3) {
        for (int i = max(0, v-(M-1)); i < N && i <= v; i++) {
            ans[i][v-i] = '#';
            cur[v-i]--;
            if (cur[v-i] == 0) {
                cb--;
            }
        }
        for (int i = max(0, v-2*K-(M-1)); i < N && i <= v-2*K; i++) {
            ans[i][v-2*K-i] = '.';
            cur[v-i-2*K]++;
            if (cur[v-i-2*K] == 1) {
                cb++;
            }
        }
        if (cb == 0) return true;
    }
    return false;
}


void solve() {
    cin >> N >> M;
    A = vi(M);
    F0R(i, M) cin >> A[i];
    string S;
    F0R(i, M) {
        S += '.';
    }
    ans.clear();
    F0R(i, N) ans.pb(S);

    int lo = 1, hi = min(N, M);
    while (lo < hi) {
        int mid = (lo+hi)/2;
        if (ok(mid)) {
            hi = mid;
        } else lo = mid+1;
    }
    cout << lo << nl;
    ok(lo);
    F0R(j, M) {
        F0R(i, N) {
            if (A[j] == 0) {
                ans[i][j] = '.';
            }
            if (ans[i][j] == '#') {
                A[j]--;
            }
        }
    }

    F0R(i, N) {
        F0R(j, M) {
            cout << ans[i][j];
        }
        cout << nl;
    }
}

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    int T; cin >> T;
	while (T--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3552kb

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:

2
####
....
3
###
###
###
2
####
###.
##..
#...
2
..###
.####
####.
###..

result:

wrong answer Wrong score (test case 1)