QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#514360 | #7943. LIS on Grid | Swarthmore# | WA | 0ms | 3552kb | C++20 | 2.2kb | 2024-08-11 00:50:40 | 2024-08-11 00:50:40 |
Judging History
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)