QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#831527 | #8952. 解谜游戏 | 275307894a | 88.143333 | 186ms | 8176kb | C++14 | 3.5kb | 2024-12-25 15:18:59 | 2024-12-25 15:19:00 |
Judging History
answer
#include<bits/stdc++.h>
#include "puzzle.h"
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=1e3+5,M=(1<<28)+5,K=1000+5,mod=1e9+7,Mod=mod-1;const db eps=1e-9;const int INF=1e9+7;mt19937 rnd(28382);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
#ifdef LOCAL
#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
#else
#define gdb(...) void()
#endif
}using namespace Debug;
int nn,pp[N],qcnt;
vector<int> p,vis,rgt;
int n;
void divide(vector<int> st,int sum,int w){
if(!sum) return;
if(st.size()==1){
vis[st[0]]=1;rgt.push_back(st[0]);
return;
}
int m=st.size()/2;
vector<int> s1(st.begin(),st.begin()+m),s2(st.begin()+m,st.end());
for(int i=0;i<s1.size();i++) swap(p[s1[i]],p[rgt[i]]);
int pw=w-query(p)-s1.size();
// gdb(pw);
for(int i=0;i<s1.size();i++) swap(p[s1[i]],p[rgt[i]]);
divide(s1,pw,w);divide(s2,sum-pw,w);
}
int alp[N][N];
void play(int nn){
mt19937 rnd(181766);
n=nn;p.resize(n);vis.resize(n);
iota(all(p),0);
if(n==1) return check(p);
for(int i=1;i<=100;i++){
shuffle(all(p),rnd);
while(query(p)){
shuffle(all(p),rnd);
}
for(int i=0;i<n;i++) alp[p[i]][i]=1;
}
int cnt=0;
vector<int> id(n-1);
iota(all(id),1);shuffle(all(id),rnd);
for(int i:id){
swap(p[0],p[i]);
int w=query(p);
if(w){
if(w==2){
cnt=w;vis[i]=vis[0]=1;
break;
}
int w1=p[0],w2=p[i];
while(1){
auto q=p;
shuffle(q.begin()+1,q.end(),rnd);
if(!query(q)){vis[i]=1;break;}
q=p;
swap(q[0],q[i]);
shuffle(q.begin()+1,q.end(),rnd);
swap(q[0],q[i]);
if(!query(q)){vis[0]=1;break;}
}
cnt=1;break;
break;
}
swap(p[0],p[i]);
}
gdb(qcnt);
for(int i=0;i<n;i++) if(vis[i]) rgt.push_back(i);
int cts=0;
while(cnt^n){
int w=cnt;
// gdb(w,p[0],p[1],p[2],p[3],p[4],rgt[0],vis[2]);
while(w==cnt){
for(int i=0;i<n;i++) if(!vis[i]) alp[p[i]][i]=1;
static int ap[N];Me(ap,0);
for(int i:rgt) ap[p[i]]=1;
for(int i=0;i<n;i++) if(!vis[i]){
int x=R(n)-1;
int k=100;
while(ap[x]||(k&&alp[x][i])){
if(!ap[x]&&alp[x][i]) k--;
x=R(n)-1;
}
p[i]=x;ap[x]=1;
}
int flag=0;
for(int i=0;i<n;i++) if(!vis[i]&&!alp[p[i]][i]) flag=1;
if(!flag) continue;
w=query(p);
cts++;
// gdb(w,p[0],p[1],p[2],p[3],p[4]);
}
// gdb(w,p[0],p[1],p[2]);
vector<int> st;
vector<int> id(n+1);
iota(all(id),0);shuffle(id.begin(),id.begin()+n,rnd);
for(int i:id)if(rgt.size()<w){
if(i<n&&!vis[i]&&!alp[p[i]][i]) st.push_back(i);
if(i==n||st.size()==rgt.size()){
if(i==n){
divide(st,w-rgt.size(),w);
}else{
for(int i=0;i<st.size();i++) swap(p[st[i]],p[rgt[i]]);
int pw=query(p);
for(int i=0;i<st.size();i++) swap(p[st[i]],p[rgt[i]]);
if(pw<w-st.size()){
divide(st,w-pw-st.size(),w);
}
}
st.clear();
}
}
cnt=w;
}
check(p);
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 2
Accepted
Test #1:
score: 2
Accepted
time: 1ms
memory: 4108kb
input:
1 2 816815200
result:
ok accepted: cnt = 214
Test #2:
score: 2
Accepted
time: 0ms
memory: 3748kb
input:
1 3 723182155
result:
ok accepted: cnt = 331
Test #3:
score: 2
Accepted
time: 0ms
memory: 3916kb
input:
1 5 971867682
result:
ok accepted: cnt = 290
Test #4:
score: 2
Accepted
time: 0ms
memory: 3716kb
input:
1 3 887042235
result:
ok accepted: cnt = 295
Test #5:
score: 2
Accepted
time: 1ms
memory: 4132kb
input:
1 3 568659743
result:
ok accepted: cnt = 331
Test #6:
score: 2
Accepted
time: 1ms
memory: 4124kb
input:
1 5 930991667
result:
ok accepted: cnt = 278
Test #7:
score: 2
Accepted
time: 0ms
memory: 3836kb
input:
1 5 185481439
result:
ok accepted: cnt = 265
Test #8:
score: 2
Accepted
time: 0ms
memory: 4132kb
input:
1 5 405685705
result:
ok accepted: cnt = 276
Test #9:
score: 2
Accepted
time: 0ms
memory: 4136kb
input:
1 5 693401039
result:
ok accepted: cnt = 276
Test #10:
score: 2
Accepted
time: 0ms
memory: 3900kb
input:
1 5 570594473
result:
ok accepted: cnt = 274
Subtask #2:
score: 4
Accepted
Test #11:
score: 4
Accepted
time: 0ms
memory: 3756kb
input:
2 2 931107645
result:
ok accepted: cnt = 214
Test #12:
score: 4
Accepted
time: 0ms
memory: 3896kb
input:
2 4 512124670
result:
ok accepted: cnt = 319
Test #13:
score: 4
Accepted
time: 0ms
memory: 3848kb
input:
2 4 793864173
result:
ok accepted: cnt = 258
Test #14:
score: 4
Accepted
time: 0ms
memory: 4132kb
input:
2 7 322910591
result:
ok accepted: cnt = 286
Test #15:
score: 4
Accepted
time: 0ms
memory: 3872kb
input:
2 9 316192686
result:
ok accepted: cnt = 294
Test #16:
score: 4
Accepted
time: 0ms
memory: 3920kb
input:
2 10 350886420
result:
ok accepted: cnt = 277
Test #17:
score: 4
Accepted
time: 1ms
memory: 3856kb
input:
2 10 914937911
result:
ok accepted: cnt = 293
Test #18:
score: 4
Accepted
time: 0ms
memory: 3844kb
input:
2 10 68729974
result:
ok accepted: cnt = 303
Test #19:
score: 4
Accepted
time: 0ms
memory: 3876kb
input:
2 10 15788440
result:
ok accepted: cnt = 334
Test #20:
score: 4
Accepted
time: 0ms
memory: 3892kb
input:
2 10 950846282
result:
ok accepted: cnt = 297
Subtask #3:
score: 6
Accepted
Test #21:
score: 6
Accepted
time: 0ms
memory: 3788kb
input:
3 2 667362636
result:
ok accepted: cnt = 185
Test #22:
score: 6
Accepted
time: 0ms
memory: 3832kb
input:
3 4 890842001
result:
ok accepted: cnt = 319
Test #23:
score: 6
Accepted
time: 1ms
memory: 3824kb
input:
3 3 225277415
result:
ok accepted: cnt = 292
Test #24:
score: 6
Accepted
time: 1ms
memory: 3916kb
input:
3 26 235413642
result:
ok accepted: cnt = 311
Test #25:
score: 6
Accepted
time: 0ms
memory: 3856kb
input:
3 25 139642984
result:
ok accepted: cnt = 295
Test #26:
score: 6
Accepted
time: 1ms
memory: 4220kb
input:
3 30 991911708
result:
ok accepted: cnt = 382
Test #27:
score: 6
Accepted
time: 1ms
memory: 3968kb
input:
3 30 4514256
result:
ok accepted: cnt = 309
Test #28:
score: 6
Accepted
time: 1ms
memory: 3940kb
input:
3 30 157113423
result:
ok accepted: cnt = 307
Test #29:
score: 6
Accepted
time: 1ms
memory: 3872kb
input:
3 30 557648974
result:
ok accepted: cnt = 318
Test #30:
score: 6
Accepted
time: 1ms
memory: 3904kb
input:
3 30 645022468
result:
ok accepted: cnt = 299
Test #31:
score: 6
Accepted
time: 0ms
memory: 3816kb
input:
4 2 427653480
result:
ok accepted: cnt = 185
Test #32:
score: 6
Accepted
time: 0ms
memory: 3800kb
input:
4 3 219860551
result:
ok accepted: cnt = 331
Test #33:
score: 6
Accepted
time: 0ms
memory: 3780kb
input:
4 4 165138325
result:
ok accepted: cnt = 269
Test #34:
score: 6
Accepted
time: 2ms
memory: 4188kb
input:
4 93 525060479
result:
ok accepted: cnt = 657
Test #35:
score: 6
Accepted
time: 0ms
memory: 4496kb
input:
4 99 829735778
result:
ok accepted: cnt = 733
Subtask #4:
score: 8
Accepted
Test #36:
score: 8
Accepted
time: 0ms
memory: 4216kb
input:
4 100 6610818
result:
ok accepted: cnt = 669
Test #37:
score: 8
Accepted
time: 0ms
memory: 6256kb
input:
4 100 653323659
result:
ok accepted: cnt = 787
Test #38:
score: 8
Accepted
time: 0ms
memory: 4220kb
input:
4 100 268513130
result:
ok accepted: cnt = 679
Test #39:
score: 8
Accepted
time: 2ms
memory: 4252kb
input:
4 100 479581529
result:
ok accepted: cnt = 640
Test #40:
score: 8
Accepted
time: 0ms
memory: 4408kb
input:
4 100 119844914
result:
ok accepted: cnt = 753
Subtask #5:
score: 10
Accepted
Test #41:
score: 10
Accepted
time: 0ms
memory: 3832kb
input:
5 2 527801655
result:
ok accepted: cnt = 214
Test #42:
score: 10
Accepted
time: 0ms
memory: 3872kb
input:
5 5 235665947
result:
ok accepted: cnt = 267
Test #43:
score: 10
Accepted
time: 0ms
memory: 3832kb
input:
5 3 648413779
result:
ok accepted: cnt = 292
Test #44:
score: 10
Accepted
time: 13ms
memory: 4856kb
input:
5 272 737778828
result:
ok accepted: cnt = 1942
Test #45:
score: 10
Accepted
time: 14ms
memory: 5880kb
input:
5 278 173436130
result:
ok accepted: cnt = 2235
Test #46:
score: 10
Accepted
time: 13ms
memory: 6064kb
input:
5 300 997862299
result:
ok accepted: cnt = 2379
Test #47:
score: 10
Accepted
time: 11ms
memory: 6812kb
input:
5 300 764271855
result:
ok accepted: cnt = 2147
Test #48:
score: 10
Accepted
time: 17ms
memory: 7096kb
input:
5 300 428892383
result:
ok accepted: cnt = 2180
Test #49:
score: 10
Accepted
time: 14ms
memory: 5308kb
input:
5 300 166706392
result:
ok accepted: cnt = 2145
Test #50:
score: 10
Accepted
time: 16ms
memory: 5020kb
input:
5 300 843444435
result:
ok accepted: cnt = 2329
Subtask #6:
score: 10
Accepted
Test #51:
score: 10
Accepted
time: 0ms
memory: 3836kb
input:
6 2 183795068
result:
ok accepted: cnt = 214
Test #52:
score: 10
Accepted
time: 0ms
memory: 3892kb
input:
6 5 63668012
result:
ok accepted: cnt = 303
Test #53:
score: 10
Accepted
time: 1ms
memory: 3844kb
input:
6 5 990398365
result:
ok accepted: cnt = 272
Test #54:
score: 10
Accepted
time: 36ms
memory: 6560kb
input:
6 488 942578687
result:
ok accepted: cnt = 4146
Test #55:
score: 10
Accepted
time: 36ms
memory: 7316kb
input:
6 475 915148470
result:
ok accepted: cnt = 4090
Test #56:
score: 10
Accepted
time: 38ms
memory: 7252kb
input:
6 500 736505651
result:
ok accepted: cnt = 4294
Test #57:
score: 10
Accepted
time: 37ms
memory: 6236kb
input:
6 500 352417213
result:
ok accepted: cnt = 4502
Test #58:
score: 10
Accepted
time: 43ms
memory: 6920kb
input:
6 500 80534667
result:
ok accepted: cnt = 4347
Test #59:
score: 10
Accepted
time: 36ms
memory: 7212kb
input:
6 500 811975157
result:
ok accepted: cnt = 4452
Test #60:
score: 10
Accepted
time: 39ms
memory: 6068kb
input:
6 500 471392863
result:
ok accepted: cnt = 4101
Subtask #7:
score: 48.1433
Acceptable Answer
Test #61:
score: 60
Accepted
time: 0ms
memory: 3808kb
input:
7 2 412859550
result:
ok accepted: cnt = 214
Test #62:
score: 60
Accepted
time: 1ms
memory: 3912kb
input:
7 4 892225546
result:
ok accepted: cnt = 294
Test #63:
score: 60
Accepted
time: 0ms
memory: 3808kb
input:
7 4 577686541
result:
ok accepted: cnt = 296
Test #64:
score: 60
Accepted
time: 133ms
memory: 7992kb
input:
7 902 974849567
result:
ok accepted: cnt = 8035
Test #65:
score: 60
Accepted
time: 149ms
memory: 7644kb
input:
7 939 155203710
result:
ok accepted: cnt = 8172
Test #66:
score: 48.1433
Acceptable Answer
time: 173ms
memory: 8084kb
input:
7 1000 253107507
result:
points 0.8023888889 partially_correct: cnt = 10057
Test #67:
score: 60
Accepted
time: 170ms
memory: 7880kb
input:
7 1000 882029420
result:
ok accepted: cnt = 8938
Test #68:
score: 49.0267
Acceptable Answer
time: 163ms
memory: 8176kb
input:
7 1000 199421982
result:
points 0.8171111111 partially_correct: cnt = 9792
Test #69:
score: 60
Accepted
time: 186ms
memory: 7944kb
input:
7 1000 749220884
result:
ok accepted: cnt = 9287
Test #70:
score: 49.9233
Acceptable Answer
time: 163ms
memory: 7860kb
input:
7 1000 729055050
result:
points 0.8320555556 partially_correct: cnt = 9523
Test #71:
score: 60
Accepted
time: 0ms
memory: 3788kb
input:
7 2 375338281
result:
ok accepted: cnt = 185
Test #72:
score: 60
Accepted
time: 0ms
memory: 3876kb
input:
7 5 914443594
result:
ok accepted: cnt = 260
Test #73:
score: 60
Accepted
time: 0ms
memory: 3832kb
input:
7 5 310479620
result:
ok accepted: cnt = 253
Test #74:
score: 60
Accepted
time: 158ms
memory: 7816kb
input:
7 982 660842623
result:
ok accepted: cnt = 8942
Test #75:
score: 60
Accepted
time: 157ms
memory: 8120kb
input:
7 985 92435101
result:
ok accepted: cnt = 8817
Test #76:
score: 49.62
Acceptable Answer
time: 165ms
memory: 8176kb
input:
7 1000 901527471
result:
points 0.827 partially_correct: cnt = 9614
Test #77:
score: 60
Accepted
time: 160ms
memory: 7888kb
input:
7 1000 891945482
result:
ok accepted: cnt = 9335
Test #78:
score: 60
Accepted
time: 155ms
memory: 7888kb
input:
7 1000 461988571
result:
ok accepted: cnt = 8762
Test #79:
score: 60
Accepted
time: 175ms
memory: 7836kb
input:
7 1000 588921486
result:
ok accepted: cnt = 9186
Test #80:
score: 60
Accepted
time: 162ms
memory: 7884kb
input:
7 1000 819181186
result:
ok accepted: cnt = 9204
Test #81:
score: 60
Accepted
time: 0ms
memory: 3772kb
input:
7 2 509390821
result:
ok accepted: cnt = 214
Test #82:
score: 60
Accepted
time: 0ms
memory: 3836kb
input:
7 3 932973010
result:
ok accepted: cnt = 288
Test #83:
score: 60
Accepted
time: 0ms
memory: 4120kb
input:
7 3 704198002
result:
ok accepted: cnt = 292
Test #84:
score: 49.9867
Acceptable Answer
time: 170ms
memory: 7876kb
input:
7 996 844688748
result:
points 0.8331111111 partially_correct: cnt = 9504
Test #85:
score: 60
Accepted
time: 143ms
memory: 7632kb
input:
7 935 983758765
result:
ok accepted: cnt = 8598
Test #86:
score: 48.97
Acceptable Answer
time: 166ms
memory: 7860kb
input:
7 1000 560957955
result:
points 0.8161666667 partially_correct: cnt = 9809
Test #87:
score: 60
Accepted
time: 174ms
memory: 7920kb
input:
7 1000 381616996
result:
ok accepted: cnt = 8900
Test #88:
score: 60
Accepted
time: 170ms
memory: 7856kb
input:
7 1000 607168013
result:
ok accepted: cnt = 8984
Test #89:
score: 60
Accepted
time: 166ms
memory: 7892kb
input:
7 1000 755432541
result:
ok accepted: cnt = 8885
Test #90:
score: 60
Accepted
time: 174ms
memory: 8168kb
input:
7 1000 675700852
result:
ok accepted: cnt = 9312
Test #91:
score: 60
Accepted
time: 0ms
memory: 3892kb
input:
7 2 91873452
result:
ok accepted: cnt = 214
Test #92:
score: 60
Accepted
time: 0ms
memory: 3896kb
input:
7 4 336570576
result:
ok accepted: cnt = 245
Test #93:
score: 60
Accepted
time: 0ms
memory: 4116kb
input:
7 4 617201184
result:
ok accepted: cnt = 260
Test #94:
score: 60
Accepted
time: 130ms
memory: 7524kb
input:
7 904 396880646
result:
ok accepted: cnt = 8902
Test #95:
score: 60
Accepted
time: 132ms
memory: 7504kb
input:
7 906 970970547
result:
ok accepted: cnt = 8099
Test #96:
score: 49.0633
Acceptable Answer
time: 162ms
memory: 7884kb
input:
7 1000 960558936
result:
points 0.8177222222 partially_correct: cnt = 9781
Test #97:
score: 60
Accepted
time: 164ms
memory: 7888kb
input:
7 1000 238446836
result:
ok accepted: cnt = 8943
Test #98:
score: 49.64
Acceptable Answer
time: 159ms
memory: 7888kb
input:
7 1000 897094536
result:
points 0.8273333333 partially_correct: cnt = 9608
Test #99:
score: 48.1833
Acceptable Answer
time: 155ms
memory: 8172kb
input:
7 1000 820891454
result:
points 0.8030555556 partially_correct: cnt = 10045
Test #100:
score: 49.9033
Acceptable Answer
time: 161ms
memory: 7968kb
input:
7 1000 586475353
result:
points 0.8317222222 partially_correct: cnt = 9529