QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#680486#9519. Build a Computerucup-team3691#AC ✓1ms3792kbC++202.3kb2024-10-26 21:12:172024-10-26 21:12:18

Judging History

This is the latest submission verdict.

  • [2024-10-26 21:12:18]
  • Judged
  • Verdict: AC
  • Time: 1ms
  • Memory: 3792kb
  • [2024-10-26 21:12:17]
  • Submitted

answer

#include <iostream>
#include <vector>

using namespace std;
int cnt=2;
int ans[30];
vector<int>vecc;
vector<pair<int,int> >adj[105];
int fiu1[105];
int fiu0[105];
void add (int nod,int index,int k)
{
    if(index+1==vecc.size())
    {
        adj[nod].push_back({ans[k],vecc[index]});
        return;
    }
    if(vecc[index]==1)
    {
        if(fiu1[nod]!=0)
        {
            add(fiu1[nod],index+1,k);
        }
        else
        {
            cnt++;
            fiu1[nod]=cnt;
            adj[nod].push_back({cnt,1});
            add(cnt,index+1,k);
        }
    }
    else
    {
        if(fiu0[nod]!=0)
        {
            add(fiu0[nod],index+1,k);
        }
        else
        {
            cnt++;
            fiu0[nod]=cnt;
            adj[nod].push_back({cnt,0});
            add(cnt,index+1,k);
        }
    }
}
void desc(int x,int k)
{
    int pow=2097152/2,h=0;
    vecc.clear();
    for(int i=20;i>=0;i--)
    {
        if(x/pow==1)
        {
            h=1;
        }
        if(h==1)
        {
            vecc.push_back(x/pow);
            x=x%pow;
        }
        pow=pow/2;
    }

    for(int i=1;i<=k;i++)
    {
        vecc.pop_back();
    }
    /*
    for(int i=0;i<vecc.size();i++)
    {
        cout<<vecc[i]<<" ";
    }
    cout<<'\n';
    */
    add(1,0,k);
}
int main()
{
    int n,i,j,k,l,r,pw,maxim=0;
    cin>>l>>r;
    vector<pair<int,int> >vec;
    for(i=l;i<=r;)
    {
        int nr=1;
        for(pw=0;pw<=20;pw++)
        {
            if(i%nr!=0 || i+nr-1>r)
            {
                pw--;
                nr=nr/2;
                break;
            }
            nr=nr*2;
        }
        vec.push_back({i,pw});
        maxim=max(maxim,pw);
        //cout<<i<<" "<<i+nr-1<<" "<<pw<<" "<<nr<<'\n';
        i=i+nr;
    }
    ans[0]=2;
    for(i=1;i<=maxim;i++)
    {
        cnt++;
        adj[cnt].push_back({cnt-1,1});
        adj[cnt].push_back({cnt-1,0});
        ans[i]=cnt;
    }
    for(i=0;i<vec.size();i++)
    {
        desc(vec[i].first,vec[i].second);
    }
    cout<<cnt<<'\n';
    for(i=1;i<=cnt;i++)
    {
        cout<<adj[i].size()<<" ";
        for(auto x:adj[i])
        {
            cout<<x.first<<" "<<x.second<<" ";
        }
        cout<<'\n';
    }
    return 0;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3504kb

input:

5 7

output:

5
1 4 1 
0 
2 2 1 2 0 
2 5 0 3 1 
1 2 1 

result:

ok ok

Test #2:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

10 27

output:

8
1 6 1 
0 
2 2 1 2 0 
2 3 1 3 0 
2 4 1 4 0 
4 7 0 4 1 5 0 8 1 
1 3 1 
1 4 0 

result:

ok ok

Test #3:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

5 13

output:

7
1 5 1 
0 
2 2 1 2 0 
2 3 1 3 0 
4 6 0 3 1 4 0 7 1 
1 2 1 
1 3 0 

result:

ok ok

Test #4:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

1 1000000

output:

39
20 2 1 3 1 4 1 5 1 6 1 7 1 8 1 9 1 10 1 11 1 12 1 13 1 14 1 15 1 16 1 17 1 18 1 19 1 20 1 21 1 
0 
2 2 1 2 0 
2 3 1 3 0 
2 4 1 4 0 
2 5 1 5 0 
2 6 1 6 0 
2 7 1 7 0 
2 8 1 8 0 
2 9 1 9 0 
2 10 1 10 0 
2 11 1 11 0 
2 12 1 12 0 
2 13 1 13 0 
2 14 1 14 0 
2 15 1 15 0 
2 16 1 16 0 
2 17 1 17 0 
2 18 1...

result:

ok ok

Test #5:

score: 0
Accepted
time: 0ms
memory: 3464kb

input:

1 1

output:

2
1 2 1 
0 

result:

ok ok

Test #6:

score: 0
Accepted
time: 0ms
memory: 3508kb

input:

7 9

output:

6
1 4 1 
0 
2 2 1 2 0 
2 5 1 6 0 
1 2 1 
1 3 0 

result:

ok ok

Test #7:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

3 7

output:

5
2 5 1 4 1 
0 
2 2 1 2 0 
2 3 1 3 0 
1 2 1 

result:

ok ok

Test #8:

score: 0
Accepted
time: 0ms
memory: 3536kb

input:

1 5

output:

4
3 2 1 3 1 4 1 
0 
2 2 1 2 0 
1 3 0 

result:

ok ok

Test #9:

score: 0
Accepted
time: 0ms
memory: 3488kb

input:

1 4

output:

5
3 2 1 3 1 4 1 
0 
2 2 1 2 0 
1 5 0 
1 2 0 

result:

ok ok

Test #10:

score: 0
Accepted
time: 0ms
memory: 3740kb

input:

8 9

output:

5
1 4 1 
0 
2 2 1 2 0 
1 5 0 
1 3 0 

result:

ok ok

Test #11:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

7 51

output:

9
3 7 1 5 1 6 1 
0 
2 2 1 2 0 
2 3 1 3 0 
2 4 1 4 0 
2 5 1 5 0 
2 8 1 6 0 
2 2 1 9 0 
1 4 0 

result:

ok ok

Test #12:

score: 0
Accepted
time: 1ms
memory: 3608kb

input:

51 79

output:

12
1 7 1 
0 
2 2 1 2 0 
2 3 1 3 0 
2 4 1 4 0 
2 5 1 5 0 
2 8 1 12 0 
2 9 0 5 1 
2 10 0 4 1 
1 11 1 
1 2 1 
1 6 0 

result:

ok ok

Test #13:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

92 99

output:

11
1 5 1 
0 
2 2 1 2 0 
2 3 1 3 0 
2 6 0 9 1 
1 7 1 
1 8 1 
1 4 1 
1 10 0 
1 11 0 
1 4 0 

result:

ok ok

Test #14:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

27 36

output:

12
1 5 1 
0 
2 2 1 2 0 
2 3 1 3 0 
2 6 1 9 0 
2 7 0 4 1 
1 8 1 
1 2 1 
1 10 0 
2 4 0 11 1 
1 12 0 
1 2 0 

result:

ok ok

Test #15:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

55 84

output:

16
1 7 1 
0 
2 2 1 2 0 
2 3 1 3 0 
2 4 1 4 0 
2 5 1 5 0 
2 8 1 12 0 
2 9 0 5 1 
1 10 1 
1 11 1 
1 2 1 
2 6 0 13 1 
1 14 0 
2 4 0 15 1 
1 16 0 
1 2 0 

result:

ok ok

Test #16:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

297208 929600

output:

53
1 21 1 
0 
2 2 1 2 0 
2 3 1 3 0 
2 4 1 4 0 
2 5 1 5 0 
2 6 1 6 0 
2 7 1 7 0 
2 8 1 8 0 
2 9 1 9 0 
2 10 1 10 0 
2 11 1 11 0 
2 12 1 12 0 
2 13 1 13 0 
2 14 1 14 0 
2 15 1 15 0 
2 16 1 16 0 
2 17 1 17 0 
2 18 1 18 0 
2 19 1 19 0 
4 22 0 19 1 20 0 36 1 
2 23 0 18 1 
1 24 1 
2 25 0 16 1 
2 26 0 15 1...

result:

ok ok

Test #17:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

45728 589156

output:

47
4 21 1 18 1 19 1 20 1 
0 
2 2 1 2 0 
2 3 1 3 0 
2 4 1 4 0 
2 5 1 5 0 
2 6 1 6 0 
2 7 1 7 0 
2 8 1 8 0 
2 9 1 9 0 
2 10 1 10 0 
2 11 1 11 0 
2 12 1 12 0 
2 13 1 13 0 
2 14 1 14 0 
2 15 1 15 0 
2 16 1 16 0 
2 17 1 17 0 
2 18 1 18 0 
2 19 1 19 0 
2 22 0 16 1 
2 23 1 31 0 
1 24 1 
2 25 0 13 1 
2 26 0...

result:

ok ok

Test #18:

score: 0
Accepted
time: 0ms
memory: 3572kb

input:

129152 138000

output:

39
1 15 1 
0 
2 2 1 2 0 
2 3 1 3 0 
2 4 1 4 0 
2 5 1 5 0 
2 6 1 6 0 
2 7 1 7 0 
2 8 1 8 0 
2 9 1 9 0 
2 10 1 10 0 
2 11 1 11 0 
2 12 1 12 0 
2 13 1 13 0 
2 16 1 24 0 
1 17 1 
1 18 1 
1 19 1 
1 20 1 
2 21 0 12 1 
2 22 0 11 1 
2 23 0 10 1 
1 9 1 
1 25 0 
1 26 0 
1 27 0 
2 14 0 28 1 
2 13 0 29 1 
1 30 ...

result:

ok ok

Test #19:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

245280 654141

output:

49
2 21 1 20 1 
0 
2 2 1 2 0 
2 3 1 3 0 
2 4 1 4 0 
2 5 1 5 0 
2 6 1 6 0 
2 7 1 7 0 
2 8 1 8 0 
2 9 1 9 0 
2 10 1 10 0 
2 11 1 11 0 
2 12 1 12 0 
2 13 1 13 0 
2 14 1 14 0 
2 15 1 15 0 
2 16 1 16 0 
2 17 1 17 0 
2 18 1 18 0 
2 19 1 19 0 
2 22 1 33 0 
1 23 1 
2 24 0 16 1 
1 25 1 
1 26 1 
1 27 1 
1 28 ...

result:

ok ok

Test #20:

score: 0
Accepted
time: 0ms
memory: 3740kb

input:

202985 296000

output:

51
1 18 1 
0 
2 2 1 2 0 
2 3 1 3 0 
2 4 1 4 0 
2 5 1 5 0 
2 6 1 6 0 
2 7 1 7 0 
2 8 1 8 0 
2 9 1 9 0 
2 10 1 10 0 
2 11 1 11 0 
2 12 1 12 0 
2 13 1 13 0 
2 14 1 14 0 
2 15 1 15 0 
2 16 1 16 0 
2 19 1 35 0 
2 20 0 17 1 
2 21 0 16 1 
2 22 0 15 1 
1 23 1 
1 24 1 
2 25 0 12 1 
2 26 0 11 1 
2 27 0 10 1 
...

result:

ok ok

Test #21:

score: 0
Accepted
time: 0ms
memory: 3760kb

input:

438671 951305

output:

54
1 21 1 
0 
2 2 1 2 0 
2 3 1 3 0 
2 4 1 4 0 
2 5 1 5 0 
2 6 1 6 0 
2 7 1 7 0 
2 8 1 8 0 
2 9 1 9 0 
2 10 1 10 0 
2 11 1 11 0 
2 12 1 12 0 
2 13 1 13 0 
2 14 1 14 0 
2 15 1 15 0 
2 16 1 16 0 
2 17 1 17 0 
2 18 1 18 0 
2 19 1 19 0 
2 22 1 20 0 
4 23 0 18 1 19 0 39 1 
1 24 1 
2 25 0 16 1 
1 26 1 
1 2...

result:

ok ok

Test #22:

score: 0
Accepted
time: 0ms
memory: 3576kb

input:

425249 739633

output:

54
1 20 1 
0 
2 2 1 2 0 
2 3 1 3 0 
2 4 1 4 0 
2 5 1 5 0 
2 6 1 6 0 
2 7 1 7 0 
2 8 1 8 0 
2 9 1 9 0 
2 10 1 10 0 
2 11 1 11 0 
2 12 1 12 0 
2 13 1 13 0 
2 14 1 14 0 
2 15 1 15 0 
2 16 1 16 0 
2 17 1 17 0 
2 18 1 18 0 
2 21 1 38 0 
2 22 0 18 1 
2 23 0 17 1 
1 24 1 
1 25 1 
1 26 1 
1 27 1 
1 28 1 
2 ...

result:

ok ok

Test #23:

score: 0
Accepted
time: 0ms
memory: 3580kb

input:

551207 961718

output:

56
1 20 1 
0 
2 2 1 2 0 
2 3 1 3 0 
2 4 1 4 0 
2 5 1 5 0 
2 6 1 6 0 
2 7 1 7 0 
2 8 1 8 0 
2 9 1 9 0 
2 10 1 10 0 
2 11 1 11 0 
2 12 1 12 0 
2 13 1 13 0 
2 14 1 14 0 
2 15 1 15 0 
2 16 1 16 0 
2 17 1 17 0 
2 18 1 18 0 
2 21 0 39 1 
2 22 0 19 1 
2 23 0 18 1 
2 24 0 17 1 
1 25 1 
1 26 1 
2 27 0 14 1 
...

result:

ok ok

Test #24:

score: 0
Accepted
time: 0ms
memory: 3504kb

input:

114691 598186

output:

54
3 21 1 19 1 20 1 
0 
2 2 1 2 0 
2 3 1 3 0 
2 4 1 4 0 
2 5 1 5 0 
2 6 1 6 0 
2 7 1 7 0 
2 8 1 8 0 
2 9 1 9 0 
2 10 1 10 0 
2 11 1 11 0 
2 12 1 12 0 
2 13 1 13 0 
2 14 1 14 0 
2 15 1 15 0 
2 16 1 16 0 
2 17 1 17 0 
2 18 1 18 0 
2 19 1 19 0 
2 22 1 37 0 
1 23 1 
2 24 0 15 1 
2 25 0 14 1 
2 26 0 13 1...

result:

ok ok

Test #25:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

234654 253129

output:

44
1 16 1 
0 
2 2 1 2 0 
2 3 1 3 0 
2 4 1 4 0 
2 5 1 5 0 
2 6 1 6 0 
2 7 1 7 0 
2 8 1 8 0 
2 9 1 9 0 
2 10 1 10 0 
2 11 1 11 0 
2 12 1 12 0 
2 13 1 13 0 
2 14 1 14 0 
1 17 1 
1 18 1 
2 19 0 32 1 
2 20 0 15 1 
1 21 1 
2 22 0 13 1 
1 23 1 
2 24 0 11 1 
2 25 0 10 1 
1 26 1 
2 27 0 8 1 
2 28 0 7 1 
1 29...

result:

ok ok

Test #26:

score: 0
Accepted
time: 0ms
memory: 3504kb

input:

554090 608599

output:

48
1 18 1 
0 
2 2 1 2 0 
2 3 1 3 0 
2 4 1 4 0 
2 5 1 5 0 
2 6 1 6 0 
2 7 1 7 0 
2 8 1 8 0 
2 9 1 9 0 
2 10 1 10 0 
2 11 1 11 0 
2 12 1 12 0 
2 13 1 13 0 
2 14 1 14 0 
2 15 1 15 0 
2 16 1 16 0 
1 19 0 
1 20 0 
2 21 0 36 1 
2 22 0 17 1 
1 23 1 
1 24 1 
1 25 1 
2 26 0 13 1 
1 27 1 
2 28 0 11 1 
2 29 0 ...

result:

ok ok

Extra Test:

score: 0
Extra Test Passed