QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#700655 | #9519. Build a Computer | Forever_Young# | AC ✓ | 0ms | 3996kb | C++23 | 2.0kb | 2024-11-02 13:16:11 | 2024-11-02 13:16:20 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define data dataa
using LL=long long;
using ULL=unsigned long long;
using LD=long double;
int id[25],idl[25],idr[25],L,R,l[25],r[25],tot,mxid;
vector<pair<int,int>>g[110];
void print()
{
printf("%d\n",tot);
rep(i,tot)
{
printf("%d",int(g[i].size()));
for(auto [x,y]:g[i])printf(" %d %d",x,y);
puts("");
}
}
void add(int x,int y,int z){g[x].pb(mp(y,z));}
int getid(int dep)
{
for(;mxid<dep;)
{
id[++mxid]=++tot;
add(id[mxid],id[mxid-1],0);
add(id[mxid],id[mxid-1],1);
}
return id[dep];
}
void work(int num[],int id[],int pos,int flag)
{
for(int i=pos;i>1;i--)
{
if(num[i-1]!=flag)continue;
add(id[i],getid(i-2),!flag);
}
}
// map<int,int>s;
// void dfs(int p,int now)
// {
// if(g[p].size()==0)s[now]++;
// for(auto [x,y]:g[p])dfs(x,(now<<1)|y);
// }
int main()
{
scanf("%d%d",&L,&R);
int S=1,T=2;
id[0]=2;mxid=0;
tot=2;
int lenl=0,lenr=0;
for(int x=L;x;x>>=1)l[++lenl]=x&1;
for(int x=R;x;x>>=1)r[++lenr]=x&1;
int last=S;
for(int i=lenl;i>1;i--)
{
idl[i]=++tot;
add(last,idl[i],l[i]);
last=idl[i];
}
add(last,T,l[1]);
if(L==R){print();return 0;}
last=S;
for(int i=lenr;i>1;i--)
{
idr[i]=++tot;
add(last,idr[i],r[i]);
last=idr[i];
}
add(last,T,r[1]);
if(lenl!=lenr)
{
work(l,idl,lenl,0),work(r,idr,lenr,1);
for(int i=lenl+1;i<lenr;i++)
{
add(S,getid(i-1),1);
}
}
else
{
int pos=lenl;
for(;l[pos]==r[pos];pos--);
work(l,idl,pos,0);work(r,idr,pos,1);
}
print();
// dfs(1,0);
// for(int i=L;i<=R;i++)
// {
// if(s[i]!=1)printf("%d %d\n",i,s[i]);
// assert(s[i]==1);
// }
return 0;
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3932kb
input:
5 7
output:
6 2 3 1 5 1 0 1 4 0 1 2 1 1 6 1 2 2 1 2 0
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3936kb
input:
10 27
output:
12 2 3 1 6 1 0 2 4 0 11 1 1 5 1 2 2 0 2 1 2 7 1 12 0 1 8 0 2 9 1 10 0 2 2 1 2 0 2 2 0 2 1 2 10 0 10 1 2 11 0 11 1
result:
ok ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
5 13
output:
9 2 3 1 5 1 0 2 4 0 8 1 1 2 1 2 6 1 9 0 1 7 0 2 2 1 2 0 2 2 0 2 1 2 8 0 8 1
result:
ok ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3848kb
input:
1 1000000
output:
39 20 2 1 3 1 22 1 23 1 24 1 25 1 26 1 27 1 28 1 29 1 30 1 31 1 32 1 33 1 34 1 35 1 36 1 37 1 38 1 39 1 0 2 4 1 39 0 2 5 1 38 0 2 6 1 37 0 1 7 0 2 8 1 35 0 1 9 0 1 10 0 1 11 0 1 12 0 2 13 1 30 0 1 14 0 1 15 0 2 16 1 27 0 1 17 0 1 18 0 1 19 0 1 20 0 1 21 0 1 2 0 2 2 0 2 1 2 22 0 22 1 2 23 0 23 1 2 24...
result:
ok ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3840kb
input:
1 1
output:
2 1 2 1 0
result:
ok ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3948kb
input:
7 9
output:
7 2 3 1 5 1 0 1 4 1 1 2 1 1 6 0 1 7 0 2 2 1 2 0
result:
ok ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
3 7
output:
6 2 3 1 4 1 0 1 2 1 2 5 1 6 0 2 2 1 2 0 2 2 0 2 1
result:
ok ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
1 5
output:
5 3 2 1 3 1 5 1 0 1 4 0 2 2 1 2 0 2 2 0 2 1
result:
ok ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 3996kb
input:
1 4
output:
5 3 2 1 3 1 5 1 0 1 4 0 1 2 0 2 2 0 2 1
result:
ok ok
Test #10:
score: 0
Accepted
time: 0ms
memory: 3900kb
input:
8 9
output:
8 2 3 1 6 1 0 1 4 0 1 5 0 1 2 0 1 7 0 1 8 0 1 2 1
result:
ok ok
Test #11:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
7 51
output:
13 4 3 1 5 1 12 1 13 1 0 1 4 1 1 2 1 2 6 1 13 0 1 7 0 1 8 0 2 9 1 10 0 2 2 1 2 0 2 2 0 2 1 2 10 0 10 1 2 11 0 11 1 2 12 0 12 1
result:
ok ok
Test #12:
score: 0
Accepted
time: 0ms
memory: 3980kb
input:
51 79
output:
16 2 3 1 8 1 0 1 4 1 2 5 0 16 1 2 6 0 15 1 1 7 1 1 2 1 1 9 0 1 10 0 2 11 1 16 0 2 12 1 15 0 2 13 1 14 0 2 2 1 2 0 2 2 0 2 1 2 14 0 14 1 2 15 0 15 1
result:
ok ok
Test #13:
score: 0
Accepted
time: 0ms
memory: 3932kb
input:
92 99
output:
15 2 3 1 9 1 0 1 4 0 1 5 1 1 6 1 1 7 1 2 8 0 15 1 2 2 0 2 1 1 10 1 1 11 0 1 12 0 1 13 0 2 14 1 15 0 2 2 1 2 0 2 2 0 2 1
result:
ok ok
Test #14:
score: 0
Accepted
time: 0ms
memory: 3932kb
input:
27 36
output:
13 2 3 1 7 1 0 1 4 1 2 5 0 13 1 1 6 1 1 2 1 1 8 0 1 9 0 2 10 1 13 0 1 11 0 1 2 0 2 2 0 2 1 2 12 0 12 1
result:
ok ok
Test #15:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
55 84
output:
17 2 3 1 8 1 0 1 4 1 2 5 0 16 1 1 6 1 1 7 1 1 2 1 1 9 0 2 10 1 17 0 1 11 0 2 12 1 15 0 1 13 0 1 2 0 2 2 0 2 1 2 14 0 14 1 2 15 0 15 1 2 16 0 16 1
result:
ok ok
Test #16:
score: 0
Accepted
time: 0ms
memory: 3920kb
input:
297208 929600
output:
57 2 3 1 21 1 0 2 4 0 56 1 2 5 0 55 1 1 6 1 2 7 0 53 1 2 8 0 52 1 2 9 0 51 1 1 10 1 2 11 0 49 1 2 12 0 48 1 2 13 0 47 1 1 14 1 1 15 1 1 16 1 1 17 1 1 18 1 2 19 0 41 1 2 20 0 40 1 2 2 0 2 1 2 22 1 57 0 2 23 1 56 0 1 24 0 1 25 0 1 26 0 2 27 1 52 0 1 28 0 2 29 1 50 0 2 30 1 49 0 2 31 1 48 0 2 32 1 47 0...
result:
ok ok
Test #17:
score: 0
Accepted
time: 0ms
memory: 3844kb
input:
45728 589156
output:
54 5 3 1 18 1 52 1 53 1 54 1 0 2 4 0 50 1 1 5 1 1 6 1 2 7 0 47 1 2 8 0 46 1 1 9 1 2 10 0 44 1 1 11 1 2 12 0 42 1 1 13 1 2 14 0 40 1 2 15 0 39 1 2 16 0 38 1 2 17 0 37 1 2 2 0 2 1 1 19 0 1 20 0 1 21 0 2 22 1 51 0 2 23 1 50 0 2 24 1 49 0 2 25 1 48 0 2 26 1 47 0 2 27 1 46 0 1 28 0 2 29 1 44 0 1 30 0 2 3...
result:
ok ok
Test #18:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
129152 138000
output:
47 2 3 1 19 1 0 1 4 1 1 5 1 1 6 1 1 7 1 1 8 1 2 9 0 45 1 2 10 0 44 1 2 11 0 43 1 1 12 1 2 13 0 41 1 2 14 0 40 1 2 15 0 39 1 2 16 0 38 1 2 17 0 37 1 2 18 0 36 1 2 2 0 2 1 1 20 0 1 21 0 1 22 0 1 23 0 2 24 1 47 0 2 25 1 46 0 1 26 0 2 27 1 44 0 2 28 1 43 0 1 29 0 1 30 0 1 31 0 2 32 1 39 0 1 33 0 1 34 0 ...
result:
ok ok
Test #19:
score: 0
Accepted
time: 0ms
memory: 3916kb
input:
245280 654141
output:
56 3 3 1 20 1 56 1 0 1 4 1 1 5 1 2 6 0 52 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 2 12 0 46 1 2 13 0 45 1 2 14 0 44 1 1 15 1 2 16 0 42 1 2 17 0 41 1 2 18 0 40 1 2 19 0 39 1 2 2 0 2 1 1 21 0 1 22 0 2 23 1 54 0 2 24 1 53 0 2 25 1 52 0 2 26 1 51 0 2 27 1 50 0 2 28 1 49 0 1 29 0 2 30 1 47 0 2 31 1 46 0 1 32 0...
result:
ok ok
Test #20:
score: 0
Accepted
time: 0ms
memory: 3852kb
input:
202985 296000
output:
52 2 3 1 20 1 0 1 4 1 2 5 0 52 1 2 6 0 51 1 2 7 0 50 1 1 8 1 1 9 1 2 10 0 47 1 2 11 0 46 1 2 12 0 45 1 1 13 1 1 14 1 1 15 1 2 16 0 41 1 1 17 1 2 18 0 39 1 2 19 0 38 1 1 2 1 1 21 0 1 22 0 2 23 1 52 0 1 24 0 1 25 0 1 26 0 1 27 0 2 28 1 47 0 1 29 0 1 30 0 1 31 0 2 32 1 43 0 1 33 0 1 34 0 1 35 0 1 36 0 ...
result:
ok ok
Test #21:
score: 0
Accepted
time: 0ms
memory: 3928kb
input:
438671 951305
output:
57 2 3 1 21 1 0 1 4 1 2 5 0 55 1 1 6 1 2 7 0 53 1 1 8 1 1 9 1 2 10 0 50 1 2 11 0 49 1 2 12 0 48 1 1 13 1 1 14 1 2 15 0 45 1 2 16 0 44 1 2 17 0 43 1 1 18 1 1 19 1 1 20 1 1 2 1 2 22 1 57 0 2 23 1 56 0 1 24 0 2 25 1 54 0 1 26 0 1 27 0 1 28 0 1 29 0 2 30 1 49 0 1 31 0 1 32 0 1 33 0 1 34 0 1 35 0 1 36 0 ...
result:
ok ok
Test #22:
score: 0
Accepted
time: 0ms
memory: 3976kb
input:
425249 739633
output:
56 2 3 1 21 1 0 1 4 1 2 5 0 55 1 2 6 0 54 1 1 7 1 1 8 1 1 9 1 1 10 1 1 11 1 2 12 0 48 1 1 13 1 2 14 0 46 1 2 15 0 45 1 1 16 1 2 17 0 43 1 2 18 0 42 1 2 19 0 41 1 2 20 0 40 1 1 2 1 1 22 0 2 23 1 56 0 2 24 1 55 0 1 25 0 2 26 1 53 0 1 27 0 1 28 0 2 29 1 50 0 1 30 0 1 31 0 2 32 1 47 0 1 33 0 1 34 0 2 35...
result:
ok ok
Test #23:
score: 0
Accepted
time: 0ms
memory: 3908kb
input:
551207 961718
output:
57 2 3 1 22 1 0 1 4 0 2 5 0 57 1 2 6 0 56 1 2 7 0 55 1 1 8 1 1 9 1 2 10 0 52 1 1 11 1 2 12 0 50 1 2 13 0 49 1 1 14 1 2 15 0 47 1 2 16 0 46 1 1 17 1 2 18 0 44 1 2 19 0 43 1 1 20 1 1 21 1 1 2 1 1 23 1 2 24 1 57 0 1 25 0 2 26 1 55 0 1 27 0 2 28 1 53 0 1 29 0 2 30 1 51 0 2 31 1 50 0 1 32 0 1 33 0 2 34 1...
result:
ok ok
Test #24:
score: 0
Accepted
time: 0ms
memory: 3768kb
input:
114691 598186
output:
55 4 3 1 19 1 54 1 55 1 0 1 4 1 1 5 1 2 6 0 50 1 2 7 0 49 1 2 8 0 48 1 2 9 0 47 1 2 10 0 46 1 2 11 0 45 1 2 12 0 44 1 2 13 0 43 1 2 14 0 42 1 2 15 0 41 1 2 16 0 40 1 2 17 0 39 1 1 18 1 1 2 1 1 20 0 1 21 0 2 22 1 53 0 1 23 0 1 24 0 2 25 1 50 0 1 26 0 1 27 0 1 28 0 1 29 0 1 30 0 2 31 1 44 0 1 32 0 2 3...
result:
ok ok
Test #25:
score: 0
Accepted
time: 0ms
memory: 3928kb
input:
234654 253129
output:
49 2 3 1 20 1 0 1 4 1 1 5 1 1 6 0 2 7 0 49 1 1 8 1 2 9 0 47 1 1 10 1 2 11 0 45 1 2 12 0 44 1 1 13 1 2 14 0 42 1 2 15 0 41 1 1 16 1 1 17 1 1 18 1 1 19 1 2 2 0 2 1 1 21 1 1 22 1 1 23 1 1 24 0 2 25 1 48 0 2 26 1 47 0 2 27 1 46 0 1 28 0 1 29 0 2 30 1 43 0 2 31 1 42 0 1 32 0 1 33 0 2 34 1 39 0 1 35 0 1 3...
result:
ok ok
Test #26:
score: 0
Accepted
time: 0ms
memory: 3932kb
input:
554090 608599
output:
55 2 3 1 22 1 0 1 4 0 1 5 0 1 6 0 2 7 0 55 1 1 8 1 1 9 1 1 10 1 2 11 0 51 1 1 12 1 2 13 0 49 1 2 14 0 48 1 2 15 0 47 1 1 16 1 1 17 1 2 18 0 44 1 1 19 1 2 20 0 42 1 1 21 1 2 2 0 2 1 1 23 0 1 24 0 1 25 1 1 26 0 2 27 1 54 0 1 28 0 1 29 0 2 30 1 51 0 1 31 0 1 32 0 2 33 1 48 0 1 34 0 2 35 1 46 0 1 36 0 2...
result:
ok ok
Extra Test:
score: 0
Extra Test Passed