QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#754932#9530. A Game On TreeANIG#WA 0ms3692kbC++142.2kb2024-11-16 16:06:242024-11-16 16:06:25

Judging History

This is the latest submission verdict.

  • [2024-11-16 16:06:25]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3692kb
  • [2024-11-16 16:06:24]
  • Submitted

answer

#include<bits/stdc++.h>

using namespace std;

int L,R;

int k,idx=1;
vector<int> rec[1111];
vector<pair<int,int>> ver[1111];

vector<pair<int,int>> tmp;

void solve(int l,int r,int dep=0,int now=1){
    if(L<=l&&r<=R){
        //cerr<<"at "<<l<<' '<<r<<' '<<dep<<endl;
        if(l!=r) rec[dep].emplace_back(now);
        return ;
    }
    int mid=(l+r)>>1;
    if(L<=mid){
        if(!l){
            if(l!=mid) solve(l,mid,dep+1,now);
            else tmp.emplace_back(now,0);
        }
        else{
            if(l!=mid){
                idx++;
                ver[now].emplace_back(idx,0);
            }else tmp.emplace_back(now,0);
            solve(l,mid,dep+1,idx);
        }
    }
    if(mid<R){
        if(mid+1!=r){
            idx++;
            ver[now].emplace_back(idx,1);
        }else tmp.emplace_back(now,1);
        solve(mid+1,r,dep+1,idx);
    }
}

int main(){

    cin>>L>>R;

    int mx=R+1;
    while((mx&-mx)!=mx) mx++;
    k=__lg(mx);
    cerr<<k<<endl;
    solve(0,mx-1);

    mx=-1;
    for(int i=0; i<1000; i++){
        if(rec[i].size()){
            mx=i;
            break;
        }
    }

    assert(mx!=-1);

    int Lim=k-mx;
    for(int i=idx+1; i<idx+Lim; i++){
        ver[i].emplace_back(i+1,0);
        ver[i].emplace_back(i+1,1);
    }

    for(int i=0; i<1000; i++){
        for(auto pt:rec[i]){
            if(!(k-i)){
                assert(0);
                continue;
            }
            ver[pt].emplace_back(idx+k-i,0);
            ver[pt].emplace_back(idx+k-i,1);
        }
    }

    for(auto pt:tmp){
        ver[pt.first].emplace_back(idx+Lim,pt.second);
    }

    int T=0;
    for(int i=1; i<1000; i++){
        if(ver[i].size()){
            T=i;
            for(auto p:ver[i]) T=max(T,p.first);
        }
    }
    assert(T==idx+Lim);

    cout<<T<<'\n';
    for(int i=1; i<=T; i++){
        cout<<ver[i].size()<<' ';
        for(auto pt:ver[i]){
            cout<<pt.first<<' '<<pt.second<<' ';
        }
        cout<<'\n';
    }

    return 0;
}
/*
6 13
4
9
2 2 1 4 1 
1 3 1 
2 8 0 8 1 
2 5 0 6 1 
2 9 0 9 1 
1 7 0 
2 8 0 8 1 
2 9 0 9 1 
0 
*/

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3692kb

input:

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

output:

3
1 2 1 
2 3 0 3 1 
0 

result:

wrong answer 1st lines differ - expected: '443664158', found: '3'