QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#797300 | #8952. 解谜游戏 | misfits | 84.176667 | 23ms | 8092kb | C++14 | 4.2kb | 2024-12-02 20:28:44 | 2024-12-02 20:28:44 |
Judging History
answer
#include<bits/stdc++.h>
#include "puzzle.h"
#define LL int
#define SZ(x) ((LL)(x.size()))
#define all(x) (x).begin(),(x).end()
using namespace std;
inline void dmin(LL &x,LL y){if(x>y)x=y;return ;}
inline void dmax(LL &x,LL y){if(x<y)x=y;return ;}
#define cout cerr
#define pb push_back
namespace GenHelper{
#define ull unsigned long long
ull seed=19260817ull;
inline void Get(){seed^=(seed<<7);seed^=(seed>>11);seed^=(seed<<13);}
inline ull Rand(){Get();return (seed^(seed<<32ull));}
}using GenHelper::Rand;
inline LL random(LL l,LL r){return (Rand()%(r-l+1)+l);}
const LL N = 1000+95 ;
LL n;vector<LL>P,ans;
#define PL pair<LL,LL>
#define mp make_pair
#define fir first
#define sec second
inline LL GET(vector<PL>vc){
vector<LL>p=P;
for(auto u:vc){
// cout<<" -> u.fir = "<<u.fir<<" u.sec = "<<u.sec<<endl;
swap(p[u.fir],p[u.sec]);
}
// cout<<" p : ";for(auto u:p)cout<<u<<" ";cout<<endl;
return query(p);
}
LL X=-1,Y=-1;
inline bool __brute(LL x,LL y){//极其暴力的判断单点的 p[x] 是否等于 y ,错误率 0.0101 .
for(LL TC=1;TC<=20;TC++){
vector<LL>p(n);for(LL i=0;i<n;i++)p[i]=i;
for(LL i=0;i<n;i++)swap(p[i],p[random(0,(n-1))]);
for(LL i=0;i<n;i++)if(p[i]==y){swap(p[x],p[i]);break;}
if(query(p)==0)return 0;
}
return 1;
}
inline bool brute(LL x,LL y){//判断单点 p[x] 是否等于 y
if(X==-1)return __brute(x,y);
//用一组正确的匹配强行拆解掉原有匹配
vector<LL>p(n);for(LL i=0;i<n;i++)p[i]=i;
for(LL i=0;i<n;i++)swap(p[i],p[random(0,(n-1))]);
for(LL i=0;i<n;i++)if(p[i]==Y){swap(p[X],p[i]);break;}
for(LL i=0;i<n;i++)if(p[i]==y){swap(p[x],p[i]);break;}
LL k=query(p);swap(p[x],p[X]);LL _k=query(p);
return ((k==_k+2)?(1):(0));
}
void solve(vector<PL>&vc,LL l,LL r,LL cnt){
// cout<<" -> l = "<<l<<" r = "<<r<<endl;
if(!cnt)return ;
// cout<<" -> l = "<<l<<" r = "<<r<<" cnt = "<<cnt<<endl;
if(l==r){
// cout<<" -> vc[l].fir = "<<vc[l].fir<<" P[vc[l].sec] = "<<P[vc[l].sec]<<" vc[l].sec = "<<vc[l].sec<<" P[vc[l].fir] = "<<P[vc[l].fir]<<endl;
if(cnt==1){
if(brute(vc[l].fir,P[vc[l].sec])){
ans[vc[l].fir]=P[vc[l].sec];
X=vc[l].fir;Y=P[vc[l].sec];
// cout<<" -> vc[l].fir = "<<vc[l].fir<<" P[vc[l].sec] = "<<P[vc[l].sec]<<endl;
}
else {
ans[vc[l].sec]=P[vc[l].fir];
X=vc[l].sec;Y=P[vc[l].fir];
// cout<<" -> vc[l].sec = "<<vc[l].sec<<" P[vc[l].fir] = "<<P[vc[l].fir]<<endl;
}
}
else {
// cout<<" -> vc[l].fir = "<<vc[l].fir<<" P[vc[l].sec] = "<<P[vc[l].sec]<<endl;
ans[vc[l].fir]=P[vc[l].sec];
X=vc[l].fir;Y=P[vc[l].sec];
// cout<<" -> vc[l].sec = "<<vc[l].sec<<" P[vc[l].fir] = "<<P[vc[l].fir]<<endl;
ans[vc[l].sec]=P[vc[l].fir];
}
return ;
}
LL mid=(l+r)>>1;
vector<PL>tmp;for(LL i=l;i<=mid;i++)tmp.pb(vc[i]);
LL cntl=GET(tmp);LL cntr=cnt-cntl;
solve(vc,l,mid,cntl);solve(vc,mid+1,r,cntr);
return ;
}
void play(LL _n_){
n=_n_;if(n==1){check({0});return ;}
P.resize(n);for(LL t=0;t<n;t++)P[t]=t;
while(true){
for(LL t=0;t<n;t++)swap(P[t],P[random(0,(n-1))]);
// cout<<" -> p = ";for(auto u:P)cout<<u<<" ";cout<<endl;
if(!query(P))break;
}
// cout<<" P " ;for(auto u:P)cout<<u<<" ";cout<<endl;
vector<vector<PL>>vc;
if(n&1){
auto tr=[&](LL x){
if(x<1)x+=n;
if(x>n)x-=n;
return x;
};
vc.resize(n);
for(LL t=0;t<n;t++){
vector<PL>p;
for(LL i=1;i<=(n>>1);i++)p.pb(mp(tr((t+1)-i),tr((t+1)+i)));
vc[t]=p;
}
}
else {
auto tr=[&](LL x){
if(x<1)x+=(n-1);
if(x>(n-1))x-=(n-1);
return x;
};
vc.resize(n-1);
for(LL t=0;t<n-1;t++){
vector<PL>p;p.pb(mp(t+1,n));
for(LL i=1;i<(n>>1);i++)p.pb(mp(tr((t+1)-i),tr((t+1)+i)));
vc[t]=p;
}
}
/* for(LL t=0;t<SZ(vc);t++){
cout<<"> t = "<<t<<" vc[t] : ";
for(auto u:vc[t])cout<<" ("<<u.fir<<","<<u.sec<<") ";cout<<endl;
}*/
ans.resize(n);
for(LL t=0;t<SZ(vc);t++){
for(LL i=0;i<SZ(vc[t]);i++){vc[t][i].fir--;vc[t][i].sec--;}
solve(vc[t],0,SZ(vc[t])-1,GET(vc[t]));
}
// cout<<" -> ans : ";for(auto u:ans)cout<<u<<" ";cout<<endl;
check(ans);return ;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 2
Accepted
Test #1:
score: 2
Accepted
time: 0ms
memory: 3892kb
input:
1 2 816815200
result:
ok accepted: cnt = 2
Test #2:
score: 2
Accepted
time: 0ms
memory: 3788kb
input:
1 3 723182155
result:
ok accepted: cnt = 11
Test #3:
score: 2
Accepted
time: 0ms
memory: 3832kb
input:
1 5 971867682
result:
ok accepted: cnt = 38
Test #4:
score: 2
Accepted
time: 0ms
memory: 3808kb
input:
1 3 887042235
result:
ok accepted: cnt = 36
Test #5:
score: 2
Accepted
time: 0ms
memory: 3836kb
input:
1 3 568659743
result:
ok accepted: cnt = 11
Test #6:
score: 2
Accepted
time: 0ms
memory: 3828kb
input:
1 5 930991667
result:
ok accepted: cnt = 39
Test #7:
score: 2
Accepted
time: 0ms
memory: 4132kb
input:
1 5 185481439
result:
ok accepted: cnt = 22
Test #8:
score: 2
Accepted
time: 0ms
memory: 3840kb
input:
1 5 405685705
result:
ok accepted: cnt = 38
Test #9:
score: 2
Accepted
time: 0ms
memory: 3788kb
input:
1 5 693401039
result:
ok accepted: cnt = 20
Test #10:
score: 2
Accepted
time: 0ms
memory: 3864kb
input:
1 5 570594473
result:
ok accepted: cnt = 35
Subtask #2:
score: 4
Accepted
Test #11:
score: 4
Accepted
time: 0ms
memory: 4132kb
input:
2 2 931107645
result:
ok accepted: cnt = 2
Test #12:
score: 4
Accepted
time: 0ms
memory: 4124kb
input:
2 4 512124670
result:
ok accepted: cnt = 10
Test #13:
score: 4
Accepted
time: 0ms
memory: 3828kb
input:
2 4 793864173
result:
ok accepted: cnt = 5
Test #14:
score: 4
Accepted
time: 0ms
memory: 3848kb
input:
2 7 322910591
result:
ok accepted: cnt = 26
Test #15:
score: 4
Accepted
time: 0ms
memory: 3848kb
input:
2 9 316192686
result:
ok accepted: cnt = 61
Test #16:
score: 4
Accepted
time: 0ms
memory: 4128kb
input:
2 10 350886420
result:
ok accepted: cnt = 53
Test #17:
score: 4
Accepted
time: 0ms
memory: 4032kb
input:
2 10 914937911
result:
ok accepted: cnt = 68
Test #18:
score: 4
Accepted
time: 0ms
memory: 3788kb
input:
2 10 68729974
result:
ok accepted: cnt = 62
Test #19:
score: 4
Accepted
time: 0ms
memory: 4132kb
input:
2 10 15788440
result:
ok accepted: cnt = 50
Test #20:
score: 4
Accepted
time: 0ms
memory: 3832kb
input:
2 10 950846282
result:
ok accepted: cnt = 65
Subtask #3:
score: 6
Accepted
Test #21:
score: 6
Accepted
time: 0ms
memory: 3848kb
input:
3 2 667362636
result:
ok accepted: cnt = 5
Test #22:
score: 6
Accepted
time: 0ms
memory: 3836kb
input:
3 4 890842001
result:
ok accepted: cnt = 10
Test #23:
score: 6
Accepted
time: 0ms
memory: 3784kb
input:
3 3 225277415
result:
ok accepted: cnt = 20
Test #24:
score: 6
Accepted
time: 0ms
memory: 3844kb
input:
3 26 235413642
result:
ok accepted: cnt = 176
Test #25:
score: 6
Accepted
time: 0ms
memory: 3836kb
input:
3 25 139642984
result:
ok accepted: cnt = 154
Test #26:
score: 6
Accepted
time: 0ms
memory: 3836kb
input:
3 30 991911708
result:
ok accepted: cnt = 216
Test #27:
score: 6
Accepted
time: 0ms
memory: 3872kb
input:
3 30 4514256
result:
ok accepted: cnt = 187
Test #28:
score: 6
Accepted
time: 0ms
memory: 3832kb
input:
3 30 157113423
result:
ok accepted: cnt = 191
Test #29:
score: 6
Accepted
time: 0ms
memory: 4128kb
input:
3 30 557648974
result:
ok accepted: cnt = 197
Test #30:
score: 6
Accepted
time: 0ms
memory: 3904kb
input:
3 30 645022468
result:
ok accepted: cnt = 207
Test #31:
score: 6
Accepted
time: 0ms
memory: 3828kb
input:
4 2 427653480
result:
ok accepted: cnt = 5
Test #32:
score: 6
Accepted
time: 0ms
memory: 3908kb
input:
4 3 219860551
result:
ok accepted: cnt = 11
Test #33:
score: 6
Accepted
time: 0ms
memory: 3828kb
input:
4 4 165138325
result:
ok accepted: cnt = 33
Test #34:
score: 6
Accepted
time: 0ms
memory: 3936kb
input:
4 93 525060479
result:
ok accepted: cnt = 743
Test #35:
score: 6
Accepted
time: 1ms
memory: 3872kb
input:
4 99 829735778
result:
ok accepted: cnt = 808
Subtask #4:
score: 8
Accepted
Test #36:
score: 8
Accepted
time: 1ms
memory: 4168kb
input:
4 100 6610818
result:
ok accepted: cnt = 800
Test #37:
score: 8
Accepted
time: 1ms
memory: 3868kb
input:
4 100 653323659
result:
ok accepted: cnt = 823
Test #38:
score: 8
Accepted
time: 1ms
memory: 4080kb
input:
4 100 268513130
result:
ok accepted: cnt = 810
Test #39:
score: 8
Accepted
time: 1ms
memory: 3892kb
input:
4 100 479581529
result:
ok accepted: cnt = 784
Test #40:
score: 8
Accepted
time: 1ms
memory: 4164kb
input:
4 100 119844914
result:
ok accepted: cnt = 818
Subtask #5:
score: 10
Accepted
Test #41:
score: 10
Accepted
time: 0ms
memory: 3852kb
input:
5 2 527801655
result:
ok accepted: cnt = 2
Test #42:
score: 10
Accepted
time: 0ms
memory: 3836kb
input:
5 5 235665947
result:
ok accepted: cnt = 38
Test #43:
score: 10
Accepted
time: 0ms
memory: 3836kb
input:
5 3 648413779
result:
ok accepted: cnt = 20
Test #44:
score: 10
Accepted
time: 2ms
memory: 4140kb
input:
5 272 737778828
result:
ok accepted: cnt = 2534
Test #45:
score: 10
Accepted
time: 2ms
memory: 4160kb
input:
5 278 173436130
result:
ok accepted: cnt = 2648
Test #46:
score: 10
Accepted
time: 3ms
memory: 4232kb
input:
5 300 997862299
result:
ok accepted: cnt = 2879
Test #47:
score: 10
Accepted
time: 2ms
memory: 4196kb
input:
5 300 764271855
result:
ok accepted: cnt = 2854
Test #48:
score: 10
Accepted
time: 3ms
memory: 4196kb
input:
5 300 428892383
result:
ok accepted: cnt = 2830
Test #49:
score: 10
Accepted
time: 3ms
memory: 4180kb
input:
5 300 166706392
result:
ok accepted: cnt = 2861
Test #50:
score: 10
Accepted
time: 3ms
memory: 4500kb
input:
5 300 843444435
result:
ok accepted: cnt = 2813
Subtask #6:
score: 10
Accepted
Test #51:
score: 10
Accepted
time: 0ms
memory: 3828kb
input:
6 2 183795068
result:
ok accepted: cnt = 2
Test #52:
score: 10
Accepted
time: 0ms
memory: 3912kb
input:
6 5 63668012
result:
ok accepted: cnt = 20
Test #53:
score: 10
Accepted
time: 0ms
memory: 4124kb
input:
6 5 990398365
result:
ok accepted: cnt = 39
Test #54:
score: 10
Accepted
time: 6ms
memory: 4788kb
input:
6 488 942578687
result:
ok accepted: cnt = 4989
Test #55:
score: 10
Accepted
time: 2ms
memory: 4768kb
input:
6 475 915148470
result:
ok accepted: cnt = 4746
Test #56:
score: 10
Accepted
time: 6ms
memory: 4852kb
input:
6 500 736505651
result:
ok accepted: cnt = 5080
Test #57:
score: 10
Accepted
time: 6ms
memory: 4844kb
input:
6 500 352417213
result:
ok accepted: cnt = 5087
Test #58:
score: 10
Accepted
time: 6ms
memory: 4844kb
input:
6 500 80534667
result:
ok accepted: cnt = 5089
Test #59:
score: 10
Accepted
time: 6ms
memory: 4836kb
input:
6 500 811975157
result:
ok accepted: cnt = 5116
Test #60:
score: 10
Accepted
time: 6ms
memory: 4832kb
input:
6 500 471392863
result:
ok accepted: cnt = 5074
Subtask #7:
score: 44.1767
Acceptable Answer
Test #61:
score: 60
Accepted
time: 0ms
memory: 3800kb
input:
7 2 412859550
result:
ok accepted: cnt = 2
Test #62:
score: 60
Accepted
time: 0ms
memory: 4124kb
input:
7 4 892225546
result:
ok accepted: cnt = 21
Test #63:
score: 60
Accepted
time: 0ms
memory: 4136kb
input:
7 4 577686541
result:
ok accepted: cnt = 14
Test #64:
score: 48.6567
Acceptable Answer
time: 19ms
memory: 7132kb
input:
7 902 974849567
result:
points 0.8109444444 partially_correct: cnt = 9903
Test #65:
score: 46.6967
Acceptable Answer
time: 17ms
memory: 7336kb
input:
7 939 155203710
result:
points 0.7782777778 partially_correct: cnt = 10491
Test #66:
score: 44.34
Acceptable Answer
time: 19ms
memory: 7748kb
input:
7 1000 253107507
result:
points 0.739 partially_correct: cnt = 11198
Test #67:
score: 44.4167
Acceptable Answer
time: 15ms
memory: 7792kb
input:
7 1000 882029420
result:
points 0.7402777778 partially_correct: cnt = 11175
Test #68:
score: 44.4733
Acceptable Answer
time: 22ms
memory: 8080kb
input:
7 1000 199421982
result:
points 0.7412222222 partially_correct: cnt = 11158
Test #69:
score: 44.28
Acceptable Answer
time: 22ms
memory: 7992kb
input:
7 1000 749220884
result:
points 0.738 partially_correct: cnt = 11216
Test #70:
score: 44.3033
Acceptable Answer
time: 22ms
memory: 7856kb
input:
7 1000 729055050
result:
points 0.7383888889 partially_correct: cnt = 11209
Test #71:
score: 60
Accepted
time: 0ms
memory: 3804kb
input:
7 2 375338281
result:
ok accepted: cnt = 5
Test #72:
score: 60
Accepted
time: 0ms
memory: 3840kb
input:
7 5 914443594
result:
ok accepted: cnt = 24
Test #73:
score: 60
Accepted
time: 0ms
memory: 3832kb
input:
7 5 310479620
result:
ok accepted: cnt = 34
Test #74:
score: 45.22
Acceptable Answer
time: 14ms
memory: 7844kb
input:
7 982 660842623
result:
points 0.7536666667 partially_correct: cnt = 10934
Test #75:
score: 44.87
Acceptable Answer
time: 17ms
memory: 7688kb
input:
7 985 92435101
result:
points 0.7478333333 partially_correct: cnt = 11039
Test #76:
score: 44.4933
Acceptable Answer
time: 19ms
memory: 8084kb
input:
7 1000 901527471
result:
points 0.7415555556 partially_correct: cnt = 11152
Test #77:
score: 44.4933
Acceptable Answer
time: 23ms
memory: 7744kb
input:
7 1000 891945482
result:
points 0.7415555556 partially_correct: cnt = 11152
Test #78:
score: 44.49
Acceptable Answer
time: 23ms
memory: 7788kb
input:
7 1000 461988571
result:
points 0.7415 partially_correct: cnt = 11153
Test #79:
score: 44.3767
Acceptable Answer
time: 23ms
memory: 7856kb
input:
7 1000 588921486
result:
points 0.7396111111 partially_correct: cnt = 11187
Test #80:
score: 44.4567
Acceptable Answer
time: 23ms
memory: 7828kb
input:
7 1000 819181186
result:
points 0.7409444444 partially_correct: cnt = 11163
Test #81:
score: 60
Accepted
time: 0ms
memory: 3828kb
input:
7 2 509390821
result:
ok accepted: cnt = 2
Test #82:
score: 60
Accepted
time: 0ms
memory: 3784kb
input:
7 3 932973010
result:
ok accepted: cnt = 39
Test #83:
score: 60
Accepted
time: 0ms
memory: 3892kb
input:
7 3 704198002
result:
ok accepted: cnt = 28
Test #84:
score: 44.46
Acceptable Answer
time: 15ms
memory: 8060kb
input:
7 996 844688748
result:
points 0.741 partially_correct: cnt = 11162
Test #85:
score: 47.07
Acceptable Answer
time: 20ms
memory: 7596kb
input:
7 935 983758765
result:
points 0.7845 partially_correct: cnt = 10379
Test #86:
score: 44.41
Acceptable Answer
time: 18ms
memory: 8084kb
input:
7 1000 560957955
result:
points 0.7401666667 partially_correct: cnt = 11177
Test #87:
score: 44.47
Acceptable Answer
time: 23ms
memory: 7744kb
input:
7 1000 381616996
result:
points 0.7411666667 partially_correct: cnt = 11159
Test #88:
score: 44.51
Acceptable Answer
time: 23ms
memory: 8092kb
input:
7 1000 607168013
result:
points 0.7418333333 partially_correct: cnt = 11147
Test #89:
score: 44.2267
Acceptable Answer
time: 23ms
memory: 7824kb
input:
7 1000 755432541
result:
points 0.7371111111 partially_correct: cnt = 11232
Test #90:
score: 44.55
Acceptable Answer
time: 19ms
memory: 8084kb
input:
7 1000 675700852
result:
points 0.7425 partially_correct: cnt = 11135
Test #91:
score: 60
Accepted
time: 0ms
memory: 3840kb
input:
7 2 91873452
result:
ok accepted: cnt = 2
Test #92:
score: 60
Accepted
time: 0ms
memory: 4128kb
input:
7 4 336570576
result:
ok accepted: cnt = 21
Test #93:
score: 60
Accepted
time: 0ms
memory: 3844kb
input:
7 4 617201184
result:
ok accepted: cnt = 17
Test #94:
score: 48.1933
Acceptable Answer
time: 19ms
memory: 7364kb
input:
7 904 396880646
result:
points 0.8032222222 partially_correct: cnt = 10042
Test #95:
score: 48.33
Acceptable Answer
time: 15ms
memory: 7140kb
input:
7 906 970970547
result:
points 0.8055 partially_correct: cnt = 10001
Test #96:
score: 44.1767
Acceptable Answer
time: 15ms
memory: 8088kb
input:
7 1000 960558936
result:
points 0.7362777778 partially_correct: cnt = 11247
Test #97:
score: 44.6267
Acceptable Answer
time: 23ms
memory: 7800kb
input:
7 1000 238446836
result:
points 0.7437777778 partially_correct: cnt = 11112
Test #98:
score: 44.2367
Acceptable Answer
time: 19ms
memory: 7800kb
input:
7 1000 897094536
result:
points 0.7372777778 partially_correct: cnt = 11229
Test #99:
score: 44.5233
Acceptable Answer
time: 23ms
memory: 8092kb
input:
7 1000 820891454
result:
points 0.7420555556 partially_correct: cnt = 11143
Test #100:
score: 44.32
Acceptable Answer
time: 23ms
memory: 7792kb
input:
7 1000 586475353
result:
points 0.7386666667 partially_correct: cnt = 11204