QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#89917#5110. Splitstream_skb_#Compile Error//C++202.8kb2023-03-21 19:39:132023-03-21 19:39:15

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-21 19:39:15]
  • 评测
  • [2023-03-21 19:39:13]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define ll long long
;



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    ll n,q,m;
    cin>>m>>n>>q;
    vector<int> vis(1e6,0);
    vector<pair<int,int>> par(1e6,{-1,-1});
    vector<int> inp;
    vector<vector<int>> rec;
    vector<ll> sz;
    inp.assign(1e6,-1);
    rec.assign(n,{});
    sz.assign(1e6,-1);
    for(int i=0;i<n;i++){
        char p;
        int x,y,z;
        cin>>p>>x>>y>>z;
        if(p=='S'){
            par[y]={x,-1};
            par[z]={-1,x};
            inp[x]=i;
            rec[i]={x,0,y,z};
        }
        else {
            par[z]={x,y};
            inp[x]=inp[y]=i;
            rec[i]={x,y,z,0};
        }
    }
    
    sz[1]=m;
    queue<int> qq;
    qq.push(1);
    while(qq.size()){
        int u=qq.front();
        qq.pop();
        vis[u]=1;
        if(inp[u]==-1) continue;
        if(!rec[inp[u]][1]){
            sz[rec[inp[u]][2]]=(sz[u]+1)/2;
            sz[rec[inp[u]][3]]=(sz[u])/2;
            qq.push(rec[inp[u]][2]);
            qq.push(rec[inp[u]][3]);
        }
        else{
            int x=rec[inp[u]][0];
            int y=rec[inp[u]][1];
            if(vis[x]&&vis[y]){
                sz[rec[inp[u]][2]]=sz[x]+sz[y];
                qq.push(rec[inp[u]][2]);
            }
        }

    }
    
    for (int i = 2; i < 10 * n; ++i) if (sz[i] == -1) {
        f(i, 0);
    }

    while(q--){
        ll u,k;
        cin>>u>>k;
        int f=1;
        while(u!=1){
            int x=par[u].first;
            int y=par[u].second;
            if(k>sz[u]){
                f=0;
                break;
            }
            if(x==-1){
                u=y;
                k=2LL*k;
            }   
            else if(y==-1){
                u=x;
                k=2LL*k-1LL;
            }
            else{
                ll a=sz[x];
                ll b=sz[y];
                if(k>a+b){
                    f=0;
                    break;
                }
                if(a>=b){
                    if(k<=2LL*b){
                        if(k%2) u=x;
                        else u=y;
                        k=(k+1LL)/2;
                    }
                    else{
                        u=x;
                        k=k-b;
                    }
                }
                else{
                    if(k<=2LL*a){
                        if(k%2) u=x;
                        else u=y;
                        k=(k+1LL)/2;
                    }
                    else{
                        u=y;
                        k=k-a;
                    }
                }
            }
        }
        if(k>m) f=0;
        if(!f) cout<<"none\n";
        else cout<<k<<"\n";
    }



}

詳細信息

answer.code: In function ‘int main()’:
answer.code:67:9: error: ‘f’ was not declared in this scope
   67 |         f(i, 0);
      |         ^