QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#756758 | #8363. interactive | lsj2009 | 0 | 0ms | 3820kb | C++20 | 2.8kb | 2024-11-16 21:50:01 | 2024-11-16 21:50:03 |
answer
#include<bits/stdc++.h>
#include "interactive.h"
//#pragma GCC optimize(3,"Ofast","inline")
//#define int long long
#define i128 __int128
#define ll long long
#define ull unsigned long long
#define uint unsigned int
#define ld double
#define PII pair<int,int>
#define chkmax(a,b) a=max(a,b)
#define chkmin(a,b) a=min(a,b)
#define rep(k,l,r) for(int k=l;k<=r;++k)
#define per(k,r,l) for(int k=r;k>=l;--k)
#define cl(f,x) memset(f,x,sizeof(f))
#define pcnt(x) __builtin_popcount(x)
#define lg(x) (31-__builtin_clz(x))
using namespace std;
void file_IO() {
// system("fc .out .ans");
freopen(".in","r",stdin);
freopen(".out","w",stdout);
}
const int INF=0x3f3f3f3f;
const ll INFLL=0x3f3f3f3f3f3f3f3f;
int n;
int query(int x,int y,int z) {
vector<int> vec;
vec.push_back(x);
vec.push_back(y);
vec.push_back(z);
rep(i,1,n) {
if(i!=x&&i!=y&&i!=z)
vec.push_back(i);
}
return query(vec);
}
const int N=5e2+5;
bool g[N][N];
void link(int u,int v) {
g[u][v]=g[v][u]=true;
}
void get(int x,int y,int z) {
int v1=query(x,y,z),v2=query(y,x,z),v3=query(y,z,x),v4=query(z,y,x);
if(v1==v2&&v3==v4)
return;
if(v1==v2) {
if(v3>v4) {
link(x,z);
link(y,z);
}
if(v3<v4)
link(x,y);
} else if(v3==v4) {
if(v1>v2)
link(y,z);
if(v2>v1) {
link(x,y);
link(x,z);
}
} else {
if(v3>v4)
link(x,z);
if(v3<v4)
link(x,y);
if(v1>v2)
link(y,z);
if(v1<v2)
link(x,z);
}
}
bool used[N];
int calc(int l,int r,int d) {
if(l>r)
return 0;
rep(i,1,n)
used[i]=false;
vector<int> vec;
rep(i,2,l-1)
vec.push_back(i),used[i]=true;
int op=0;
rep(i,0,min(r-l,d-1)) {
int x=l+i;
vector<int> tmp;
while(x<=min(r+d,n))
tmp.push_back(x),x+=d;
if(op)
reverse(tmp.begin(),tmp.end());
for(auto x:tmp)
vec.push_back(x),used[x]=true;
op^=1;
}
per(i,min(r+d,n),r+1) {
if(!used[i])
vec.push_back(i);
}
vec.push_back(1);
rep(i,r+1+d,n)
vec.push_back(i);
int val=query(vec),last=-1;
for(auto x:vec) {
if(last!=-1)
val-=g[last][x];
last=x;
}
return val;
}
void solve(int l,int r,int d,int t) {
if(!t)
return;
if(l==r) {
link(l,l+d);
return;
}
int mid=(l+r)>>1;
int v=calc(l,mid,d);
solve(l,mid,d,v);
solve(mid+1,r,d,t-v);
}
bool vis[N];
vector<int> vec;
void dfs(int x) {
if(vis[x])
return;
vis[x]=true;
vec.push_back(x);
rep(i,1,n) {
if(g[x][i])
dfs(i);
}
}
vector<int> solve(int _n) {
n=_n;
if(n==2) {
vector<int> vec;
vec.push_back(1);
vec.push_back(2);
return vec;
}
rep(i,2,n-1)
get(1,i,i+1);
puts("ok");
rep(i,2,n-1)
solve(2,n-i,i,calc(2,n-i,i));
rep(i,1,n) {
int cnt=0;
rep(j,1,n)
cnt+=g[i][j];
if(cnt==1) {
dfs(i);
break;
}
}
return vec;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3820kb
input:
1 3 3 1 2
output:
Unauthorized output
result:
wrong output format Expected integer, but "Unauthorized" found
Subtask #2:
score: 0
Wrong Answer
Test #11:
score: 0
Wrong Answer
time: 0ms
memory: 3812kb
input:
1 27 17 16 3 20 27 5 2 13 24 21 25 23 19 9 7 4 22 12 26 15 14 11 1 18 6 10 8
output:
Unauthorized output
result:
wrong output format Expected integer, but "Unauthorized" found