QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#355573#5110. SplitstreamInfinityNS#WA 1ms3852kbC++141.8kb2024-03-16 20:46:272024-03-16 20:46:28

Judging History

你现在查看的是最新测评结果

  • [2024-03-16 20:46:28]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3852kb
  • [2024-03-16 20:46:27]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ll long long

const int N=50050;
int par[N],pos[N],fir[N],sec[N],spl[N],sz[N];
int main(){
    int m,n,q;
    scanf("%i %i %i",&m,&n,&q);
    sz[1]=m;
    for(int i=1;i<=n;i++){
        char t[5];
        int x,y,z;
        scanf("%s %i %i %i",t,&x,&y,&z);
        if(t[0]=='S'){
            spl[y]=1;
            par[y]=x;
            pos[y]=0;
            sz[y]=(sz[x]+1)/2;

            spl[z]=1;
            par[z]=x;
            pos[z]=1;
            sz[z]=sz[x]/2;
        }else{
            spl[z]=0;
            fir[z]=x;
            sec[z]=y;
            sz[z]=sz[x]+sz[y];
        }
    }
    for(int i=1;i<=q;i++){
        int x;
        ll k;
        scanf("%i %lld",&x,&k);
        bool ok=true;
        if(k>sz[x])ok=false;
        else{
            while(x!=1){
                if(spl[x]==0){
                    if(k<=2*min(sz[fir[x]],sz[sec[x]])){
                        if(k%2==1)x=fir[x];
                        else x=sec[x];
                        k=(k+1)/2;
                    }else{
                        if(sz[fir[x]]>sz[sec[x]]){
                            k-=sz[sec[x]];
                            x=fir[x];
                        }else{
                            k-=sz[fir[x]];
                            x=sec[x];
                        }
                    }
                }else{
                    if(pos[x]==0)k=2*k-1;
                    else k=2*k;
                    x=par[x];
                }
                /*if(k>m){
                    ok=false;
                    break;
                }*/
                //printf("->%i %lld\n",x,k);
            }
        }
        //if(k>m)ok=false;
        if(ok)printf("%lld\n",k);
        else printf("none\n");
    }
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3852kb

input:

5 8 26
M 8 9 13
S 2 4 5
S 1 2 3
M 6 5 8
S 4 9 10
S 10 14 15
S 3 6 7
S 7 11 12
2 3
2 4
3 2
3 3
4 2
4 3
5 1
5 2
6 1
6 2
7 1
7 2
8 2
8 3
9 1
9 2
10 1
10 2
11 1
11 2
12 1
13 3
13 4
14 1
14 2
15 1

output:

5
none
4
none
none
none
none
none
2
none
4
none
none
none
none
none
none
none
4
none
none
none
none
none
none
none

result:

wrong answer 5th lines differ - expected: '5', found: 'none'