QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#699076 | #9519. Build a Computer | Nuj | AC ✓ | 0ms | 3724kb | C++14 | 1.6kb | 2024-11-02 00:41:37 | 2024-11-02 00:41:38 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
#define eb emplace_back
#define sz(x) (int)x.size()
#define dbg(x) cerr<<"In Line "<<__LINE__<<' '<<#x<<" = "<<(x)<<endl
vector<pair<int,bool>> edge[105];
int node[20];
int main(){
int l,r,i;cin>>l>>r;
int n=1,nowl,nowr;
bool yes=0,no=1;
for(i=19;~l>>i&1&&~r>>i&1;i--);
for(;~i;i--){
if((l^r)>>i&1||yes){
if(!yes){
if(!i){
edge[n].eb(n+1,0);
edge[n].eb(n+1,1);
n++;
}
else{
int tmp=n;
if(n^1) nowl=++n,edge[tmp].eb(nowl,0);else nowl=1;
nowr=++n,edge[tmp].eb(nowr,1);
}
yes=1;
}
else{
int tmpl=nowl,tmpr=nowr;
if(!i){
if(no) *node=++n,no=0;
if(l&1||nowl^1) edge[nowl].eb(*node,l&1);
edge[nowr].eb(*node,r&1);
}
else{
if(l>>i&1||nowl^1) edge[nowl].eb(++n,l>>i&1),tmpl=n;
edge[nowr].eb(++n,r>>i&1),tmpr=n;
}
if(~l>>i&1){
if(no){
no=0;
for(int j=0;j<=i;j++) node[j]=++n;
for(int j=0;j<i;j++){
edge[node[j+1]].eb(node[j],0);
edge[node[j+1]].eb(node[j],1);
}
}
edge[nowl].eb(node[i],1);
}
if(r>>i&1){
if(no){
no=0;
for(int j=0;j<=i;j++) node[j]=++n;
for(int j=0;j<i;j++){
edge[node[j+1]].eb(node[j],0);
edge[node[j+1]].eb(node[j],1);
}
}
edge[nowr].eb(node[i],0);
}
nowl=tmpl,nowr=tmpr;
}
}
else edge[n].eb(n+1,l>>i&1),n++;
}
cout<<n<<endl;
for(int i=1;i<=n;i++){
cout<<sz(edge[i])<<' ';
for(auto j:edge[i]) cout<<j.first<<' '<<j.second<<' ';cout<<endl;
}
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3660kb
input:
5 7
output:
5 1 2 1 2 3 0 4 1 1 5 1 2 5 1 5 0 0
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
10 27
output:
12 2 2 1 3 1 2 4 1 8 0 2 9 0 7 1 1 10 0 0 2 5 0 5 1 2 6 0 6 1 2 7 0 7 1 1 11 1 2 12 1 6 0 2 5 0 5 1 2 5 1 5 0
result:
ok ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
5 13
output:
9 2 2 1 3 1 2 4 1 7 0 2 8 0 6 1 1 9 0 0 2 5 0 5 1 2 6 0 6 1 1 5 1 2 5 1 5 0
result:
ok ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3668kb
input:
1 1000000
output:
39 20 2 1 22 1 21 1 20 1 19 1 18 1 17 1 16 1 15 1 14 1 13 1 12 1 11 1 10 1 9 1 8 1 7 1 6 1 5 1 4 1 2 3 1 22 0 2 23 1 21 0 0 2 4 0 4 1 2 5 0 5 1 2 6 0 6 1 2 7 0 7 1 2 8 0 8 1 2 9 0 9 1 2 10 0 10 1 2 11 0 11 1 2 12 0 12 1 2 13 0 13 1 2 14 0 14 1 2 15 0 15 1 2 16 0 16 1 2 17 0 17 1 2 ...
result:
ok ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
1 1
output:
2 1 2 1 0
result:
ok ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
7 9
output:
7 2 2 1 3 1 1 4 0 1 5 1 1 6 0 1 7 1 2 7 1 7 0 0
result:
ok ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
3 7
output:
6 2 2 1 3 1 2 4 1 6 0 1 5 1 2 5 1 5 0 0 2 5 0 5 1
result:
ok ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 3720kb
input:
1 5
output:
5 3 2 1 5 1 4 1 1 3 0 2 4 1 4 0 0 2 4 0 4 1
result:
ok ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 3672kb
input:
1 4
output:
5 3 2 1 5 1 4 1 1 3 0 1 4 0 0 2 4 0 4 1
result:
ok ok
Test #10:
score: 0
Accepted
time: 0ms
memory: 3708kb
input:
8 9
output:
5 1 2 1 1 3 0 1 4 0 2 5 0 5 1 0
result:
ok ok
Test #11:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
7 51
output:
13 4 2 1 8 1 7 1 10 1 2 3 1 8 0 1 9 0 0 2 4 0 4 1 2 5 0 5 1 2 6 0 6 1 2 7 0 7 1 1 11 0 1 12 1 2 13 1 5 0 1 4 1 2 4 1 4 0
result:
ok ok
Test #12:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
51 79
output:
16 2 2 1 3 1 1 4 0 1 5 1 1 6 0 2 7 0 12 1 2 8 1 12 0 2 13 0 11 1 2 14 1 11 0 0 2 9 0 9 1 2 10 0 10 1 2 11 0 11 1 1 15 1 2 16 1 10 0 1 9 1 2 9 1 9 0
result:
ok ok
Test #13:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
92 99
output:
14 1 2 1 2 3 0 4 1 1 5 1 1 6 0 1 7 1 1 8 0 1 9 1 1 10 0 2 11 0 14 1 2 12 1 14 0 2 13 0 13 1 2 13 1 13 0 0 2 13 0 13 1
result:
ok ok
Test #14:
score: 0
Accepted
time: 0ms
memory: 3648kb
input:
27 36
output:
13 2 2 1 3 1 1 4 0 1 5 1 1 6 0 2 7 0 11 1 2 8 1 11 0 1 12 1 1 13 0 0 2 9 0 9 1 2 10 0 10 1 1 9 1 1 9 0
result:
ok ok
Test #15:
score: 0
Accepted
time: 0ms
memory: 3644kb
input:
55 84
output:
17 2 2 1 3 1 1 4 0 1 5 1 2 6 1 11 0 2 12 0 10 1 1 13 0 0 2 7 0 7 1 2 8 0 8 1 2 9 0 9 1 2 10 0 10 1 1 14 1 2 15 1 9 0 1 16 1 1 17 0 1 7 1 1 7 0
result:
ok ok
Test #16:
score: 0
Accepted
time: 0ms
memory: 3592kb
input:
297208 929600
output:
57 2 2 1 3 1 2 4 1 23 0 2 24 0 22 1 2 25 1 22 0 0 2 5 0 5 1 2 6 0 6 1 2 7 0 7 1 2 8 0 8 1 2 9 0 9 1 2 10 0 10 1 2 11 0 11 1 2 12 0 12 1 2 13 0 13 1 2 14 0 14 1 2 15 0 15 1 2 16 0 16 1 2 17 0 17 1 2 18 0 18 1 2 19 0 19 1 2 20 0 20 1 2 21 0 21 1 2 22 0 22 1 2 26 0 21 1 1 27 0 ...
result:
ok ok
Test #17:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
45728 589156
output:
54 5 2 1 22 1 21 1 20 1 25 1 1 3 0 1 23 0 0 2 4 0 4 1 2 5 0 5 1 2 6 0 6 1 2 7 0 7 1 2 8 0 8 1 2 9 0 9 1 2 10 0 10 1 2 11 0 11 1 2 12 0 12 1 2 13 0 13 1 2 14 0 14 1 2 15 0 15 1 2 16 0 16 1 2 17 0 17 1 2 18 0 18 1 2 19 0 19 1 2 20 0 20 1 2 21 0 21 1 1 24 0 2 26 1 19 0 2 27 0 18...
result:
ok ok
Test #18:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
129152 138000
output:
47 2 2 1 3 1 1 4 0 1 5 1 1 6 0 1 7 1 1 8 0 1 9 1 1 10 0 1 11 1 2 12 1 25 0 1 26 1 2 27 1 24 0 0 2 13 0 13 1 2 14 0 14 1 2 15 0 15 1 2 16 0 16 1 2 17 0 17 1 2 18 0 18 1 2 19 0 19 1 2 20 0 20 1 2 21 0 21 1 2 22 0 22 1 2 23 0 23 1 2 24 0 24 1 2 28 0 23 1 1 29 0 2 30 0 22 1 2...
result:
ok ok
Test #19:
score: 0
Accepted
time: 0ms
memory: 3652kb
input:
245280 654141
output:
56 3 2 1 22 1 23 1 1 3 0 1 24 0 0 2 4 0 4 1 2 5 0 5 1 2 6 0 6 1 2 7 0 7 1 2 8 0 8 1 2 9 0 9 1 2 10 0 10 1 2 11 0 11 1 2 12 0 12 1 2 13 0 13 1 2 14 0 14 1 2 15 0 15 1 2 16 0 16 1 2 17 0 17 1 2 18 0 18 1 2 19 0 19 1 2 20 0 20 1 2 21 0 21 1 1 25 1 2 26 1 20 0 1 27 1 2 28 1 19 0...
result:
ok ok
Test #20:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
202985 296000
output:
52 2 2 1 3 1 1 4 0 1 5 1 1 6 0 2 7 0 24 1 2 8 1 24 0 2 25 0 23 1 1 26 0 0 2 9 0 9 1 2 10 0 10 1 2 11 0 11 1 2 12 0 12 1 2 13 0 13 1 2 14 0 14 1 2 15 0 15 1 2 16 0 16 1 2 17 0 17 1 2 18 0 18 1 2 19 0 19 1 2 20 0 20 1 2 21 0 21 1 2 22 0 22 1 2 23 0 23 1 2 27 0 22 1 1 28 0 1 2...
result:
ok ok
Test #21:
score: 0
Accepted
time: 0ms
memory: 3716kb
input:
438671 951305
output:
57 2 2 1 3 1 2 4 1 23 0 1 24 1 2 25 1 22 0 0 2 5 0 5 1 2 6 0 6 1 2 7 0 7 1 2 8 0 8 1 2 9 0 9 1 2 10 0 10 1 2 11 0 11 1 2 12 0 12 1 2 13 0 13 1 2 14 0 14 1 2 15 0 15 1 2 16 0 16 1 2 17 0 17 1 2 18 0 18 1 2 19 0 19 1 2 20 0 20 1 2 21 0 21 1 2 22 0 22 1 2 26 0 21 1 1 27 0 1 28 ...
result:
ok ok
Test #22:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
425249 739633
output:
56 2 2 1 3 1 1 4 0 1 5 1 2 6 1 24 0 2 25 0 23 1 2 26 1 23 0 0 2 7 0 7 1 2 8 0 8 1 2 9 0 9 1 2 10 0 10 1 2 11 0 11 1 2 12 0 12 1 2 13 0 13 1 2 14 0 14 1 2 15 0 15 1 2 16 0 16 1 2 17 0 17 1 2 18 0 18 1 2 19 0 19 1 2 20 0 20 1 2 21 0 21 1 2 22 0 22 1 2 23 0 23 1 2 27 0 22 1 1 2...
result:
ok ok
Test #23:
score: 0
Accepted
time: 0ms
memory: 3724kb
input:
551207 961718
output:
56 1 2 1 2 3 0 4 1 2 5 0 24 1 2 6 1 24 0 2 25 0 23 1 1 26 0 0 2 7 0 7 1 2 8 0 8 1 2 9 0 9 1 2 10 0 10 1 2 11 0 11 1 2 12 0 12 1 2 13 0 13 1 2 14 0 14 1 2 15 0 15 1 2 16 0 16 1 2 17 0 17 1 2 18 0 18 1 2 19 0 19 1 2 20 0 20 1 2 21 0 21 1 2 22 0 22 1 2 23 0 23 1 2 27 0 22 1 2 2...
result:
ok ok
Test #24:
score: 0
Accepted
time: 0ms
memory: 3656kb
input:
114691 598186
output:
55 4 2 1 22 1 21 1 24 1 1 3 0 1 23 0 0 2 4 0 4 1 2 5 0 5 1 2 6 0 6 1 2 7 0 7 1 2 8 0 8 1 2 9 0 9 1 2 10 0 10 1 2 11 0 11 1 2 12 0 12 1 2 13 0 13 1 2 14 0 14 1 2 15 0 15 1 2 16 0 16 1 2 17 0 17 1 2 18 0 18 1 2 19 0 19 1 2 20 0 20 1 2 21 0 21 1 2 25 1 20 0 1 26 1 1 27 0 1 28 1...
result:
ok ok
Test #25:
score: 0
Accepted
time: 0ms
memory: 3596kb
input:
234654 253129
output:
46 1 2 1 1 3 1 1 4 1 2 5 0 6 1 2 7 0 22 1 1 8 0 1 23 1 2 24 1 21 0 0 2 9 0 9 1 2 10 0 10 1 2 11 0 11 1 2 12 0 12 1 2 13 0 13 1 2 14 0 14 1 2 15 0 15 1 2 16 0 16 1 2 17 0 17 1 2 18 0 18 1 2 19 0 19 1 2 20 0 20 1 2 21 0 21 1 2 25 0 20 1 2 26 1 20 0 1 27 1 2 28 1 19 0 2 29 0 1...
result:
ok ok
Test #26:
score: 0
Accepted
time: 0ms
memory: 3664kb
input:
554090 608599
output:
52 1 2 1 1 3 0 1 4 0 2 5 0 6 1 2 7 0 24 1 1 8 0 1 25 1 2 26 1 23 0 0 2 9 0 9 1 2 10 0 10 1 2 11 0 11 1 2 12 0 12 1 2 13 0 13 1 2 14 0 14 1 2 15 0 15 1 2 16 0 16 1 2 17 0 17 1 2 18 0 18 1 2 19 0 19 1 2 20 0 20 1 2 21 0 21 1 2 22 0 22 1 2 23 0 23 1 1 27 1 1 28 0 1 29 1 1 30 ...
result:
ok ok
Extra Test:
score: 0
Extra Test Passed