QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#115763 | #5033. Y 君的序列 | lgvc | 0 | 2ms | 7424kb | C++23 | 1.4kb | 2023-06-26 19:45:36 | 2023-06-26 19:45:39 |
Judging History
answer
#include <bits/stdc++.h>
#include "seq.h"
int pa[100009],p[100009],iv[100009],A[100009],B[100009],nxt[100009],to[100009],dep[100009],hd[100009],k;
inline void l(int u,int v) {nxt[++k]=hd[u],to[k]=v,hd[u]=k;}
inline bool chk(int a,int b,int m,int n) {
if(m!=-1&&(a==2*b||b==2*a)) {
if(a==2*b) add(m,n);else add(n,m);
return 1;
}
assert((a+b)%2);
int bb=b,st=0;
while(1) {
int x;
if(a%2==0) x=-a/2;else x=b/2;
if(m!=-1) {
if(x<0) add(m,n);else add(n,m);
}
a+=x;b-=x;
if(a==bb) return 1;
if(b==bb) return 0;
}
}
void swp(int a,int b) {
int m=0,n=0;
while(dep[a]>dep[b]) {
A[++m]=a;
a=pa[a];
}
while(dep[a]<dep[b]) {
B[++n]=b;
b=pa[b];
}
while(a!=b) {
A[++m]=a;
B[++n]=b;
a=pa[a];
b=pa[b];
}
A[++m]=a;
for(int i=n;i>=1;i--) A[++m]=B[i];
for(int i=1;i<m;i++) {
chk(A[i],A[i+1],iv[A[1]],iv[A[i+1]]);
}
for(int i=m-1;i>=2;i--) {
chk(A[i],A[i-1],iv[A[m]],iv[A[i]]);
}
std::swap(p[iv[A[1]]],p[iv[A[m]]]);
std::swap(iv[A[1]],iv[A[m]]);
}
void dfs(int n) {
for(int i=hd[n];i;i=nxt[i]) {
dep[to[i]]=dep[n]+1;
dfs(to[i]);
}
}
void SEQ(int n,int M) {
answer(1);
for(int i=2;i<=n;i+=2) {
int as=0;
int st=1;
while(st+1<=i) st*=2;
pa[i]=st+1-i;
}
for(int i=2;i<=n;i++) l(pa[i],i);
dfs(1);
for(int i=1;i<=n;i++) {
p[i]=i;
iv[i]=i;
}
for(int i=1;i<=n;i++) {
if(p[i]==Get(i)) continue;
swp(p[i],Get(i));
}
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 17
Accepted
time: 2ms
memory: 7424kb
input:
1 10000000 1
output:
Correct Answer :) Congrats!
result:
ok 4 tokens
Test #2:
score: -17
Wrong Answer
time: 1ms
memory: 5512kb
input:
8 10000000 7 6 5 2 8 1 4 3
output:
Invalid operation
result:
wrong answer 1st words differ - expected: 'Correct', found: 'Invalid'
Subtask #2:
score: 0
Wrong Answer
Test #21:
score: 0
Wrong Answer
time: 1ms
memory: 5576kb
input:
121 1500000 121 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98...
output:
Invalid operation
result:
wrong answer 1st words differ - expected: 'Correct', found: 'Invalid'
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 0
Skipped
Dependency #3:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%
Subtask #6:
score: 0
Skipped
Dependency #5:
0%