QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#182895#5374. 数圈Lynkcat#Compile Error//C++203.3kb2023-09-18 18:38:482024-07-04 02:02:22

Judging History

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

  • [2024-07-04 02:02:22]
  • 评测
  • [2023-09-18 18:38:48]
  • 提交

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 bnd[N],pos[N];
    mt19937_64 rnd(time(0));
    void geta(int k,int x,int y,int rb)
    {
        if (!x) return;
        int l=pos[k]+1,r=min(rb,bnd[k]);
        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=bnd[k];
        while (l<=r)
        {
            int mid=l+(r-l)/2;
            if (ask2(mid,k)=="<")
            {
                pos[k]=mid;
                l=mid+1;
            } else r=mid-1;
        }
    }
    void upd(int k,int x,int y)
    {
        int l=max(1,pos[k]+1),r=bnd[k];
        while (l<=r)
        {
            int mid=l+(r-l)/2;
            if (ask1(mid,k,x,y)=="<")
            {
                l=mid+1;
            } else
            {
                bnd[k]=mid-1;
                r=mid-1;
            }
        }
    }
    void solve(poly g)
    {
        if (g.empty()) return;
        int md=0;
        // for (int i=0;i<g.size();i++)
        // {
        //     int u=g[i];
        //     if (i==md) continue;
        //     if (ask1(pos[u]+1,u,pos[g[md]]+1,g[md])=="<") md=i;
        // }
        md=rnd()%g.size();
        // if (g.size()>100) md=g.size()-rnd()%50-1;
        // md=0;
        int mid=g[md];
        // cout<<mid<<" "<<pos[mid]+1<<" "<<bnd[mid]<<endl;
        // 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;
                if (cx>n||ask1(cx,cy,pos[u]+1,u)==">") 
                {
                    // if (pos[u]+1>bnd[u]) 
                    // {
                    //     cx=pos[u]+1,cy=u;
                    // }
                }
            }
        for (auto u:g)
            if (u!=mid)
            {
                if (pos[u]==n) continue;
                if (cx>n||ask1(cx,cy,pos[u]+1,u)==">") 
                {
                    if (cx<=n) upd(u,cx,cy);
                    if (pos[u]+1>bnd[u]) continue;
                    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),bnd[i]=n;
        solve(g);
        int ans=0;
        for (int i=1;i<=n;i++) ans+=pos[i];
        return ans;
    }
}

Details

answer.code: In function ‘void query::geta(int, int, int, int)’:
answer.code:31:17: error: ‘ask1’ was not declared in this scope
   31 |             if (ask1(mid,k,x,y)=="<")
      |                 ^~~~
answer.code: In function ‘void query::getr(int)’:
answer.code:44:17: error: ‘ask2’ was not declared in this scope
   44 |             if (ask2(mid,k)=="<")
      |                 ^~~~
answer.code: In function ‘void query::upd(int, int, int)’:
answer.code:57:17: error: ‘ask1’ was not declared in this scope
   57 |             if (ask1(mid,k,x,y)=="<")
      |                 ^~~~
answer.code: In function ‘void query::solve(std::vector<int>)’:
answer.code:102:27: error: ‘ask1’ was not declared in this scope
  102 |                 if (cx>n||ask1(cx,cy,pos[u]+1,u)==">")
      |                           ^~~~
answer.code:114:27: error: ‘ask1’ was not declared in this scope
  114 |                 if (cx>n||ask1(cx,cy,pos[u]+1,u)==">")
      |                           ^~~~