QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#183383#5375. SearchLynkcat10 1374ms52820kbC++203.6kb2023-09-19 14:31:092023-09-19 14:31:10

Judging History

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

  • [2023-09-19 14:31:10]
  • 评测
  • 测评结果:10
  • 用时:1374ms
  • 内存:52820kb
  • [2023-09-19 14:31:09]
  • 提交

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 f[N][N];
    int n;
    int bnd[N],pos[N];
    int mx,my;
    mt19937_64 rnd(time(0));
    void geta(int k,int x,int y)
    {
        if (!x) return;
        int l=pos[k]+1,r=bnd[k];
        while (l<=r)
        {
            int mid=l+(r-l)/2;
            mid=l;
            if (ask1(mid,k,x,y)=="<")
            {
                pos[k]=mid;
                l=mid+1;
            } else r=mid-1;
        }
    }
    void getb(int k,int x,int y)
    {
        int l=pos[k]+1,r=bnd[k];
        while (l<=r)
        {
            int mid=l+(r-l)/2;
            mid=r;
            if (ask1(mid,k,x,y)=="<")
            {
                l=mid+1;
            } else
            {
                bnd[k]=mid-1;
                r=mid-1;
            }
        }
    }
    inline int calc(int x,int y)
    {
        return max((f[x][y]-1),(f[n][n]-f[x-1][n]-f[n][y-1]+f[x-1][y-1]-1));
    }
    int solve()
    {
        bool bl=1;
        for (int i=1;i<=n;i++)
            if (pos[i]==bnd[i]) bl&=1;
            else bl=0;
        int tot=0;
        poly g;
        for (int i=1;i<=n;i++)
        {
            tot+=bnd[i]-pos[i];
            if (bnd[i]!=pos[i]) g.push_back(i);
        }
        if (bl) return 1;
        int sm=tot;
        int od=rnd()%sm;
        sm=0;
        int cx=0,cy=0;
        for (int i=1;i<=n;i++)
        {
            for (int j=1;j<=n;j++)
            {
                f[i][j]=0;
            }
        }
        for (int j=1;j<=n;j++)
            for (int i=pos[j]+1;i<=bnd[j];i++) f[i][j]=1;
        for (int i=1;i<=n;i++)
            for (int j=1;j<=n;j++)
                f[i][j]+=f[i-1][j]+f[i][j-1]-f[i-1][j-1];
        int Tot=0;
        vector<pa>all;
        for (int j=1;j<=n;j++)
            for (int i=pos[j]+1;i<=bnd[j];i++) 
                if (calc(i,j)*2<=tot&&(tot<=100||calc(i,j)*9<=tot)) all.push_back(mp(i,j));
        int ooo=rnd()%all.size();
        cx=all[ooo].fi,cy=all[ooo].se;
        // if (tot>0)
        // {
        //     for (auto u:g)
        //     {
        //         sm+=bnd[u]-pos[u];
        //         if (od<sm)
        //         {
        //             cx=bnd[u]-(sm-od)+1;
        //             cy=u;
        //             break;
        //         }
        //     }
        // }
        if (ask2(cx,cy)=="<")
        {
            pos[cy]=cx;
            for (int i=n;i>=1;i--)
                {
                    if (i<n)
                        pos[i]=max(pos[i],pos[i+1]);
                    if (i!=cy)
                        geta(i,cx,cy);
                }
        } else
        {
            bnd[cy]=cx-1;
            for (int i=1;i<=n;i++)
                {
                    if (i>1)
                        bnd[i]=min(bnd[i],bnd[i-1]);
                    if (i!=cy)
                        getb(i,cx,cy);
                }
        }
        return 0;
    }

    int main(int nn) 
    {
        n=nn;
        mx=n,my=n;
        if (ask2(n,n)=="<")
        {
            return n*n;
        }
        poly g;
        for (int i=1;i<=n;i++)
            g.push_back(i),bnd[i]=n;
        while (!solve());
        int ans=0;
        for (int i=1;i<=n;i++) ans+=pos[i];
        return ans;
    }
}

详细

Subtask #1:

score: 10
Accepted

Test #1:

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

input:

6 3
384 45
837639677

output:

1 19 8

result:

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

Test #2:

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

input:

8 59
512 45
439876779

output:

1 51 9

result:

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

Test #3:

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

input:

9 27
576 45
777817090

output:

1 36 7

result:

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

Test #4:

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

input:

7 14
448 45
42081112

output:

1 24 6

result:

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

Test #5:

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

input:

6 14
384 45
380054191

output:

1 17 7

result:

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

Test #6:

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

input:

9 13
576 45
718060038

output:

1 21 6

result:

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

Test #7:

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

input:

9 16
576 45
1056065885

output:

1 33 6

result:

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

Test #8:

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

input:

7 41
448 45
320297139

output:

1 33 8

result:

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

Test #9:

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

input:

7 33
448 45
658302986

output:

1 56 11

result:

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

Test #10:

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

input:

7 30
448 45
996276065

output:

1 40 7

result:

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

Test #11:

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

input:

7 37
448 45
598480398

output:

1 10 5

result:

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

Test #12:

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

input:

10 27
640 45
936486245

output:

1 73 11

result:

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

Test #13:

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

input:

8 22
512 45
200750268

output:

1 50 7

result:

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

Test #14:

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

input:

10 41
640 45
538723346

output:

1 62 9

result:

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

Test #15:

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

input:

6 35
384 45
876729193

output:

1 19 7

result:

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

Test #16:

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

input:

10 98
640 45
140960448

output:

1 49 9

result:

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

Test #17:

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

input:

8 36
512 45
478966295

output:

1 37 7

result:

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

Test #18:

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

input:

8 9
512 45
81170628

output:

1 57 12

result:

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

Test #19:

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

input:

6 20
384 45
419176475

output:

1 34 10

result:

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

Test #20:

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

input:

6 23
384 45
757149553

output:

1 23 7

result:

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

Subtask #2:

score: 0
Wrong Answer

Test #21:

score: 0
Wrong Answer
time: 1374ms
memory: 52820kb

input:

1998 997469
511488 45
691176210

output:

1 78075 48

result:

points 0.0 correct, ask1 called 78075 time(s), ask2 called 48 time(s)