QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#66512#5015. 树xlwang0 17ms7716kbC++142.9kb2022-12-08 20:35:242022-12-08 20:35:26

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-08 20:35:26]
  • 评测
  • 测评结果:0
  • 用时:17ms
  • 内存:7716kb
  • [2022-12-08 20:35:24]
  • 提交

answer

#include<bits/stdc++.h>
#define fr(i,j,k) for(register int i=j;i<=k;++i)
#define rf(i,j,k) for(register int i=j;i>=k;--i)
#define randfind(l,r) (rand()%((r)-(l)+1)+(l))
using namespace std;
int ask(int u,std::vector<int>v);
void answer(int u,int v);
const int Maxn=1e3+10;
int dep[Maxn];
vector<int> vc[Maxn];
inline int ask1(int x,int y){
    vector<int> now;now.clear();
    now.push_back(y);
    int tot;tot=ask(x,now);
    if(tot==1) return true;
    return false;
}
struct node{
    int dis;
    int pos;
}e1[Maxn],e2[Maxn];
inline bool cmp(node a,node b){return a.dis<b.dis;}
inline void solve(vector<int> a,vector<int> b){
    // printf("solve:\n");
    // for(register int i=0;i<a.size();++i) cout<<a[i]<<' ';
    // puts("");
    // for(register int i=0;i<b.size();++i) cout<<b[i]<<' ';
    // puts("");
    if(a.size()==1){
        for(register int i=0;i<b.size();++i) answer(a[0],b[i]);
        return;
    }
    if(b.size()==1){
        for(register int i=0;i<a.size();++i) if(ask1(a[i],b[0])){
            answer(a[i],b[0]);
            return;
        }
    }
    vector<int> now;now.clear();
    if(a.size()>10){
        while(now.size()<a.size()/5 || now.size()>a.size()*3/5 || now.size()==a.size() || now.size()==0){
            for(register int i=0;i<a.size();++i){
                int x;
                x=randfind(1,12);
                if(x%4==0) now.push_back(a[i]);
            }
        }
    }
    else {
        while(now.size()==a.size() || now.size()==0){
            for(register int i=0;i<a.size();++i){
                int x;
                x=randfind(1,12);
                if(x%4==0) now.push_back(a[i]);
            }
        }
    }
    int cnt1,cnt2;
    cnt1=cnt2=0;
    // printf("important:\n");
    // for(register int i=0;i<now.size();++i) cout<<now[i]<<' ';
    // puts("");
    for(register int i=0;i<a.size();++i){
        e1[++cnt1].pos=a[i];
        e1[cnt1].dis=ask(a[i],now);
    }
    for(register int i=0;i<b.size();++i){
        e2[++cnt2].pos=b[i];
        e2[cnt2].dis=ask(b[i],now);
    }
    sort(e1+1,e1+cnt1+1,cmp);
    sort(e2+1,e2+cnt2+1,cmp);
    int l,r;
    l=r=1;
    int ql,qr;
    ql=1;
    while(l<=cnt1 && ql<=cnt2){
        r=l;
        while(r<cnt1 && e1[r+1].dis==e1[l].dis) ++r;
        while(ql<cnt2 && e2[ql].dis<e1[l].dis+now.size()) ++ql;
        qr=ql;
        while(qr<cnt2 && e2[qr+1].dis==e2[ql].dis) ++qr;
        if(ql<=qr){
            vector<int> p1,p2;
            p1.clear();p2.clear();
            fr(i,l,r) p1.push_back(e1[i].pos);
            fr(i,ql,qr) p2.push_back(e2[i].pos);
            solve(p1,p2);
        }
        l=r+1;ql=qr+1;
    }
}
void solver(int n,int A,int B){
    srand(time(0));
    vector<int> now;now.clear();
    now.push_back(1);
    dep[1]=1;
    fr(i,2,n) dep[i]=ask(i,now)+1;
    fr(i,1,n) vc[dep[i]].push_back(i);
    fr(i,1,n) if(vc[i].size() && vc[i+1].size()) solve(vc[i],vc[i+1]);
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 17ms
memory: 7568kb

input:

1000 500000 500000
1 2
2 3
2 4
2 5
2 6
3 7
2 8
5 9
5 10
9 11
2 12
9 13
4 14
5 15
12 16
5 17
4 18
4 19
13 20
9 21
19 22
7 23
6 24
14 25
2 26
10 27
14 28
21 29
17 30
8 31
15 32
9 33
22 34
24 35
20 36
6 37
12 38
19 39
31 40
35 41
25 42
11 43
8 44
9 45
12 46
26 47
10 48
6 49
27 50
39 51
33 52
6 53
43 54...

output:

Invalid ask

result:

wrong answer Wrong Answer

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 0
Wrong Answer
time: 3ms
memory: 4004kb

input:

100 3000 40000
66 95
66 60
66 93
66 69
66 82
66 24
66 64
66 84
66 42
66 22
66 67
66 54
66 90
66 26
66 41
66 18
66 43
66 68
66 36
66 88
66 33
66 29
66 79
66 6
66 48
66 47
66 8
66 38
66 61
69 97
64 30
38 86
88 14
18 10
54 81
88 25
29 2
18 21
95 46
42 80
93 91
61 62
68 35
47 23
69 17
93 28
18 31
61 70
...

output:

Invalid ask

result:

wrong answer Wrong Answer

Subtask #3:

score: 0
Wrong Answer

Test #111:

score: 0
Wrong Answer
time: 11ms
memory: 7716kb

input:

1000 50000 3000000
126 207
937 126
615 937
837 615
500 837
588 500
505 588
353 505
60 353
904 60
656 904
685 656
460 685
614 460
551 614
537 551
858 537
596 858
9 596
738 9
918 738
322 918
940 322
859 940
113 859
110 113
312 110
995 312
443 995
246 443
257 246
238 257
999 238
885 999
976 885
330 976...

output:

Invalid ask

result:

wrong answer Wrong Answer

Subtask #4:

score: 0
Wrong Answer

Test #211:

score: 0
Wrong Answer
time: 9ms
memory: 7536kb

input:

990 8500 300000
1 2
1 3
1 4
1 5
2 6
2 7
2 8
3 9
3 10
3 11
4 12
4 13
4 14
5 15
5 16
5 17
6 18
6 19
6 20
7 21
7 22
7 23
8 24
8 25
8 26
9 27
9 28
9 29
10 30
10 31
10 32
11 33
11 34
11 35
12 36
12 37
12 38
13 39
13 40
13 41
14 42
14 43
14 44
15 45
15 46
15 47
16 48
16 49
16 50
17 51
17 52
17 53
18 54
18...

output:

Invalid ask

result:

wrong answer Wrong Answer