QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#182875#5375. SearchLynkcat#0 355ms50344kbC++202.1kb2023-09-18 17:47:142024-07-04 02:45:32

Judging History

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

  • [2024-07-04 02:45:32]
  • 评测
  • 测评结果:0
  • 用时:355ms
  • 内存:50344kb
  • [2023-09-18 17:47:14]
  • 提交

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)
    {
        // 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=mid,cy=pos[mid];
        if (cy+1<=n) cy++;
        poly lf;
        for (auto u:g)
            if (u!=mid)
            {
                if (pos[u]==n) continue;
                if (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: 0
Wrong Answer

Test #1:

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

input:

6 3
384 45
837639677

output:

1 12 5

result:

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

Test #2:

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

input:

8 59
512 45
439876779

output:

0 0 3 x2 should be in the range [1, n]

result:

wrong answer x2

Subtask #2:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 355ms
memory: 50344kb

input:

1998 997469
511488 45
691176210

output:

0 0 10 x2 should be in the range [1, n]

result:

wrong answer x2