QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#346821 | #7943. LIS on Grid | Delay_for_five_minutes | WA | 9ms | 5800kb | C++20 | 2.0kb | 2024-03-09 00:58:36 | 2024-03-09 00:58:37 |
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 {
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(2) ;
// 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: 100
Accepted
time: 1ms
memory: 5800kb
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: 9ms
memory: 3604kb
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 Jury found better answer than participant (test case 21)