QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#182877 | #5375. Search | Lynkcat# | 0 | 337ms | 50104kb | C++20 | 2.2kb | 2023-09-18 17:48:11 | 2024-07-04 02:02:15 |
Judging History
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=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: 4092kb
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: 3812kb
input:
8 59 512 45 439876779
output:
0 10 12 wrong answer!
result:
wrong answer wrong
Subtask #2:
score: 0
Wrong Answer
Test #21:
score: 0
Wrong Answer
time: 337ms
memory: 50104kb
input:
1998 997469 511488 45 691176210
output:
0 17459 61 wrong answer!
result:
wrong answer wrong