QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#494260 | #9141. Array Spread | ucup-team3510# | WA | 1ms | 3900kb | C++20 | 1.4kb | 2024-07-27 14:55:46 | 2024-07-27 14:55:46 |
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 14:55:46]
- 提交
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];
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;++i)v[i].clear();
for(int i=1;i<=m;++i)v[r[i]].push_back(l[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("==================i:%d\n",i);
for(int j=i;j<=k;++j)mx[j]=-1e9,mn[j]=1e9;
mn[i-1]=0;mx[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)mn[j]=min(mn[j],mn[l-1]+1),mx[j]=max(mx[j],mx[l-1]+1);
}
// printf("mx:");for(int j=i;j<=k;++j)printf("%d ",mx[j]);putchar(10);
// printf("mn:");for(int j=i;j<=k;++j)printf("%d ",mn[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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3828kb
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: 3892kb
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: 3892kb
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'