QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#182885#5375. SearchLynkcat#10 374ms50208kbC++202.2kb2023-09-18 17:58:062024-07-04 02:02:19

Judging History

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

  • [2024-07-04 02:02:19]
  • 评测
  • 测评结果:10
  • 用时:374ms
  • 内存:50208kb
  • [2023-09-18 17:58:06]
  • 提交

answer

#include <bits/stdc++.h>
#include "search.h"
#define poly vector<int>
#define IOS ios::sync_with_stdio(false)
#define ll long long
#define mp make_pair
#define mt make_tuple
#define pa pair < int,int >
#define fi first
#define se second
#define inf 1e18
#define mod 998244353
#define sz(x) ((int)((x).size()))
// #define int ll

using namespace std;

namespace query 
{
    const int N=2005;
    int n;
    int pos[N];
    mt19937_64 rnd(2006100920070217);
    void geta(int k,int x,int y,int rb)
    {
        if (!x) return;
        // cout<<"!!geta"<<" "<<k<<" "<<x<<" "<<y<<" "<<rb<<endl;
        int l=pos[k]+1,r=rb;
        while (l<=r)
        {
            int mid=l+(r-l)/2;
            if (ask1(mid,k,x,y)=="<")
            {
                pos[k]=mid;
                l=mid+1;
            } else r=mid-1;
        }
    }
    void getr(int k)
    {
        int l=pos[k]+1,r=n;
        while (l<=r)
        {
            int mid=l+(r-l)/2;
            if (ask2(mid,k)=="<")
            {
                pos[k]=mid;
                l=mid+1;
            } else r=mid-1;
        }
    }
    void solve(poly g)
    {
        if (g.empty()) return;
        int md=rnd()%g.size();
        // md=0;
        int mid=g[md];
        // for (auto u:g) cout<<u<<",";
        // cout<<endl;
        getr(mid);
        // cout<<mid<<" "<<pos[mid]<<endl;
        int lst=n;
        for (auto u:g)
            if (u!=mid)
            {
                geta(u,pos[mid],mid,lst);
                lst=pos[u];
            }
            // for (auto u:g) cout<<u<<":"<<pos[u]<<endl;
            // cout<<"_--------------"<<endl;
        int cx=pos[mid],cy=mid;
        cx++;
        poly lf;
        for (auto u:g)
            if (u!=mid)
            {
                if (pos[u]==n) continue;
                // cout<<"!!!"<<u<<" "<<pos[u]<<endl;
                if (cx>n||ask1(cx,cy,pos[u]+1,u)==">") lf.push_back(u);
            }
        solve(lf);
    }

    int main(int nn) 
    {
        n=nn;
        poly g;
        for (int i=1;i<=n;i++)
            g.push_back(i);
        solve(g);
        int ans=0;
        for (int i=1;i<=n;i++) ans+=pos[i];
        return ans;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 3840kb

input:

6 3
384 45
837639677

output:

1 12 3

result:

points 1.0 correct, ask1 called 12 time(s), ask2 called 3 time(s)

Test #2:

score: 10
Accepted
time: 0ms
memory: 3932kb

input:

8 59
512 45
439876779

output:

1 35 13

result:

points 1.0 correct, ask1 called 35 time(s), ask2 called 13 time(s)

Test #3:

score: 10
Accepted
time: 1ms
memory: 3928kb

input:

9 27
576 45
777817090

output:

1 28 8

result:

points 1.0 correct, ask1 called 28 time(s), ask2 called 8 time(s)

Test #4:

score: 10
Accepted
time: 0ms
memory: 3820kb

input:

7 14
448 45
42081112

output:

1 10 9

result:

points 1.0 correct, ask1 called 10 time(s), ask2 called 9 time(s)

Test #5:

score: 10
Accepted
time: 1ms
memory: 3844kb

input:

6 14
384 45
380054191

output:

1 10 3

result:

points 1.0 correct, ask1 called 10 time(s), ask2 called 3 time(s)

Test #6:

score: 10
Accepted
time: 1ms
memory: 4144kb

input:

9 13
576 45
718060038

output:

1 31 6

result:

points 1.0 correct, ask1 called 31 time(s), ask2 called 6 time(s)

Test #7:

score: 10
Accepted
time: 0ms
memory: 3892kb

input:

9 16
576 45
1056065885

output:

1 35 10

result:

points 1.0 correct, ask1 called 35 time(s), ask2 called 10 time(s)

Test #8:

score: 10
Accepted
time: 0ms
memory: 3864kb

input:

7 41
448 45
320297139

output:

1 22 8

result:

points 1.0 correct, ask1 called 22 time(s), ask2 called 8 time(s)

Test #9:

score: 10
Accepted
time: 0ms
memory: 3860kb

input:

7 33
448 45
658302986

output:

1 18 11

result:

points 1.0 correct, ask1 called 18 time(s), ask2 called 11 time(s)

Test #10:

score: 10
Accepted
time: 1ms
memory: 5856kb

input:

7 30
448 45
996276065

output:

1 24 10

result:

points 1.0 correct, ask1 called 24 time(s), ask2 called 10 time(s)

Test #11:

score: 10
Accepted
time: 0ms
memory: 3932kb

input:

7 37
448 45
598480398

output:

1 21 8

result:

points 1.0 correct, ask1 called 21 time(s), ask2 called 8 time(s)

Test #12:

score: 10
Accepted
time: 0ms
memory: 4152kb

input:

10 27
640 45
936486245

output:

1 45 15

result:

points 1.0 correct, ask1 called 45 time(s), ask2 called 15 time(s)

Test #13:

score: 10
Accepted
time: 0ms
memory: 3856kb

input:

8 22
512 45
200750268

output:

1 24 12

result:

points 1.0 correct, ask1 called 24 time(s), ask2 called 12 time(s)

Test #14:

score: 10
Accepted
time: 0ms
memory: 3788kb

input:

10 41
640 45
538723346

output:

1 30 10

result:

points 1.0 correct, ask1 called 30 time(s), ask2 called 10 time(s)

Test #15:

score: 10
Accepted
time: 0ms
memory: 3848kb

input:

6 35
384 45
876729193

output:

1 13 7

result:

points 1.0 correct, ask1 called 13 time(s), ask2 called 7 time(s)

Test #16:

score: 10
Accepted
time: 0ms
memory: 5844kb

input:

10 98
640 45
140960448

output:

1 51 13

result:

points 1.0 correct, ask1 called 51 time(s), ask2 called 13 time(s)

Test #17:

score: 10
Accepted
time: 0ms
memory: 4164kb

input:

8 36
512 45
478966295

output:

1 34 11

result:

points 1.0 correct, ask1 called 34 time(s), ask2 called 11 time(s)

Test #18:

score: 10
Accepted
time: 0ms
memory: 3852kb

input:

8 9
512 45
81170628

output:

1 34 15

result:

points 1.0 correct, ask1 called 34 time(s), ask2 called 15 time(s)

Test #19:

score: 10
Accepted
time: 0ms
memory: 4144kb

input:

6 20
384 45
419176475

output:

1 20 8

result:

points 1.0 correct, ask1 called 20 time(s), ask2 called 8 time(s)

Test #20:

score: 10
Accepted
time: 0ms
memory: 4132kb

input:

6 23
384 45
757149553

output:

1 12 5

result:

points 1.0 correct, ask1 called 12 time(s), ask2 called 5 time(s)

Subtask #2:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 374ms
memory: 50208kb

input:

1998 997469
511488 45
691176210

output:

1 11471 108

result:

points 0.0 correct, ask1 called 11471 time(s), ask2 called 108 time(s)