QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#291400 | #7943. LIS on Grid | dieselhuang | WA | 0ms | 3888kb | C++14 | 845b | 2023-12-26 15:01:35 | 2023-12-26 15:01:35 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int n, m, nm, a[200010], c[200010];
bool b[200010];
int main()
{
int t, i, j, p, x, tmp;
scanf("%d", &t);
while(t--){
scanf("%d%d", &n, &m); nm = n * m;
for(i = 1; i <= m; i++) scanf("%d", &a[i]);
for(x = 1; x <= n; x++){
for(i = 1, j = 0; i <= m; i++) j += max(a[i] - x, 0);
if(j <= x * (n - x)) break;
}
printf("%d\n", x);
for(i = 1; i <= nm; i++) b[i] = false;
for(i = 1; i <= m; i++) c[i] = 0;
for(i = 1; i <= x; i++){
for(j = 1, p = n - x + i; j <= m; j++){
tmp = c[j]; c[j] = p;
if(a[j] > x - i) b[(p - 1) * m + j] = true; a[j]--;
while(p > tmp + 1 && a[j] > x - i) b[(--p - 1) * m + j] = true, a[j]--;
}
}
for(i = 1; i <= nm; i++){
putchar(b[i] ? '#' : '.');
if(i % m == 0) putchar('\n');
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3888kb
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 Wrong number of colored cells (test case 3)