QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#304050#1195. One-Way ConveyorsNYCU_CartesianTree#Compile Error//C++203.3kb2024-01-13 13:22:512024-01-13 13:22:51

Judging History

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

  • [2024-01-13 13:22:51]
  • 评测
  • [2024-01-13 13:22:51]
  • 提交

answer

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

#define int long long 
#define F first 
#define S second 
#define pb push_back

const int mol=1e9+7;

vector<int>node[10005],nnode[20005];
int vis[20005],low[20005],dfn[20005],dep[40005];
int lcc[20][20005];
int fa[50005];
int up[50005],down[50005];
vector<pair<int,int>>toal;
map<pair<int,int>,int>gan;
stack<int>st;
set<int>hav[50005];
int nn=0,iu=0;
int n,m;

void dfs(int v,int pre){
    st.push(v);vis[v]=1,low[v]=dfn[v]=++iu;
    for(int k:node[v]){
        if(!vis[k]){
            dfs(k,v);
            gan[{v,k}]=1;
            low[v]=min(low[v],low[k]);
            if(low[k]>=dfn[v]){
                nn++;
                int tt;
                while(1){
                    int tt=st.top();st.pop();
                    nnode[nn+n].pb(tt);
                    nnode[tt].pb(nn+n);
                    if(tt==k) break;
                }
                tt=v;
                nnode[nn+n].pb(tt);
                nnode[tt].pb(nn+n);
            }
        }
        else {
            if(dfn[k]>dfn[v])
            gan[{v,k}]=1;
            low[v]=min(low[v],dfn[k]);
        }
    }
}

void dd(int v,int pre){
    dep[v]=dep[pre]+1;
    lcc[0][v]=pre;
    for(int k:nnode[v]){
        if(k==pre) continue;
        dd(k,v);
    }
}

pair<int,int> lca(int g,int h){
    int ss=0;
    if(dep[g]<dep[h]) swap(g,h),ss=1;
    int t=19;
    while(t>=0){
        int gg=lcc[t][g];
        if(dep[gg]>dep[h]) g=gg;
        t--;
    }
    if(lcc[0][g]==h) return {g,g};
    t=19;
    while(t>=0){
        int g1=lcc[t][g],g2=lcc[t][h];
        if(g1!=g2) g=g1,h=g2;
        t--;
    }
    if(ss) swap(g,h);
    return {g,h};
}

int u=0,d=0;
bool ok=1;
void fi(int v,int pre){
    fa[v]=pre;
    cerr<<n<<"\n";
    cerr<<u<<" "<<d<<" "<<v<<"vv\n";
    // return;
    int u1=u,d1=d;
    u+=up[v],d+=down[v];
    u1=max(u1,u),d1=max(d1,d);
    if(u1&&d1){
        ok=0;
        return;
    }
    int pp=pre;
    if(pre>n) pp=fa[pre];
    if(u1) gan[{v,pp}],gan[{pp,v}]=0;
    if(d1) gan[{pp,v}],gan[{v,pp}]=0;
    for(int k:nnode[v]){
        if(k==pre) continue;
        fi(k,v);
    }
}

void solve(){
    cin>>n>>m;

    for(int i=1;i<=m;i++){
        int g,h;
        cin>>g>>h;
        node[g].pb(h);
        node[h].pb(g);
        toal.pb({g,h});
    }

    dfs(1,1);
    dd(1,1);
    // for(int i=1;i<=nn+n;i++){
    //     for(int ii:nnode[i]) cout<<ii<<" ";cout<<"\n";
    // }
    // return;

    for(int i=1;i<=19;i++) for(int j=1;j<=n;j++) lcc[i][j]=lcc[i-1][lcc[i-1][j]];

    int q;
    cin>>q;
    for(int i=1;i<=q;i++){
        int g,h;
        cin>>g>>h;
        auto p=lca(g,h);
        if(p.F==p.S){
            if(dep[g]<dep[h]){
                down[p.F]=1;
                down[h]=-1;
            }
            up[g]=-1;
            up[p.F]=1;
        }
        else{
            up[p.F]=1,down[p.S]=1,up[g]=-1,down[h]=-1;
        }
    }

    fi(1,1);
    return;
    if(!ok) {
        cout<<"No\n";
        return;
    }
    cout<<"Yes\n";
    for(auto g:toal){
        if(gan[{g.F,g.S}]){
            cout<<g.F<<" "<<g.S<<"\n";
        }
        else cout<<g.S<<" "<<g.F<<"\n";
    }

}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}

Details

answer.code:11:1: error: ‘vector’ does not name a type
   11 | vector<int>node[10005],nnode[20005];
      | ^~~~~~
answer.code:16:8: error: ‘pair’ was not declared in this scope
   16 | vector<pair<int,int>>toal;
      |        ^~~~
