QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#561015 | #8952. 解谜游戏 | zhouhuanyi | 100 ✓ | 16ms | 8356kb | C++23 | 2.5kb | 2024-09-12 19:33:52 | 2024-09-12 19:33:53 |
Judging History
answer
#include "puzzle.h"
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<random>
#define N 1000
using namespace std;
struct reads
{
int x,y;
};
vector<reads>p[N+1];
int tn,n,length,tong[N+1],rd[N+1];
bool used[N+1];
unsigned long long seed=998244353;
vector<int>E[N+1];
unsigned long long get_rand()
{
seed^=(seed<<7);
seed^=(seed>>11);
seed^=(seed<<17);
return seed;
}
int get(int x)
{
if (x>tn) x-=tn;
if (x<1) x+=tn;
return x;
}
void add_edge(int x,int y)
{
E[x].push_back(y),E[y].push_back(x);
return;
}
void solve(vector<reads>sp,int res)
{
if (!res) return;
if (sp.size()==1)
{
for (int i=0;i<sp.size();++i) add_edge(sp[i].x,sp[i].y);
return;
}
vector<reads>A;
vector<reads>B;
int mid=sp.size()>>1,d;
vector<int>tp(n);
for (int i=1;i<=n;++i) tp[i-1]=rd[i];
for (int i=0;i<mid;++i) A.push_back(sp[i]),tp[sp[i].x-1]=rd[sp[i].y],tp[sp[i].y-1]=rd[sp[i].x];
for (int i=mid;i<sp.size();++i) B.push_back(sp[i]);
d=query(tp),solve(A,d),solve(B,res-d);
return;
}
void dfs(int x)
{
used[x]=1,tong[++length]=x;
for (int i=0;i<E[x].size();++i)
if (!used[E[x][i]])
dfs(E[x][i]);
return;
}
void play(int sn)
{
n=sn;
vector<reads>tp;
vector<int>sp(n);
vector<int>ans(n);
for (int i=0;i<n;++i) sp[i]=i;
while (1)
{
for (int i=1;i<=20*n;++i) swap(sp[get_rand()%n],sp[get_rand()%n]);
if (!query(sp)) break;
}
for (int i=1;i<=n;++i) rd[i]=sp[i-1];
if (!(n&1))
{
tn=n-1;
for (int i=1;i<=n-1;++i)
{
p[i].push_back((reads){i,n});
for (int j=1;j<=(n>>1)-1;++j) p[i].push_back((reads){get(i-j),get(i+j)});
}
}
else
{
tn=n;
for (int i=1;i<=n;++i)
for (int j=1;j<=(n>>1);++j)
p[i].push_back((reads){get(i-j),get(i+j)});
}
for (int i=1;i<=n;++i)
if (!p[i].empty())
{
tp.clear();
for (int j=0;j<p[i].size();++j)
if (E[p[i][j].x].size()<=1&&E[p[i][j].y].size()<=1)
tp.push_back(p[i][j]);
if (!tp.empty())
{
for (int j=1;j<=n;++j) sp[j-1]=rd[j];
for (int j=0;j<tp.size();++j) sp[tp[j].x-1]=rd[tp[j].y],sp[tp[j].y-1]=rd[tp[j].x];
solve(tp,query(sp));
}
}
for (int i=1;i<=n;++i)
if (!used[i])
{
length=0,dfs(i);
for (int j=1;j<=n;++j) sp[j-1]=rd[j];
for (int j=1;j<=length;++j) sp[tong[j]-1]=rd[tong[j%length+1]];
if (query(sp))
{
for (int j=1;j<=length;++j) ans[tong[j]-1]=rd[tong[j%length+1]];
}
else
{
for (int j=1;j<=length;++j) ans[tong[j%length+1]-1]=rd[tong[j]];
}
}
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: 4124kb
input:
1 2 816815200
result:
ok accepted: cnt = 4
Test #2:
score: 2
Accepted
time: 0ms
memory: 3856kb
input:
1 3 723182155
result:
ok accepted: cnt = 7
Test #3:
score: 2
Accepted
time: 0ms
memory: 3792kb
input:
1 5 971867682
result:
ok accepted: cnt = 17
Test #4:
score: 2
Accepted
time: 0ms
memory: 4020kb
input:
1 3 887042235
result:
ok accepted: cnt = 5
Test #5:
score: 2
Accepted
time: 0ms
memory: 3844kb
input:
1 3 568659743
result:
ok accepted: cnt = 7
Test #6:
score: 2
Accepted
time: 0ms
memory: 4120kb
input:
1 5 930991667
result:
ok accepted: cnt = 11
Test #7:
score: 2
Accepted
time: 0ms
memory: 3816kb
input:
1 5 185481439
result:
ok accepted: cnt = 10
Test #8:
score: 2
Accepted
time: 0ms
memory: 4116kb
input:
1 5 405685705
result:
ok accepted: cnt = 15
Test #9:
score: 2
Accepted
time: 0ms
memory: 4136kb
input:
1 5 693401039
result:
ok accepted: cnt = 11
Test #10:
score: 2
Accepted
time: 0ms
memory: 3888kb
input:
1 5 570594473
result:
ok accepted: cnt = 11
Subtask #2:
score: 4
Accepted
Test #11:
score: 4
Accepted
time: 0ms
memory: 3864kb
input:
2 2 931107645
result:
ok accepted: cnt = 4
Test #12:
score: 4
Accepted
time: 0ms
memory: 3836kb
input:
2 4 512124670
result:
ok accepted: cnt = 8
Test #13:
score: 4
Accepted
time: 0ms
memory: 3836kb
input:
2 4 793864173
result:
ok accepted: cnt = 14
Test #14:
score: 4
Accepted
time: 0ms
memory: 4132kb
input:
2 7 322910591
result:
ok accepted: cnt = 17
Test #15:
score: 4
Accepted
time: 0ms
memory: 3908kb
input:
2 9 316192686
result:
ok accepted: cnt = 20
Test #16:
score: 4
Accepted
time: 0ms
memory: 3828kb
input:
2 10 350886420
result:
ok accepted: cnt = 25
Test #17:
score: 4
Accepted
time: 0ms
memory: 4028kb
input:
2 10 914937911
result:
ok accepted: cnt = 24
Test #18:
score: 4
Accepted
time: 0ms
memory: 3860kb
input:
2 10 68729974
result:
ok accepted: cnt = 25
Test #19:
score: 4
Accepted
time: 0ms
memory: 3888kb
input:
2 10 15788440
result:
ok accepted: cnt = 25
Test #20:
score: 4
Accepted
time: 0ms
memory: 3832kb
input:
2 10 950846282
result:
ok accepted: cnt = 22
Subtask #3:
score: 6
Accepted
Test #21:
score: 6
Accepted
time: 0ms
memory: 3844kb
input:
3 2 667362636
result:
ok accepted: cnt = 3
Test #22:
score: 6
Accepted
time: 0ms
memory: 3884kb
input:
3 4 890842001
result:
ok accepted: cnt = 8
Test #23:
score: 6
Accepted
time: 0ms
memory: 3864kb
input:
3 3 225277415
result:
ok accepted: cnt = 5
Test #24:
score: 6
Accepted
time: 0ms
memory: 3892kb
input:
3 26 235413642
result:
ok accepted: cnt = 83
Test #25:
score: 6
Accepted
time: 0ms
memory: 4140kb
input:
3 25 139642984
result:
ok accepted: cnt = 83
Test #26:
score: 6
Accepted
time: 0ms
memory: 3824kb
input:
3 30 991911708
result:
ok accepted: cnt = 93
Test #27:
score: 6
Accepted
time: 0ms
memory: 3908kb
input:
3 30 4514256
result:
ok accepted: cnt = 102
Test #28:
score: 6
Accepted
time: 0ms
memory: 4128kb
input:
3 30 157113423
result:
ok accepted: cnt = 91
Test #29:
score: 6
Accepted
time: 0ms
memory: 3776kb
input:
3 30 557648974
result:
ok accepted: cnt = 100
Test #30:
score: 6
Accepted
time: 0ms
memory: 4028kb
input:
3 30 645022468
result:
ok accepted: cnt = 107
Test #31:
score: 6
Accepted
time: 0ms
memory: 4116kb
input:
4 2 427653480
result:
ok accepted: cnt = 3
Test #32:
score: 6
Accepted
time: 0ms
memory: 3832kb
input:
4 3 219860551
result:
ok accepted: cnt = 7
Test #33:
score: 6
Accepted
time: 0ms
memory: 4124kb
input:
4 4 165138325
result:
ok accepted: cnt = 6
Test #34:
score: 6
Accepted
time: 1ms
memory: 4180kb
input:
4 93 525060479
result:
ok accepted: cnt = 432
Test #35:
score: 6
Accepted
time: 1ms
memory: 3880kb
input:
4 99 829735778
result:
ok accepted: cnt = 444
Subtask #4:
score: 8
Accepted
Test #36:
score: 8
Accepted
time: 1ms
memory: 3880kb
input:
4 100 6610818
result:
ok accepted: cnt = 469
Test #37:
score: 8
Accepted
time: 1ms
memory: 3956kb
input:
4 100 653323659
result:
ok accepted: cnt = 474
Test #38:
score: 8
Accepted
time: 0ms
memory: 4096kb
input:
4 100 268513130
result:
ok accepted: cnt = 473
Test #39:
score: 8
Accepted
time: 0ms
memory: 3924kb
input:
4 100 479581529
result:
ok accepted: cnt = 475
Test #40:
score: 8
Accepted
time: 0ms
memory: 3892kb
input:
4 100 119844914
result:
ok accepted: cnt = 464
Subtask #5:
score: 10
Accepted
Test #41:
score: 10
Accepted
time: 0ms
memory: 3828kb
input:
5 2 527801655
result:
ok accepted: cnt = 4
Test #42:
score: 10
Accepted
time: 0ms
memory: 3904kb
input:
5 5 235665947
result:
ok accepted: cnt = 11
Test #43:
score: 10
Accepted
time: 0ms
memory: 3908kb
input:
5 3 648413779
result:
ok accepted: cnt = 5
Test #44:
score: 10
Accepted
time: 2ms
memory: 4440kb
input:
5 272 737778828
result:
ok accepted: cnt = 1591
Test #45:
score: 10
Accepted
time: 2ms
memory: 4756kb
input:
5 278 173436130
result:
ok accepted: cnt = 1654
Test #46:
score: 10
Accepted
time: 2ms
memory: 4812kb
input:
5 300 997862299
result:
ok accepted: cnt = 1757
Test #47:
score: 10
Accepted
time: 2ms
memory: 4824kb
input:
5 300 764271855
result:
ok accepted: cnt = 1803
Test #48:
score: 10
Accepted
time: 2ms
memory: 4516kb
input:
5 300 428892383
result:
ok accepted: cnt = 1802
Test #49:
score: 10
Accepted
time: 2ms
memory: 4508kb
input:
5 300 166706392
result:
ok accepted: cnt = 1793
Test #50:
score: 10
Accepted
time: 2ms
memory: 4576kb
input:
5 300 843444435
result:
ok accepted: cnt = 1794
Subtask #6:
score: 10
Accepted
Test #51:
score: 10
Accepted
time: 0ms
memory: 3840kb
input:
6 2 183795068
result:
ok accepted: cnt = 4
Test #52:
score: 10
Accepted
time: 0ms
memory: 3840kb
input:
6 5 63668012
result:
ok accepted: cnt = 19
Test #53:
score: 10
Accepted
time: 0ms
memory: 3820kb
input:
6 5 990398365
result:
ok accepted: cnt = 9
Test #54:
score: 10
Accepted
time: 4ms
memory: 5240kb
input:
6 488 942578687
result:
ok accepted: cnt = 3215
Test #55:
score: 10
Accepted
time: 4ms
memory: 4912kb
input:
6 475 915148470
result:
ok accepted: cnt = 3074
Test #56:
score: 10
Accepted
time: 5ms
memory: 4968kb
input:
6 500 736505651
result:
ok accepted: cnt = 3379
Test #57:
score: 10
Accepted
time: 2ms
memory: 4984kb
input:
6 500 352417213
result:
ok accepted: cnt = 3318
Test #58:
score: 10
Accepted
time: 2ms
memory: 5172kb
input:
6 500 80534667
result:
ok accepted: cnt = 3308
Test #59:
score: 10
Accepted
time: 5ms
memory: 5256kb
input:
6 500 811975157
result:
ok accepted: cnt = 3313
Test #60:
score: 10
Accepted
time: 5ms
memory: 4912kb
input:
6 500 471392863
result:
ok accepted: cnt = 3305
Subtask #7:
score: 60
Accepted
Test #61:
score: 60
Accepted
time: 0ms
memory: 3840kb
input:
7 2 412859550
result:
ok accepted: cnt = 4
Test #62:
score: 60
Accepted
time: 0ms
memory: 3832kb
input:
7 4 892225546
result:
ok accepted: cnt = 7
Test #63:
score: 60
Accepted
time: 0ms
memory: 3884kb
input:
7 4 577686541
result:
ok accepted: cnt = 9
Test #64:
score: 60
Accepted
time: 14ms
memory: 7652kb
input:
7 902 974849567
result:
ok accepted: cnt = 6701
Test #65:
score: 60
Accepted
time: 9ms
memory: 7868kb
input:
7 939 155203710
result:
ok accepted: cnt = 7003
Test #66:
score: 60
Accepted
time: 12ms
memory: 8352kb
input:
7 1000 253107507
result:
ok accepted: cnt = 7598
Test #67:
score: 60
Accepted
time: 16ms
memory: 8352kb
input:
7 1000 882029420
result:
ok accepted: cnt = 7647
Test #68:
score: 60
Accepted
time: 16ms
memory: 8112kb
input:
7 1000 199421982
result:
ok accepted: cnt = 7604
Test #69:
score: 60
Accepted
time: 16ms
memory: 8044kb
input:
7 1000 749220884
result:
ok accepted: cnt = 7624
Test #70:
score: 60
Accepted
time: 16ms
memory: 8048kb
input:
7 1000 729055050
result:
ok accepted: cnt = 7536
Test #71:
score: 60
Accepted
time: 0ms
memory: 3836kb
input:
7 2 375338281
result:
ok accepted: cnt = 3
Test #72:
score: 60
Accepted
time: 0ms
memory: 3900kb
input:
7 5 914443594
result:
ok accepted: cnt = 13
Test #73:
score: 60
Accepted
time: 0ms
memory: 3816kb
input:
7 5 310479620
result:
ok accepted: cnt = 15
Test #74:
score: 60
Accepted
time: 16ms
memory: 8036kb
input:
7 982 660842623
result:
ok accepted: cnt = 7445
Test #75:
score: 60
Accepted
time: 12ms
memory: 7984kb
input:
7 985 92435101
result:
ok accepted: cnt = 7438
Test #76:
score: 60
Accepted
time: 16ms
memory: 8116kb
input:
7 1000 901527471
result:
ok accepted: cnt = 7589
Test #77:
score: 60
Accepted
time: 16ms
memory: 8356kb
input:
7 1000 891945482
result:
ok accepted: cnt = 7578
Test #78:
score: 60
Accepted
time: 16ms
memory: 8060kb
input:
7 1000 461988571
result:
ok accepted: cnt = 7567
Test #79:
score: 60
Accepted
time: 12ms
memory: 8064kb
input:
7 1000 588921486
result:
ok accepted: cnt = 7581
Test #80:
score: 60
Accepted
time: 16ms
memory: 8340kb
input:
7 1000 819181186
result:
ok accepted: cnt = 7556
Test #81:
score: 60
Accepted
time: 0ms
memory: 3788kb
input:
7 2 509390821
result:
ok accepted: cnt = 4
Test #82:
score: 60
Accepted
time: 0ms
memory: 3820kb
input:
7 3 932973010
result:
ok accepted: cnt = 6
Test #83:
score: 60
Accepted
time: 0ms
memory: 4024kb
input:
7 3 704198002
result:
ok accepted: cnt = 7
Test #84:
score: 60
Accepted
time: 16ms
memory: 8116kb
input:
7 996 844688748
result:
ok accepted: cnt = 7504
Test #85:
score: 60
Accepted
time: 9ms
memory: 8076kb
input:
7 935 983758765
result:
ok accepted: cnt = 6931
Test #86:
score: 60
Accepted
time: 12ms
memory: 8132kb
input:
7 1000 560957955
result:
ok accepted: cnt = 7562
Test #87:
score: 60
Accepted
time: 12ms
memory: 8072kb
input:
7 1000 381616996
result:
ok accepted: cnt = 7614
Test #88:
score: 60
Accepted
time: 12ms
memory: 8056kb
input:
7 1000 607168013
result:
ok accepted: cnt = 7600
Test #89:
score: 60
Accepted
time: 16ms
memory: 8044kb
input:
7 1000 755432541
result:
ok accepted: cnt = 7553
Test #90:
score: 60
Accepted
time: 16ms
memory: 8056kb
input:
7 1000 675700852
result:
ok accepted: cnt = 7596
Test #91:
score: 60
Accepted
time: 0ms
memory: 3788kb
input:
7 2 91873452
result:
ok accepted: cnt = 4
Test #92:
score: 60
Accepted
time: 0ms
memory: 4024kb
input:
7 4 336570576
result:
ok accepted: cnt = 7
Test #93:
score: 60
Accepted
time: 0ms
memory: 3828kb
input:
7 4 617201184
result:
ok accepted: cnt = 8
Test #94:
score: 60
Accepted
time: 13ms
memory: 7840kb
input:
7 904 396880646
result:
ok accepted: cnt = 6717
Test #95:
score: 60
Accepted
time: 11ms
memory: 7956kb
input:
7 906 970970547
result:
ok accepted: cnt = 6828
Test #96:
score: 60
Accepted
time: 16ms
memory: 8016kb
input:
7 1000 960558936
result:
ok accepted: cnt = 7546
Test #97:
score: 60
Accepted
time: 12ms
memory: 8344kb
input:
7 1000 238446836
result:
ok accepted: cnt = 7656
Test #98:
score: 60
Accepted
time: 16ms
memory: 8356kb
input:
7 1000 897094536
result:
ok accepted: cnt = 7617
Test #99:
score: 60
Accepted
time: 12ms
memory: 7984kb
input:
7 1000 820891454
result:
ok accepted: cnt = 7581
Test #100:
score: 60
Accepted
time: 16ms
memory: 8140kb
input:
7 1000 586475353
result:
ok accepted: cnt = 7601