QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#495512#9141. Array Spreaducup-team3586#WA 9ms4180kbC++141.8kb2024-07-27 21:24:312024-07-27 21:24:31

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 21:24:31]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:4180kb
  • [2024-07-27 21:24:31]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int n_,n;
#define db double
#define pb push_back
int qc[4010],L[4010],R[4010],cn;
int ct[4010];
vector<int>g[4010];
db dis[4010];
bool vis[4010];
const int mod=998244353;
int qpow(int a,int b){
    int c=1;
    for(;b;b>>=1){
        if(b&1)c=1ll*a*c%mod;
        a=1ll*a*a%mod;
    }
    return c;
}
bool chk(db X){
    queue<int>q;
    for(int i=1;i<=cn;i++)dis[i]=0,ct[i]=0,q.push(i),vis[i]=1;
    while(!q.empty()){
        int u=q.front();q.pop();vis[u]=0;
        ct[u]++;if(ct[u]>cn)return 0;
        if(u<cn){
            if(dis[u+1]>dis[u]){
                dis[u+1]=dis[u];
                if(!vis[u+1])
                vis[u+1]=1,q.push(u+1);
            }
        }
        for(int v:g[u]){
            db w=(u<v)?(-1):X;
            if(dis[v]>dis[u]+w){
                dis[v]=dis[u]+w;
                if(!vis[v])vis[v]=1,q.push(v);
            }
        }
    }
    return 1;
}
const db eps=1e-7;
#define ll long long
void sol(){
    scanf("%d%d",&n_,&n);
    cn=0;
    for(int i=1;i<=n;i++)
        scanf("%d%d",&L[i],&R[i]),L[i]--,qc[++cn]=L[i],qc[++cn]=R[i];
    sort(qc+1,qc+cn+1);cn=unique(qc+1,qc+cn+1)-qc-1;
    for(int i=1;i<=cn;i++)g[i].clear();
    for(int i=1;i<=n;i++)L[i]=lower_bound(qc+1,qc+cn+1,L[i])-qc,R[i]=lower_bound(qc+1,qc+cn+1,R[i])-qc,
    g[L[i]].pb(R[i]),g[R[i]].pb(L[i]);
    db l=0,r=n*5;int cnt=30;
    while(cnt--){
        db mi=(l+r)/2;
        if(chk(mi))r=mi;
        else l=mi;
    }
    for(int i=1;i<=n*5;i++){
        db p=l*i;ll z=(ll)p;
        while(z>p+0.5)z--;
        while(z<p-0.5)z++;
        if(abs(z-p)<eps)
        {printf("%lld\n",z%mod*qpow(i,mod-2)%mod);
        return;}
    }
}
int main(){
    int T;scanf("%d",&T);while(T--)sol();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 4ms
memory: 3916kb

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: 3ms
memory: 4180kb

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: 0
Accepted
time: 4ms
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:

ok 500 numbers

Test #5:

score: -100
Wrong Answer
time: 9ms
memory: 3892kb

input:

250
1000000000 10
844342043 888135880
127033337 726074967
581308029 893912240
414276384 752837267
565680461 863374082
230362895 477723054
210479116 423381051
325072305 427826920
178306222 756423471
376470949 993759748
1000000000 2
468173597 607783582
266359996 863641680
1000000000 7
206599093 941381...

output:

2
1
2
1
3
3
1
1
1
2
1
2
2
1
3
5
2
1
1
1
2
1
2
1
3
1
2
1
3
499122178
1
1
1
1
3
1
1
1
3
3
3
1
4
1
1
1
1
1
1
1
1
5
1
4
2
1
3
1
1
1
2
2
1
2
6
2
2
1
2
1
1
1
5
2
1
2
1
1
2
2
2
1
1
5
8
3
1
1
1
8
2
6
1
1
4
2
1
1
1
1
2
2
1
2
1
1
1
1
1
1
2
1
2
1
1
4
1
1
3
1
2
3
3
2
5
1
1
1
3
2
1
1
1
3
1
1
2
1
1
1
1
3
1
1
1
1
...

result:

wrong answer 62nd numbers differ - expected: '5', found: '2'