QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#291454 | #7943. LIS on Grid | Tobo | WA | 0ms | 3588kb | C++20 | 1.6kb | 2023-12-26 17:52:49 | 2023-12-26 17:52:50 |
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 <= n; 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);
}
详细
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3588kb
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:
wrong answer Token parameter [name=s] equals to "..", doesn't correspond to pattern "[.#]{4,4}" (test case 1)