QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#288261 | #7943. LIS on Grid | Edwin_VanCleef | RE | 0ms | 3568kb | C++14 | 1.8kb | 2023-12-22 12:14:57 | 2023-12-22 12:14:57 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
namespace my_IO{
#define ll long long
#define ull unsigned long long
#define ld long double
#define spc putchar(' ')
#define et putchar('\n')
#define eb emplace_back
#define gc getchar
#define pc putchar
#define pb push_back
#define lb lower_bound
template<class T>
void read(T &num){
T x=0,f=1;
char c=gc();
while(!isdigit(c)){
if(c=='-') f=-1;
c=gc();
}
while(isdigit(c)){
x=(x<<3)+(x<<1)+c-48;
c=gc();
}
num=f*x;
}
template<class T>
void write(T x){
static char buf[40];
static int len=-1;
if(x<0) pc('-'),x=-x;
do{
buf[++len]=x%10+48;
x/=10;
}while(x);
while(len>=0) pc(buf[len--]);
}
}
using namespace my_IO;
const int maxn=2e5+10;
int n,m,a[maxn],k,b[maxn];
void solve(){
read(n),read(m);
for(int i=1;i<=m;i++) read(a[i]),b[i]=a[i];
for(int i=1;i<=n;i++){
int sum=0;
for(int j=1;j<=m;j++) sum+=max(0,a[j]-i);
if(i*(n-i)>=sum){
k=i;
break;
}
}
write(k),et;
for(int i=1;i<=m;i++) b[i]=max(0,b[i]-k);
vector<vector<int>> mp(n+10,vector<int>(m+10,0)),ans(n+10,vector<int>(m+10,0));
for(int i=1;i<=k;i++){
int now=n-k+i;
for(int j=1;j<m;j++){
mp[now][j]=1;
while(b[j]&&now!=1){
now--;
mp[now][j]=1;
b[j]--;
}
}
mp[now][m]=1;
while(now!=i){
now--;
mp[now][m]=1;
}
}
for(int i=1;i<=m;i++){
for(int j=1;j<=n;j++){
if(!a[i]) break;
if(mp[j][i]) ans[j][i]=1,a[i]--;
}
}
for(int i=1;i<=n;i++){
for(int j=1;j<=m;j++){
if(ans[i][j]) pc('#');
else pc('.');
}
et;
}
}
int main(){
int t;
read(t);
while(t--) solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3568kb
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
Runtime Error
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...