QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#493852#9141. Array Spreaducup-team3555#WA 5ms6164kbC++141.8kb2024-07-27 12:55:492024-07-27 12:55:50

Judging History

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

  • [2024-09-18 18:58:44]
  • hack成功,自动添加数据
  • (/hack/840)
  • [2024-09-18 18:53:02]
  • hack成功,自动添加数据
  • (/hack/839)
  • [2024-07-29 03:53:23]
  • hack成功,自动添加数据
  • (/hack/753)
  • [2024-07-29 03:51:16]
  • hack成功,自动添加数据
  • (/hack/752)
  • [2024-07-29 03:50:24]
  • hack成功,自动添加数据
  • (/hack/751)
  • [2024-07-29 03:48:52]
  • hack成功,自动添加数据
  • (/hack/750)
  • [2024-07-27 12:55:50]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:6164kb
  • [2024-07-27 12:55:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll N=4003,H=998244353;
int n,m,kl[N],kr[N],f1[N][N],f2[N][N];
vector<int>vl[N],vr[N];
void Max(int &x,int y){if(x<y)x=y;}
void Min(int &x,int y){if(x>y)x=y;}
ll Ksm(ll x,ll y)
{
	ll s=1;
	for(;y;y>>=1,x=x*x%H)if(y&1)s=s*x%H;
	return s;
}
struct BIT
{
	int tr[N];
	void Add1(int x,int y){for(;x;x-=x&-x)Max(tr[x],y);}
	int Ask1(int x){int s=0;for(;x<=n;x+=x&-x)Max(s,tr[x]);return s;}
	void Add2(int x,int y){for(;x;x-=x&-x)Min(tr[x],y);}
	int Ask2(int x){int s=1e9;for(;x<=n;x+=x&-x)Min(s,tr[x]);return s;}
	void Clear1(){memset(tr,0,sizeof(tr));}
	void Clear2(){memset(tr,0x3f,sizeof(tr));}
}T1,T2;
void Sol1(int st)
{
	T1.Clear1();
	for(int i=1;i<=n;i++)f1[i][st]=0;
	for(int i=st-1;i>0;i--)
	{
		for(int x:vl[i])Max(f1[i][st],T1.Ask1(x)+1);
		T1.Add1(i,f1[i][st]);
	}
}
void Sol2(int st)
{
	T2.Clear2();T2.Add2(st,0);
	for(int i=1;i<=n;i++)f2[st][i]=1e9;
	for(int i=st+1;i<=n;i++)
	{
		for(int x:vr[i])Min(f2[st][i],T2.Ask2(x)+1);
		T2.Add2(i,f2[st][i]);
	}
}
void Solve()
{
	cin>>m>>m;n=0;map<int,int>mp;
	for(int i=1;i<=m;i++)cin>>kl[i]>>kr[i],kl[i]--,mp[kl[i]]=mp[kr[i]]=0;
	for(auto &p:mp)p.second=++n,vl[n].clear(),vr[n].clear();
	for(int i=1;i<=m;i++)kl[i]=mp[kl[i]],kr[i]=mp[kr[i]],vl[kl[i]].push_back(kr[i]),vr[kr[i]].push_back(kl[i]);
	for(int i=1;i<=n;i++)Sol1(i),Sol2(i);
	for(int i=1;i<=n;i++)
	{
		int mk=0;
		for(int j=1;j<=m;j++)mk+=kl[j]<=i&&i<=kr[j];
		if(mk==m){cout<<1<<endl;return;}
	}
	ll smx=1e9,smn=1;
	for(int i=1;i<=n;i++)for(int j=i+1;j<=n;j++)if(f1[i][j]>0&&f2[i][j]<1e9&&f1[i][j]>f2[i][j])
	{
		ll mx=f1[i][j],mn=f2[i][j];
		if(smx*mn>smn*mx)smx=mx,smn=mn;
	}
	cout<<smx*Ksm(smn,H-2)%H<<endl;
}
int main()
{
	int TT;cin>>TT;
	while(TT--)Solve();
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5832kb

input:

3
3 3
1 3
2 3
1 2
12 6
2 3
5 7
1 9
4 8
1 2
7 11
4 5
3 4
2 3
1 2
4 4
1 1

output:

1
2
499122178

result:

ok 3 number(s): "1 2 499122178"

Test #2:

score: 0
Accepted
time: 3ms
memory: 5864kb

input:

2000
1000000000 1
259923446 367011266
1000000000 1
882434225 971573327
1000000000 1
41585677 470369580
1000000000 1
371902212 947250194
1000000000 1
787209148 924205796
1000000000 1
259074809 960876164
1000000000 1
148079314 188254573
1000000000 1
940091047 948318624
1000000000 1
40636497 743979446
...

output:

1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
...

result:

ok 2000 numbers

Test #3:

score: -100
Wrong Answer
time: 5ms
memory: 6164kb

input:

1000
1000000000 5
575330909 661595447
708422488 913945134
658050911 930246647
786571892 904549453
851755566 969150871
1000000000 2
198072104 844159589
8876188 644559580
1000000000 2
740802634 976972118
783909534 898449184
1000000000 2
871819537 941611957
465883854 640988372
1000000000 1
99458969 462...

output:

1755647
1
1
1755647
1
1
1755647
1
1
1
1
1
1
1
1755647
1
1
1755647
1755647
2
1
1
1755647
1
1
1755647
1755647
1
1755647
1
1
2
1755647
1
1755647
1
1
1755647
1
1
1
1
1
1755647
1755647
1
1
1755647
1
1755647
1
1
1
1755647
1755647
1755647
1
1755647
1
1755647
1755647
1755647
1
1
1
1
1
1
1
2
1755647
1
1
1
1
...

result:

wrong answer 1st numbers differ - expected: '1', found: '1755647'