QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#831533 | #8952. 解谜游戏 | 275307894a | 87.11 | 164ms | 8204kb | C++14 | 3.5kb | 2024-12-25 15:21:48 | 2024-12-25 15:21:55 |
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<=50;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);
}
详细
Subtask #1:
score: 2
Accepted
Test #1:
score: 2
Accepted
time: 0ms
memory: 4024kb
input:
1 2 816815200
result:
ok accepted: cnt = 99
Test #2:
score: 2
Accepted
time: 0ms
memory: 3832kb
input:
1 3 723182155
result:
ok accepted: cnt = 151
Test #3:
score: 2
Accepted
time: 1ms
memory: 5896kb
input:
1 5 971867682
result:
ok accepted: cnt = 186
Test #4:
score: 2
Accepted
time: 0ms
memory: 3820kb
input:
1 3 887042235
result:
ok accepted: cnt = 165
Test #5:
score: 2
Accepted
time: 0ms
memory: 3836kb
input:
1 3 568659743
result:
ok accepted: cnt = 151
Test #6:
score: 2
Accepted
time: 0ms
memory: 3844kb
input:
1 5 930991667
result:
ok accepted: cnt = 143
Test #7:
score: 2
Accepted
time: 0ms
memory: 3920kb
input:
1 5 185481439
result:
ok accepted: cnt = 155
Test #8:
score: 2
Accepted
time: 0ms
memory: 3924kb
input:
1 5 405685705
result:
ok accepted: cnt = 124
Test #9:
score: 2
Accepted
time: 0ms
memory: 4164kb
input:
1 5 693401039
result:
ok accepted: cnt = 140
Test #10:
score: 2
Accepted
time: 0ms
memory: 3840kb
input:
1 5 570594473
result:
ok accepted: cnt = 144
Subtask #2:
score: 4
Accepted
Test #11:
score: 4
Accepted
time: 0ms
memory: 4028kb
input:
2 2 931107645
result:
ok accepted: cnt = 99
Test #12:
score: 4
Accepted
time: 0ms
memory: 3900kb
input:
2 4 512124670
result:
ok accepted: cnt = 179
Test #13:
score: 4
Accepted
time: 0ms
memory: 3816kb
input:
2 4 793864173
result:
ok accepted: cnt = 127
Test #14:
score: 4
Accepted
time: 0ms
memory: 3856kb
input:
2 7 322910591
result:
ok accepted: cnt = 141
Test #15:
score: 4
Accepted
time: 0ms
memory: 3864kb
input:
2 9 316192686
result:
ok accepted: cnt = 168
Test #16:
score: 4
Accepted
time: 0ms
memory: 3928kb
input:
2 10 350886420
result:
ok accepted: cnt = 177
Test #17:
score: 4
Accepted
time: 0ms
memory: 3896kb
input:
2 10 914937911
result:
ok accepted: cnt = 161
Test #18:
score: 4
Accepted
time: 0ms
memory: 3860kb
input:
2 10 68729974
result:
ok accepted: cnt = 167
Test #19:
score: 4
Accepted
time: 0ms
memory: 3868kb
input:
2 10 15788440
result:
ok accepted: cnt = 152
Test #20:
score: 4
Accepted
time: 0ms
memory: 4172kb
input:
2 10 950846282
result:
ok accepted: cnt = 161
Subtask #3:
score: 6
Accepted
Test #21:
score: 6
Accepted
time: 0ms
memory: 3820kb
input:
3 2 667362636
result:
ok accepted: cnt = 102
Test #22:
score: 6
Accepted
time: 0ms
memory: 3844kb
input:
3 4 890842001
result:
ok accepted: cnt = 179
Test #23:
score: 6
Accepted
time: 0ms
memory: 4144kb
input:
3 3 225277415
result:
ok accepted: cnt = 138
Test #24:
score: 6
Accepted
time: 0ms
memory: 3872kb
input:
3 26 235413642
result:
ok accepted: cnt = 165
Test #25:
score: 6
Accepted
time: 0ms
memory: 3868kb
input:
3 25 139642984
result:
ok accepted: cnt = 150
Test #26:
score: 6
Accepted
time: 1ms
memory: 4232kb
input:
3 30 991911708
result:
ok accepted: cnt = 210
Test #27:
score: 6
Accepted
time: 1ms
memory: 4000kb
input:
3 30 4514256
result:
ok accepted: cnt = 200
Test #28:
score: 6
Accepted
time: 1ms
memory: 4240kb
input:
3 30 157113423
result:
ok accepted: cnt = 208
Test #29:
score: 6
Accepted
time: 1ms
memory: 3944kb
input:
3 30 557648974
result:
ok accepted: cnt = 195
Test #30:
score: 6
Accepted
time: 1ms
memory: 3948kb
input:
3 30 645022468
result:
ok accepted: cnt = 224
Test #31:
score: 6
Accepted
time: 0ms
memory: 3864kb
input:
4 2 427653480
result:
ok accepted: cnt = 102
Test #32:
score: 6
Accepted
time: 0ms
memory: 4040kb
input:
4 3 219860551
result:
ok accepted: cnt = 151
Test #33:
score: 6
Accepted
time: 0ms
memory: 3808kb
input:
4 4 165138325
result:
ok accepted: cnt = 137
Test #34:
score: 6
Accepted
time: 2ms
memory: 4192kb
input:
4 93 525060479
result:
ok accepted: cnt = 584
Test #35:
score: 6
Accepted
time: 2ms
memory: 4416kb
input:
4 99 829735778
result:
ok accepted: cnt = 605
Subtask #4:
score: 8
Accepted
Test #36:
score: 8
Accepted
time: 2ms
memory: 4288kb
input:
4 100 6610818
result:
ok accepted: cnt = 572
Test #37:
score: 8
Accepted
time: 2ms
memory: 6376kb
input:
4 100 653323659
result:
ok accepted: cnt = 577
Test #38:
score: 8
Accepted
time: 2ms
memory: 4192kb
input:
4 100 268513130
result:
ok accepted: cnt = 603
Test #39:
score: 8
Accepted
time: 2ms
memory: 4232kb
input:
4 100 479581529
result:
ok accepted: cnt = 618
Test #40:
score: 8
Accepted
time: 2ms
memory: 4276kb
input:
4 100 119844914
result:
ok accepted: cnt = 648
Subtask #5:
score: 10
Accepted
Test #41:
score: 10
Accepted
time: 0ms
memory: 3832kb
input:
5 2 527801655
result:
ok accepted: cnt = 99
Test #42:
score: 10
Accepted
time: 0ms
memory: 3852kb
input:
5 5 235665947
result:
ok accepted: cnt = 151
Test #43:
score: 10
Accepted
time: 0ms
memory: 3852kb
input:
5 3 648413779
result:
ok accepted: cnt = 138
Test #44:
score: 10
Accepted
time: 11ms
memory: 5212kb
input:
5 272 737778828
result:
ok accepted: cnt = 1938
Test #45:
score: 10
Accepted
time: 13ms
memory: 6220kb
input:
5 278 173436130
result:
ok accepted: cnt = 2054
Test #46:
score: 10
Accepted
time: 15ms
memory: 5340kb
input:
5 300 997862299
result:
ok accepted: cnt = 2357
Test #47:
score: 10
Accepted
time: 12ms
memory: 5020kb
input:
5 300 764271855
result:
ok accepted: cnt = 2301
Test #48:
score: 10
Accepted
time: 10ms
memory: 6688kb
input:
5 300 428892383
result:
ok accepted: cnt = 2148
Test #49:
score: 10
Accepted
time: 13ms
memory: 6524kb
input:
5 300 166706392
result:
ok accepted: cnt = 2098
Test #50:
score: 10
Accepted
time: 11ms
memory: 5360kb
input:
5 300 843444435
result:
ok accepted: cnt = 2193
Subtask #6:
score: 10
Accepted
Test #51:
score: 10
Accepted
time: 0ms
memory: 3820kb
input:
6 2 183795068
result:
ok accepted: cnt = 99
Test #52:
score: 10
Accepted
time: 0ms
memory: 4156kb
input:
6 5 63668012
result:
ok accepted: cnt = 145
Test #53:
score: 10
Accepted
time: 0ms
memory: 3884kb
input:
6 5 990398365
result:
ok accepted: cnt = 120
Test #54:
score: 10
Accepted
time: 37ms
memory: 6156kb
input:
6 488 942578687
result:
ok accepted: cnt = 4030
Test #55:
score: 10
Accepted
time: 36ms
memory: 7056kb
input:
6 475 915148470
result:
ok accepted: cnt = 3749
Test #56:
score: 10
Accepted
time: 37ms
memory: 7240kb
input:
6 500 736505651
result:
ok accepted: cnt = 4265
Test #57:
score: 10
Accepted
time: 39ms
memory: 7324kb
input:
6 500 352417213
result:
ok accepted: cnt = 4129
Test #58:
score: 10
Accepted
time: 36ms
memory: 7264kb
input:
6 500 80534667
result:
ok accepted: cnt = 4683
Test #59:
score: 10
Accepted
time: 38ms
memory: 6788kb
input:
6 500 811975157
result:
ok accepted: cnt = 4331
Test #60:
score: 10
Accepted
time: 38ms
memory: 6628kb
input:
6 500 471392863
result:
ok accepted: cnt = 3935
Subtask #7:
score: 47.11
Acceptable Answer
Test #61:
score: 60
Accepted
time: 0ms
memory: 4132kb
input:
7 2 412859550
result:
ok accepted: cnt = 99
Test #62:
score: 60
Accepted
time: 0ms
memory: 3900kb
input:
7 4 892225546
result:
ok accepted: cnt = 155
Test #63:
score: 60
Accepted
time: 0ms
memory: 3848kb
input:
7 4 577686541
result:
ok accepted: cnt = 148
Test #64:
score: 60
Accepted
time: 132ms
memory: 7488kb
input:
7 902 974849567
result:
ok accepted: cnt = 9047
Test #65:
score: 60
Accepted
time: 130ms
memory: 7712kb
input:
7 939 155203710
result:
ok accepted: cnt = 8455
Test #66:
score: 49.5233
Acceptable Answer
time: 153ms
memory: 7904kb
input:
7 1000 253107507
result:
points 0.8253888889 partially_correct: cnt = 9643
Test #67:
score: 60
Accepted
time: 156ms
memory: 8192kb
input:
7 1000 882029420
result:
ok accepted: cnt = 9272
Test #68:
score: 48.83
Acceptable Answer
time: 148ms
memory: 7928kb
input:
7 1000 199421982
result:
points 0.8138333333 partially_correct: cnt = 9851
Test #69:
score: 60
Accepted
time: 164ms
memory: 7956kb
input:
7 1000 749220884
result:
ok accepted: cnt = 9132
Test #70:
score: 60
Accepted
time: 151ms
memory: 7840kb
input:
7 1000 729055050
result:
ok accepted: cnt = 9025
Test #71:
score: 60
Accepted
time: 0ms
memory: 3800kb
input:
7 2 375338281
result:
ok accepted: cnt = 102
Test #72:
score: 60
Accepted
time: 0ms
memory: 3792kb
input:
7 5 914443594
result:
ok accepted: cnt = 153
Test #73:
score: 60
Accepted
time: 0ms
memory: 3912kb
input:
7 5 310479620
result:
ok accepted: cnt = 159
Test #74:
score: 60
Accepted
time: 146ms
memory: 7764kb
input:
7 982 660842623
result:
ok accepted: cnt = 9020
Test #75:
score: 60
Accepted
time: 152ms
memory: 7776kb
input:
7 985 92435101
result:
ok accepted: cnt = 9428
Test #76:
score: 47.11
Acceptable Answer
time: 161ms
memory: 7892kb
input:
7 1000 901527471
result:
points 0.7851666667 partially_correct: cnt = 10367
Test #77:
score: 60
Accepted
time: 150ms
memory: 7960kb
input:
7 1000 891945482
result:
ok accepted: cnt = 9079
Test #78:
score: 49.0133
Acceptable Answer
time: 163ms
memory: 8092kb
input:
7 1000 461988571
result:
points 0.8168888889 partially_correct: cnt = 9796
Test #79:
score: 60
Accepted
time: 158ms
memory: 7896kb
input:
7 1000 588921486
result:
ok accepted: cnt = 9101
Test #80:
score: 49.8333
Acceptable Answer
time: 156ms
memory: 7864kb
input:
7 1000 819181186
result:
points 0.8305555556 partially_correct: cnt = 9550
Test #81:
score: 60
Accepted
time: 0ms
memory: 4120kb
input:
7 2 509390821
result:
ok accepted: cnt = 99
Test #82:
score: 60
Accepted
time: 0ms
memory: 4144kb
input:
7 3 932973010
result:
ok accepted: cnt = 147
Test #83:
score: 60
Accepted
time: 0ms
memory: 3872kb
input:
7 3 704198002
result:
ok accepted: cnt = 150
Test #84:
score: 48.41
Acceptable Answer
time: 153ms
memory: 8188kb
input:
7 996 844688748
result:
points 0.8068333333 partially_correct: cnt = 9977
Test #85:
score: 60
Accepted
time: 138ms
memory: 7692kb
input:
7 935 983758765
result:
ok accepted: cnt = 9071
Test #86:
score: 49.0333
Acceptable Answer
time: 161ms
memory: 8204kb
input:
7 1000 560957955
result:
points 0.8172222222 partially_correct: cnt = 9790
Test #87:
score: 60
Accepted
time: 148ms
memory: 7900kb
input:
7 1000 381616996
result:
ok accepted: cnt = 9456
Test #88:
score: 60
Accepted
time: 160ms
memory: 7888kb
input:
7 1000 607168013
result:
ok accepted: cnt = 9325
Test #89:
score: 60
Accepted
time: 143ms
memory: 7952kb
input:
7 1000 755432541
result:
ok accepted: cnt = 8780
Test #90:
score: 49.8
Acceptable Answer
time: 153ms
memory: 8188kb
input:
7 1000 675700852
result:
points 0.83 partially_correct: cnt = 9560
Test #91:
score: 60
Accepted
time: 0ms
memory: 3828kb
input:
7 2 91873452
result:
ok accepted: cnt = 99
Test #92:
score: 60
Accepted
time: 0ms
memory: 3908kb
input:
7 4 336570576
result:
ok accepted: cnt = 111
Test #93:
score: 60
Accepted
time: 0ms
memory: 3852kb
input:
7 4 617201184
result:
ok accepted: cnt = 132
Test #94:
score: 60
Accepted
time: 131ms
memory: 7492kb
input:
7 904 396880646
result:
ok accepted: cnt = 8421
Test #95:
score: 60
Accepted
time: 127ms
memory: 7536kb
input:
7 906 970970547
result:
ok accepted: cnt = 8626
Test #96:
score: 49.5667
Acceptable Answer
time: 153ms
memory: 8188kb
input:
7 1000 960558936
result:
points 0.8261111111 partially_correct: cnt = 9630
Test #97:
score: 60
Accepted
time: 160ms
memory: 8196kb
input:
7 1000 238446836
result:
ok accepted: cnt = 9027
Test #98:
score: 60
Accepted
time: 152ms
memory: 8188kb
input:
7 1000 897094536
result:
ok accepted: cnt = 9431
Test #99:
score: 49.84
Acceptable Answer
time: 150ms
memory: 7868kb
input:
7 1000 820891454
result:
points 0.8306666667 partially_correct: cnt = 9548
Test #100:
score: 49.24
Acceptable Answer
time: 149ms
memory: 8204kb
input:
7 1000 586475353
result:
points 0.8206666667 partially_correct: cnt = 9728