answer.code:16:8: error: ‘pair’ was not declared in this scope
answer.code:16:8: error: ‘pair’ was not declared in this scope
answer.code:16:8: error: ‘pair’ was not declared in this scope
answer.code:16:8: error: ‘pair’ was not declared in this scope
answer.code:16:8: error: ‘pair’ was not declared in this scope
answer.code:16:8: error: ‘pair’ was not declared in this scope
answer.code:16:8: error: ‘pair’ was not declared in this scope
answer.code:16:8: error: ‘pair’ was not declared in this scope
answer.code:16:1: error: ‘vector’ does not name a type
   16 | vector<pair<int,int>>toal;
      | ^~~~~~
answer.code:17:5: error: ‘pair’ was not declared in this scope
   17 | map<pair<int,int>,int>gan;
      |     ^~~~
answer.code:17:5: error: ‘pair’ was not declared in this scope
answer.code:17:5: error: ‘pair’ was not declared in this scope
answer.code:17:5: error: ‘pair’ was not declared in this scope
answer.code:17:5: error: ‘pair’ was not declared in this scope
answer.code:17:5: error: ‘pair’ was not declared in this scope
answer.code:17:5: error: ‘pair’ was not declared in this scope
answer.code:17:5: error: ‘pair’ was not declared in this scope
answer.code:17:5: error: ‘pair’ was not declared in this scope
answer.code:17:1: error: ‘map’ does not name a type
   17 | map<pair<int,int>,int>gan;
      | ^~~
answer.code:18:1: error: ‘stack’ does not name a type
   18 | stack<int>st;
      | ^~~~~
answer.code:19:1: error: ‘set’ does not name a type
   19 | set<int>hav[50005];
      | ^~~
answer.code: In function ‘void dfs(long long int, long long int)’:
answer.code:24:5: error: ‘st’ was not declared in this scope; did you mean ‘std’?
   24 |     st.push(v);vis[v]=1,low[v]=dfn[v]=++iu;
      |     ^~
      |     std
answer.code:25:15: error: ‘node’ was not declared in this scope
   25 |     for(int k:node[v]){
      |               ^~~~
answer.code:28:13: error: ‘gan’ was not declared in this scope
   28 |             gan[{v,k}]=1;
      |             ^~~
answer.code:29:20: error: ‘min’ was not declared in this scope
   29 |             low[v]=min(low[v],low[k]);
      |                    ^~~
answer.code:35:21: error: ‘nnode’ was not declared in this scope
   35 |                     nnode[nn+n].pb(tt);
      |                     ^~~~~
answer.code:40:17: error: ‘nnode’ was not declared in this scope
   40 |                 nnode[nn+n].pb(tt);
      |                 ^~~~~
answer.code:46:13: error: ‘gan’ was not declared in this scope
   46 |             gan[{v,k}]=1;
      |             ^~~
answer.code:47:20: error: ‘min’ was not declared in this scope
   47 |             low[v]=min(low[v],dfn[k]);
      |                    ^~~
answer.code: In function ‘void dd(long long int, long long int)’:
answer.code:55:15: error: ‘nnode’ was not declared in this scope
   55 |     for(int k:nnode[v]){
      |               ^~~~~
answer.code: At global scope:
answer.code:61:1: error: ‘pair’ does not name a type
   61 | pair<int,int> lca(int g,int h){
      | ^~~~
answer.code: In function ‘void fi(long long int, long long int)’:
answer.code:85:5: error: ‘cerr’ was not declared in this scope
   85 |     cerr<<n<<"\n";
      |     ^~~~
answer.code:90:8: error: ‘max’ was not declared in this scope
   90 |     u1=max(u1,u),d1=max(d1,d);
      |        ^~~
answer.code:97:12: error: ‘gan’ was not declared in this scope
   97 |     if(u1) gan[{v,pp}],gan[{pp,v}]=0;
      |            ^~~
answer.code:98:12: error: ‘gan’ was not declared in this scope
   98 |     if(d1) gan[{pp,v}],gan[{v,pp}]=0;
      |            ^~~
answer.code:99:15: error: ‘nnode’ was not declared in this scope
   99 |     for(int k:nnode[v]){
      |               ^~~~~
answer.code: In function ‘void solve()’:
answer.code:106:5: error: ‘cin’ was not declared in this scope
  106 |     cin>>n>>m;
      |     ^~~
answer.code:111:9: error: ‘node’ was not declared in this scope
  111 |         node[g].pb(h);
      |         ^~~~
answer.code:113:9: error: ‘toal’ was not declared in this scope
  113 |         toal.pb({g,h});
      |         ^~~~
answer.code:130:16: error: ‘lca’ was not declared in this scope; did you mean ‘lcc’?
  130 |         auto p=lca(g,h);
      |                ^~~
      |                lcc
answer.code:147:9: error: ‘cout’ was not declared in this scope
  147 |         cout<<"No\n";
      |         ^~~~
answer.code:150:5: error: ‘cout’ was not declared in this scope
  150 |     cout<<"Yes\n";
      |     ^~~~
answer.code:151:16: error: ‘toal’ was not declared in this scope
  151 |     for(auto g:toal){
      |                ^~~~
answer.code:152:12: error: ‘gan’ was not declared in this scope
  152 |         if(gan[{g.F,g.S}]){
      |            ^~~
answer.code: In function ‘int main()’:
answer.code:161:5: error: ...