QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#291456 | #7943. LIS on Grid | Tobo | WA | 6ms | 3816kb | C++20 | 1.6kb | 2023-12-26 17:53:26 | 2023-12-26 17:53:27 |
Judging History
answer
#include <bits/stdc++.h>
using i64 = long long;
using namespace std;
const int N = 1e3 + 5;
// const int B = 205;
// const int M = 2e4 + 5;
// const int base = 13331;
// const int mod = 998244353;
// const int mod = 1e9 + 7;
// const double pi = acos(-1);
void solve(int _num)
{
int n, m;
cin >> n >> m;
vector<int> a(m + 1);
for (int i = 1; i <= m; i++)
cin >> a[i];
auto b = a;
auto check = [&](int k) -> bool
{
int res = 0;
for (int i = 1; i <= n; i++)
res += max(0, a[i] - k);
return res <= k * (n - k);
};
int l = 0, r = min(n, m), mid;
while (l < r)
{
mid = l + r >> 1;
if (check(mid))
r = mid;
else
l = mid + 1;
}
cout << r << '\n';
vector<vector<int>> ans(n + 1, vector<int>(m + 1));
for (int i = n - r + 1; i <= n; ++i)
{
int x = i;
for (int j = 1; j <= m; ++j)
{
ans[x][j] = 1;
while (x > i - n + r && a[j] > r)
{
--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])
cout << '#', b[j]--;
else
cout << '.';
cout << '\n';
}
}
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin >> t;
cout << fixed << setprecision(18);
for (int i = 1; i <= t; i++)
solve(i);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3816kb
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: 6ms
memory: 3596kb
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 19)