QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#757551 | #8363. interactive | wangqingxian | 0 | 1ms | 3936kb | C++20 | 2.7kb | 2024-11-17 10:19:23 | 2024-11-17 10:19:24 |
answer
#include<bits/stdc++.h>
#include "interactive.h"
#define pii pair<int,int>
// #define int long long
using namespace std;
const int inf=0x7fffffff,mod=1e9+7,N=5e2+10;
int n;
int e[N][N];
int q3(int x,int y,int z){
vector<int>vec;
vec.clear();
vec.push_back(x);vec.push_back(y);vec.push_back(z);
for(int i=1;i<=n;++i)if(i!=x&&i!=y&&i!=z)vec.push_back(i);
return query(vec);
}
void lk(int u,int v,int k){
e[u][v]=e[v][u]=k;
}
void get_one(int x,int y,int z){
// f1=yz-xz f2=yz-xy f3=xy-xz
int f1=q3(x,y,z)-q3(y,x,z),f2=q3(x,z,y)-q3(z,x,y),f3=f1-f2;
if(f1==1)
lk(y,z,1),lk(x,y,f2==0);
else if(f1==-1)
lk(x,z,1),lk(x,y,f3==0);
if(f2==1)
lk(y,z,1),lk(x,z,f1==0);
else if(f2==-1)
lk(x,y,1),lk(x,z,f3==0);
if(f3==1)
lk(x,y,1),lk(y,z,f2==0);
else if(f3==-1)
lk(x,z,1),lk(y,z,f1==0);
}
bool book[N];
int work(int l,int r,int d){
// cerr<<l<<" "<<r<<" "<<d<<'\n';
int res=0;
vector<int>vec;
vec.clear();
for(int i=1;i<=n;++i)book[i]=0;
for(int i=2;i<l;++i)vec.push_back(i);
for(int i=l;i<=min(r+d,n);++i){
if(book[i])continue;
if(i&1){
int tmp=i;
while(tmp+d<=min(r+d,n))tmp+=d;
while(tmp>=i){
vec.push_back(tmp);
book[tmp]=1;
tmp-=d;
}
}else
for(int tmp=i;tmp<=min(r+d,n);tmp+=d){
vec.push_back(tmp);
book[tmp]=1;
}
}
for(int i=min(r+d,n);i>=r+1;--i)if(!book[i])vec.push_back(i);
vec.push_back(1);
for(int i=r+d+1;i<=n;++i)vec.push_back(i);
// for(auto x:vec)cerr<<x<<" ";
// cerr<<'\n';
res=query(vec);
for(int i=1;i<vec.size();++i)res-=e[vec[i]][vec[i-1]];
// cerr<<res<<'\n';
return res;
}
void calc(int l,int r,int d,int tmp){
if(!tmp)return;
if(l==r)return lk(l,l+d,1),void();
int mid=(l+r)>>1,res=work(l,mid,d);
calc(l,mid,d,res);
calc(mid+1,r,d,tmp-res);
}
bool vis[N];
vector<int>solve(int m){
vector<int>ans;
n=m;
//cerr << "CHECKIN\n";
for(int i=2;i<n;++i)get_one(1,i,i+1);
// cerr << "CHECKIN\n";
for(int i=2;i<=n;++i)calc(2,n,i,work(2,n,i));
// cerr << "CHECKIN\n";
int st=0;
for(int i=1;i<=n;++i){
int du=0;
for(int j=1;j<=n;++j)du+=e[i][j];
if(du==1)st=i;
}
while(st!=n+1){
vis[st]=1;
ans.push_back(st);
int nxt=0;
for(nxt=1;nxt<=n&&(vis[nxt]||!e[st][nxt]);++nxt);
st=nxt;
}
// cerr << "ANS SIZE : " << ans.size() << "\n";
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: 3764kb
input:
1 3 3 1 2
output:
6 759807717 7113
result:
points 1.0
Test #2:
score: 0
Wrong Answer
time: 1ms
memory: 3748kb
input:
1 30 6 28 10 9 13 4 7 1 21 15 20 27 19 5 17 2 22 12 29 23 14 30 18 3 11 24 26 16 8 25
output:
0 0 0
result:
FAIL WA
Subtask #2:
score: 0
Wrong Answer
Test #11:
score: 90
Accepted
time: 0ms
memory: 3864kb
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:
209 553706006 558749364
result:
points 1.0
Test #12:
score: 90
Accepted
time: 0ms
memory: 3868kb
input:
1 29 19 13 20 22 26 1 23 24 3 14 8 25 29 17 10 9 15 11 18 4 2 28 21 7 6 12 16 27 5
output:
218 607359778 145445666
result:
points 1.0
Test #13:
score: 90
Accepted
time: 0ms
memory: 3936kb
input:
1 28 16 7 19 9 23 12 20 26 4 10 15 8 21 5 1 22 27 2 18 24 28 6 3 14 13 17 25 11
output:
229 329680392 877668399
result:
points 1.0
Test #14:
score: 0
Wrong Answer
time: 0ms
memory: 3744kb
input:
1 30 13 4 29 25 16 14 6 15 19 28 7 20 3 23 12 17 8 22 1 24 9 30 21 18 2 26 27 10 11 5
output:
0 0 0
result:
FAIL WA