QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#808642#8551. DFS Order 5ucup-team2179Compile Error//C++233.3kb2024-12-10 22:56:282024-12-10 22:56:29

Judging History

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

  • [2024-12-10 22:56:29]
  • 评测
  • [2024-12-10 22:56:28]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define pii pair<int, int>
using namespace std;
struct ollca{
    vector<vector<int> > adj;
    vector<int>L;
    vector<int>dfn;
    vector<int>siz;
    vector<int>fa;
    int cnt=0,n;
    vector<vector<int> >mylist;
    void dfs(int u,int f){
        cnt++;
        dfn[cnt]=u;
        L[u]=cnt;
        siz[u]++;
        for(auto p:adj[u]){
            if(p==f)continue;
            fa[p]=u;
            dfs(p,u);
            cnt++;
            dfn[cnt]=u;
            siz[u]+=siz[p];
        }
    }
    int op(int l,int r){
        if(L[l]<L[r])return l;
        return r;
    };
    ollca(vector<vector<int> > a,int root){
        adj=a;
        n=a.size()-1;
        L.resize(n+1);
        fa.resize(n+1);
        siz.resize(n+1);
        dfn.resize(n*2);
        dfs(root,0);
        mylist=vector<vector<int>>(2*n+1,vector<int>(__lg(2*n-1)+1));
        for(int i=1;i<=2*n-1;i++)
        mylist[i][0]=dfn[i];
        for(int j=1;j<=__lg(2*n-1);j++)
        for(int i=1;i<=2*n-1-(1<<j)+1;i++)
            mylist[i][j]=op(mylist[i][j-1],mylist[i+(1<<j-1)][j-1]);
    }
    int lca(int l,int r){
        l=L[l];
        r=L[r];
        if(l>r)swap(l,r);
        int len=__lg(r-l+1);
        return op(mylist[l][len],mylist[r-(1<<len)+1][len]);
    }
}tr;
int LCA(int u, int v) {
    return tr.lca(u, v);
}
struct stable {
    vector<vector<int>> mylist;
    int n;
    int (*op) (int a, int b);
    stable(vector<int>&a, int(*f)(int, int)) {
        op = f;
        n = a.size() - 1;
        mylist = vector<vector<int>> (n + 1, vector<int>(__lg(n) + 1));
        for (int i = 1; i <= n; i++) mylist[i][0] = a[i];
        for (int j = 1; j <= __lg(n); j++)
            for (int i = 1; i <= n - (1 << j) + 1; i++)
                mylist[i][j] = op(mylist[i][j - 1], mylist[i + (1 << j - 1)][j - 1]);
    }
    int q(int l, int r) {
        assert(l >= 1 && r <= n && l <= r);
        int len = __lg(r - l + 1);
        return op(mylist[l][len], mylist[r - (1 << len) + 1][len]);
    }
};
void solve() {
    int n, q; cin >> n >> q;
    vector<vector<int> > a(n+1);
    for (int i = 1; i < n; i++) {
        int u, v; cin >> u >> v;
        a[u].push_back(v);
        a[v].push_back(u);
    }
    ollca(a,1);
    while (q--) {
        int k; cin >> k;
        set<int> s;
        vector<int> arr(k + 1);
        for (int i = 1; i <= k; i++) cin >> arr[i], s.insert(arr[i]);
        if (s.size() != k) {
            cout << "No\n";
            continue;
        }
        s.clear();
        stable st(arr, LCA);
        int flag = 1;
        for (int i = 1; i < k && flag; i++)
            flag &= (LCA(arr[i], arr[i + 1]) == tr.fa[arr[i + 1]]);
        for (int i = 1; i <= k && flag; i++) {
            flag &= (arr[i] == st.q(i, min(k, i + tr.siz[arr[i]] - 1)));
        }
        for (int i = 1; i <= k && flag; i++) {
            if(s.lower_bound(tr.L[arr[i]])!=s.end()&&*s.lower_bound(tr.L[arr[i]])<=tr.L[arr[i]]+tr.siz[arr[i]]-1)flag=0;
            s.insert(tr.L[arr[i]]);
        }
        if (flag) cout << "Yes\n";
        else cout << "No\n";
    }
}
signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) solve();
    return 0;
}

詳細信息

answer.code:54:2: error: no matching function for call to ‘ollca::ollca()’
   54 | }tr;
      |  ^~
answer.code:32:5: note: candidate: ‘ollca::ollca(std::vector<std::vector<long long int> >, long long int)’
   32 |     ollca(vector<vector<int> > a,int root){
      |     ^~~~~
answer.code:32:5: note:   candidate expects 2 arguments, 0 provided
answer.code:6:8: note: candidate: ‘constexpr ollca::ollca(const ollca&)’
    6 | struct ollca{
      |        ^~~~~
answer.code:6:8: note:   candidate expects 1 argument, 0 provided
answer.code:6:8: note: candidate: ‘constexpr ollca::ollca(ollca&&)’
answer.code:6:8: note:   candidate expects 1 argument, 0 provided