QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#374958 | #7943. LIS on Grid | Graphcity | WA | 8ms | 5808kb | C++20 | 1.2kb | 2024-04-02 20:01:11 | 2024-04-02 20:01:12 |
Judging History
answer
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rof(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int Maxn=2e5;
int n,m,a[Maxn+5],b[Maxn+5];
vector<int> s[Maxn+5],vis[Maxn+5];
inline int Check(int k)
{
int res=k*(m+n-k),sum=0;
For(i,1,m) a[i]=b[i],sum+=b[i];
if(res<sum) return 0;
For(i,1,n) For(j,1,m) vis[i][j]=s[i][j]=0;
For(_,n-k+1,n)
{
int x=_,y=1; vis[x][y]=1;
if(a[1]) s[x][y]=1,a[1]--;
while(1)
{
if(a[y]>n-_ && x>1 && !vis[x-1][y])
a[y]--,vis[x-1][y]=s[x-1][y]=1,x--;
else
{
if(y==m || vis[x][y+1]) break;
++y,vis[x][y]=1; if(a[y]) a[y]--,s[x][y]=1;
}
}
} return 1;
}
inline void Solve()
{
cin>>n>>m; For(i,1,m) cin>>b[i];
For(i,1,n) s[i].resize(m+5,0),vis[i].resize(m+5,0);
int l=1,r=n; while(l<r)
{
int mid=(l+r)/2;
if(Check(mid)) r=mid;
else l=mid+1;
} Check(l); printf("%d\n",l);
For(i,1,n) {For(j,1,m) putchar(s[i][j]?'#':'.'); putchar('\n');}
}
int main()
{
// freopen("1.in","r",stdin);
int T; cin>>T;
while(T--) Solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 5808kb
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: 8ms
memory: 5804kb
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 Wrong number of colored cells (test case 12)