QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#288212 | #7943. LIS on Grid | zlt | WA | 4ms | 3824kb | C++14 | 1.3kb | 2023-12-22 11:07:26 | 2023-12-22 11:07:28 |
Judging History
answer
#include <bits/stdc++.h>
#define pb emplace_back
#define fst first
#define scd second
#define mkp make_pair
#define mems(a, x) memset((a), (x), sizeof(a))
using namespace std;
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef long double ldb;
typedef pair<ll, ll> pii;
const int maxn = 200100;
int n, m, a[maxn], b[maxn];
inline bool check(int x) {
int s = 0;
for (int i = 1; i <= m; ++i) {
s += max(0, a[i] - x);
}
return s <= x * (n - x);
}
void solve() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= m; ++i) {
scanf("%d", &a[i]);
b[i] = a[i];
}
int l = 0, r = min(n, m), k = -1;
while (l <= r) {
int mid = (l + r) >> 1;
if (check(mid)) {
k = mid;
r = mid - 1;
} else {
l = mid + 1;
}
}
printf("%d\n", k);
vector< vector<int> > ans(n + 2, vector<int>(m + 2, 0));
for (int i = n - k + 1; i <= n; ++i) {
int x = i;
for (int j = 1; j <= m; ++j) {
ans[x][j] = 1;
while (x > 1 && a[j] > k) {
--a[j];
ans[--x][j] = 1;
}
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
if (b[j] && ans[i][j]) {
putchar('#');
--b[j];
} else {
putchar('.');
}
}
putchar('\n');
}
}
int main() {
int T = 1;
scanf("%d", &T);
while (T--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3824kb
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: 3800kb
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)