QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#494314 | #9141. Array Spread | ucup-team3510# | WA | 1ms | 3900kb | C++20 | 1.9kb | 2024-07-27 15:11:13 | 2024-07-27 15:11:14 |
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:11:13]
- 提交
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)
{
// printf("=======================new train i:%d\n",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;
}
// printf("mn:");for(int j=i;j<=k;++j)printf("%d ",mn[j]);putchar(10);
// printf("mx:");for(int j=i;j<=k;++j)printf("%d ",mx[j]);putchar(10);
for(int j=k;j>=i;--j)mn[j]=min(mn[j],mn[j+1]);
// printf("mn:");for(int j=i;j<=k;++j)printf("%d ",mn[j]);putchar(10);
// printf("mx:");for(int j=i;j<=k;++j)printf("%d ",mx[j]);putchar(10);
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;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3888kb
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: 1ms
memory: 3900kb
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: 0
Accepted
time: 1ms
memory: 3836kb
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:
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 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 2 1 1 1 1 ...
result:
ok 1000 numbers
Test #4:
score: -100
Wrong Answer
time: 1ms
memory: 3900kb
input:
500 1000000000 13 964546318 987364574 367845944 907446075 259314137 890312338 458318546 959971971 353677471 522446336 782931403 845199078 514387878 786979588 532634932 793056892 905393511 960628299 747423889 986373313 796099347 833069525 906969434 971335651 574582540 647534593 1000000000 6 987712893...
output:
3 1 3 1 1 1 1 1 1 3 2 1 1 1 3 1 2 1 1 2 1 3 1 1 1 2 1 2 2 1 1 1 1 1 1 1 3 1 1 1 1 2 1 1 1 1 2 1 1 1 1 1 2 1 1 1 1 1 1 1 2 2 1 1 3 1 2 1 1 1 1 2 3 1 1 1 1 1 1 1 3 2 1 3 2 1 1 1 1 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 1 1 1 1 1 1 2 1 2 1 1 1 3 1 1 1 1 1 1 1 2 1 1 2 1 1 1 2 1 4 1 2 1 4 1 3 1 1 1 1 1 2 1 1 4 1 ...
result:
wrong answer 455th numbers differ - expected: '1', found: '499122178'