QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#494306 | #9141. Array Spread | ucup-team3510# | WA | 0ms | 3816kb | C++20 | 1.6kb | 2024-07-27 15:08:21 | 2024-07-27 15:08:25 |
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 15:08:21]
- 提交
answer
#include <bits/stdc++.h>
#define s1 first
#define s2 second
using namespace std;
int t,n,m;
int l[2011],r[2011];
pair<int,int*> a[4011];
int mn[4011],mx[4011];
int A,B;
vector<int> v[4011];
int mxr[4011];
const int p=998244353;
inline int qpow(int bs,int ex){int ans=1;while(ex){if(ex&1)ans=1ll*ans*bs%p;ex>>=1;bs=1ll*bs*bs%p;}return ans;}
int main()
{
scanf("%d",&t);while(t--)
{
scanf("%d%d",&n,&m);
int an=0;
for(int i=1;i<=m;++i)
{
scanf("%d%d",l+i,r+i);
++an;a[an].s1=l[i],a[an].s2=l+i;
++an;a[an].s1=r[i],a[an].s2=r+i;
}
sort(a+1,a+1+an);a[0].s1=-1e9;
int k=0;
for(int i=1;i<=an;++i)k+=a[i].s1!=a[i-1].s1,*a[i].s2=k;
for(int i=1;i<=k+1;++i)v[i].clear(),mxr[i]=0;
for(int i=1;i<=m;++i)v[r[i]].push_back(l[i]),mxr[l[i]]=max(mxr[l[i]],r[i]);
int A=1,B=1;
// for(int i=1;i<=m;++i)printf("[%d,%d] ",l[i],r[i]);putchar(10);
for(int i=1;i<=k;++i)
{
for(int j=i;j<=k+1;++j)mx[j]=-1e9,mn[j]=1e9;
mx[i-1]=0;mn[i-1]=0;
for(int j=i;j<=k;++j)
{
mx[j]=max(mx[j],mx[j-1]);
for(int l:v[j])if(l>=i)mx[j]=max(mx[j],mx[l-1]+1);
}
int curr=0;
int curi=i-1;
for(int j=1;j<=curi+1;++j)curr=max(curr,mxr[j]);
int stp=0;
while(curr>curi)
{
++stp;
mn[curr]=min(mn[curr],stp);
int tt=curr;
for(int j=curi+2;j<=tt+1;++j)curr=max(curr,mxr[j]);
curi=tt;
}
for(int j=n;j>=i;--j)mn[j]=min(mn[j],mn[j+1]);
for(int j=i;j<=k;++j)if(mn[j]<1e9)
{
if(1ll*mx[j]*B>1ll*A*mn[j])A=mx[j],B=mn[j];
}
}
printf("%lld\n",1ll*A*qpow(B,p-2)%p);
}
fclose(stdin);fclose(stdout);return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3816kb
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 0 499122178
result:
wrong answer 2nd numbers differ - expected: '2', found: '0'