QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#346824 | #7943. LIS on Grid | Delay_for_five_minutes | WA | 1ms | 3608kb | C++20 | 2.5kb | 2024-03-09 01:07:48 | 2024-03-09 01:07:49 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int n , m;
int a[200005];
vector<char> v[200005];
int f[200005];
bool check(int mx) {
for(int i = 1;i <= n;i++) f[i] = 0;
for(int i = 1;i <= m;i++) {
int cnt = a[i];
vector<int> dif;
for(int j = 1;j <= n;j++) v[j][i] = '.';
dif.push_back(-1) ;
for(int j = 1;j <= n && cnt;j++) {
if(f[j] == f[j - 1] + 1) {
cnt-- ; v[j][i] = '#' ;
dif.push_back(j - 1) ;
}
}
dif.push_back(n) ;
if(f[n] == mx) {
int lst = 1;
for(int k = 0;k < dif.size() && cnt;k++) {
/// [lst , dif[i]]
for(int j = dif[k] ; j >= lst && cnt;j--) {
v[j][i] = '#' ; cnt--;
f[j]++;
}
lst = dif[k] + 2;
}
}
else {
if(f[n] == mx - 1 && f[n] == f[n - 1]) {
f[n]++ ; v[n][i] = '#' ; cnt--;
int lst = 1;
for(int k = 0;k < dif.size() && cnt;k++) {
/// [lst , dif[i]]
for(int j = dif[k] ; j >= lst && cnt;j--) {
v[j][i] = '#' ; cnt--;
f[j]++;
}
lst = dif[k] + 2;
}
}
else {
for(int k = dif.size() - 1;k >= 1 && cnt;k--) {
for(int j = dif[k] ; j >= dif[k - 1] + 2 && cnt; j--) {
v[j][i] = '#' ; cnt--;
f[j]++;
}
}
}
}
// for(int j = 1;j <= n;j++) printf("%d ",f[j]) ; printf("\n") ;
}
return (f[n] <= mx) ;
}
void solv() {
cin >> n >> m;
for(int i = 1;i <= n;i++) f[i] = 0;
for(int i = 1;i <= m;i++) {
cin >> a[i] ; v[i].resize(n + 1) ;
}
int l = 1 , r = n;
// check(3) ;
// for(int i = 1;i <= n;i++ , cout << '\n') for(int j = 1;j <= m;j++) cout << v[i][j];
// return ;
while(l < r) {
int md = (l + r >> 1);
if(check(md)) r = md;
else l = md + 1;
}
check(l) ;
cout << l << '\n' ;
for(int i = 1;i <= n;i++ , cout << '\n') for(int j = 1;j <= m;j++) cout << v[i][j];
return ;
}
int main() {
ios::sync_with_stdio(false) ;
cin.tie(0) ;
int t;cin >> t;
while(t--) solv() ;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3608kb
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 ### ### ### 4 #### #... ###. ##.. 2 ..### .#### ####. ###..
result:
wrong answer Wrong score (test case 3)