QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#302049#370. CityXttttr0 62ms4644kbC++141.5kb2024-01-10 15:47:022024-01-10 15:47:02

Judging History

This is the latest submission verdict.

  • [2024-01-10 15:47:02]
  • Judged
  • Verdict: 0
  • Time: 62ms
  • Memory: 4644kb
  • [2024-01-10 15:47:02]
  • Submitted

Encoder

#include<bits/stdc++.h>
#include "Encoder.h"
#define ll long long
using namespace std;

namespace encode{
    const int M=250052;
    const double q=0.27;
    int n,cnt,ver[M<<1],nxt[M<<1],h[M],cntdfn,dfn[M],siz[M];
    int f[M];
    inline void init(){
        f[0]=1;
        for(int i=1;i<512;i++)f[i]=max(1.0,q*f[i-1])+f[i-1];
    }
    inline void add_edge(int x,int y){cnt++;ver[cnt]=y;nxt[cnt]=h[x];h[x]=cnt;}
    inline void dfs(int x){
        dfn[x]=++cntdfn;
        siz[x]=1;
        for(int i=h[x];i;i=nxt[i]){
            int y=ver[i];
            if(!dfn[y]){
                dfs(y);
                siz[x]+=siz[y];
            }
        }
        int p=lower_bound(f,f+512,siz[x])-f;
        siz[x]=p;
        cntdfn=dfn[x]+siz[x]-1;
        Code(x,512ll*dfn[x]+p);
    }
}
void Encode(int N,int A[],int B[]){
    using namespace encode;
    n=N;
    init();
    for(int i=0;i<n-1;i++){
        add_edge(A[i],B[i]),add_edge(B[i]+1,A[i]);
    }
    dfs(0);
}

Device

#include<bits/stdc++.h>
#include "Device.h"
using namespace std;
namespace device{
    const int M=250052;
    const double q=0.27;
    int f[M];
    inline void init(){
        f[0]=1;
        for(int i=1;i<512;i++)f[i]=max(1.0,q*f[i-1])+f[i-1];
    }
}
void InitDevice(){
    using namespace device;
    init();
}
int Answer(long long S,long long T){
    using namespace device;
    int dfns=S>>9,sizs=f[S&512ll],dfnt=T>>9,sizt=f[T&512ll];
    if(dfnt<dfns&&dfns<dfnt+sizt)return 0;
    if(dfns<dfnt&&dfnt<dfns+sizs)return 1;
    return 2;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3700kb

input:

10 45
0 5
0 2
4 3
6 4
0 6
2 8
6 9
2 1
5 7
5 0
0 2
8 0
0 7
0 6
1 0
4 0
0 3
0 9
5 2
5 8
7 5
5 6
1 5
4 5
5 3
9 5
8 2
7 2
2 6
2 1
2 4
3 2
2 9
7 8
6 8
8 1
8 4
3 8
9 8
6 7
1 7
4 7
3 7
9 7
1 6
6 4
6 3
6 9
4 1
1 3
9 1
3 4
9 4
9 3

output:

1024 3072 2560 264704 264192 265728 1536 266240 265216 2048 

input:

Interaction has been finished!

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
266240

result:

wrong answer Wrong Answer [6] (Query #1 returned 2 but expected 0)

Subtask #2:

score: 0
Wrong Answer

Test #13:

score: 0
Wrong Answer
time: 62ms
memory: 4644kb

input:

700 244650
407 643
680 336
573 208
466 455
159 648
575 549
50 567
251 211
211 481
530 513
136 334
112 492
175 396
643 483
265 132
20 160
174 550
251 90
99 236
579 374
670 613
495 379
251 170
652 61
495 467
27 317
202 484
420 592
542 354
565 650
35 88
216 681
277 219
299 171
220 647
418 433
434 660
2...

output:

1024 835072 834048 833024 832000 830976 6943232 1143808 1142784 1141760 4572672 1128960 7207424 1943552 1942528 845312 552448 7732736 7733248 7732224 1647616 295424 2436096 2435072 2171904 273408 10240 9216 5097984 1352704 561152 822272 14336 7736320 1136128 4312064 1664512 1385984 1122816 6417920 6...

input:

Interaction has been finished!

output:

2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
2
...

result:

wrong answer Wrong Answer [6] (Query #1 returned 2 but expected 0)