QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#284608#7943. LIS on Griducup-team2303#WA 11ms30912kbC++142.4kb2023-12-16 14:04:342023-12-16 14:04:34

Judging History

你现在查看的是最新测评结果

  • [2023-12-16 14:04:34]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:30912kb
  • [2023-12-16 14:04:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long T,a,b,c,d[1000001],o,h[1000001],fa[1000001],q,w,e,an,cn,fac[1000001],inv[1000001],st[1000001],u[1000001],id[1000001];
char s[1000001];
struct p{long long q,w;}l[1000001];
long long pow_(long long qq,long long ww){long long ee=1;while(ww){if(ww&1) ee*=qq,ee%=mod;qq*=qq,qq%=mod,ww>>=1;}return ee%mod;}
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}return x*f;}
void add(long long qq,long long ww){l[++o].q=ww,l[o].w=h[qq],h[qq]=o;}
long long gcd(long long qq,long long ww){return !ww?qq:gcd(ww,qq%ww);}
long long find(long long qq){return qq==fa[qq]?qq:fa[qq]=find(fa[qq]);}
void merge(long long qq,long long ww){long long f1=find(qq),f2=find(ww);if(f1==f2) return;fa[f1]=f2;}
long long C(long long qq,long long ww){return fac[qq]*inv[ww]%mod*inv[qq-ww]%mod;}
queue<long long> qu,qu1;
vector<int> v[200005];
bool ch(long long qq,long long ww)
{
	if(qq>st[cn]&&cn+1>ww) return 0;
	return 1;
}
void ins(long long qq)
{
	if(!cn||qq>st[cn]) st[++cn]=qq;
	else
	{
		long long ff=lower_bound(st+1,st+cn+1,qq)-st;
		st[ff]=qq;
	}
}
bool ch1(long long qq)
{
	for(int i=1;i<=a;i++) for(int j=1;j<=b;j++) v[i][j]=0;
	cn=0;
	for(int i=1;i<=b;i++)
	{
		long long ff=d[i];
		for(int j=a;j>=1;j--)
		{
			if(ff==0) break;
			if(ch(j,qq))
			{
				ff--;
				v[j][i]=1;
			}
		}
		if(ff>0) return 0;
		for(int j=a;j>=1;j--)
		{
			if(v[j][i]) ins(j);
		}
	}
	return 1;
}
int main()
{
//	freopen("1.in","r",stdin);
	srand((unsigned)(time(0)^(*new int)));
	fac[0]=1;for(int i=1;i<=1000000;i++) fac[i]=fac[i-1]*i%mod;
	inv[1000000]=pow_(fac[1000000],mod-2);for(int i=999999;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	T=1;
	scanf("%lld",&T);
	for(int ii=1;ii<=T;ii++)
	{
		scanf("%lld%lld",&a,&b);
		for(int i=1;i<=b;i++) scanf("%lld",&d[i]);
		for(int i=0;i<=a+1;i++) v[i].resize(b+2);
		for(int i=0;i<=a+1;i++)
		{
			for(int j=0;j<v[i].size();j++) v[i][j]=0;
		}
		long long ll=1,rr=min(a,b);an=rr;
		while(ll<=rr)
		{
			long long mid=((ll+rr)>>1);
			if(ch1(mid)) rr=mid-1,an=mid;
			else ll=mid+1;
		}
		ch1(an);
		printf("%lld\n",an);
		for(int i=1;i<=a;i++)
		{
			for(int j=1;j<=b;j++)
			{
				if(v[i][j]) putchar('#');
				else putchar('.');
			}printf("\n");
		}
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 4ms
memory: 27776kb

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: 11ms
memory: 30912kb

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:

4
.#..#
##..#
##.##
##.##
#####
3
...#
#..#
#.##
####
2
....#
....#
..###
#####
####.
2
.#.#
.###
###.
3
.#..#
.#.##
.####
#####
####.
2
#..#.
#..##
#..#.
####.
3
...##
...##
##.##
#####
#####
1
..###
..#..
###..
#....
#....
2
...#.
.####
.####
###..
###..
2
.....
.....
#####
#####
3
.#.#.
##.#.
###...

result:

wrong answer Jury found better answer than participant (test case 1)