답안 #979311

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
979311 2024-05-10T14:47:13 Z imarn 철인 이종 경기 (APIO18_duathlon) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
#define f first
#define s second
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()
#define vi vector<int>
#define vvi vector<vi>
using namespace std;
const int N=1e5+5;
vi g[N];stack<int>st;
vector<int>bst[500001];ll x=0,n;
ll d[N]{0},lo[N]{0},t=0,ap[N]{0},id[N]{0},cur=1,isap[N]{0},sz[N];
void dfs(int u,int p){x++;
    lo[u]=d[u]=++t;st.push(u);
    for(auto v:g[u]){
        if(!d[v]){
            dfs(v,u);
            lo[u]=min(lo[u],lo[v]);
            if(d[u]<=lo[v]){
                bst[u].pb(cur+n);bst[cur+n].pb(u);
                while(bst[cur+n].empty()||bst[cur+n].back()!=v){
                    bst[cur+n].pb(st.top());bst[st.top()].pb(u);st.pop();
                }cur++;
            }
        }
        else if(v!=p)lo[u]=min(lo[u],d[v]);
    }
}
ll ans=0;
void solve(int u){
    sz[u]=(u<=n);
    for(auto v:bst[u]){
        solve(v);sz[u]+=sz[v];
        if(u>n)ans-=sz[v]*(sz[v]-1)*sz(bst[u]-1);
    }
    if(u>n)ans-=(x-sz[u])*(x-sz[u]-1)*sz(bst[u]-1);
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    int m;cin>>n>>m;
    for(int i=1;i<=m;i++){
        int u,v;cin>>u>>v;
        g[u].pb(v);g[v].pb(u);
    }
    for(int i=1;i<=n;i++){
        if(d[i])continue;
        dfs(i,i);solve(i);
        ans+=(x)*(x-1)*(x-2);x=0,t=0;
    }cout<<ans;
}

Compilation message

count_triplets.cpp: In function 'void solve(int)':
count_triplets.cpp:8:15: error: invalid cast from type 'std::vector<int>' to type 'int'
    8 | #define sz(x) (int)x.size()
      |               ^~~~~~~~~~~~~
    9 | #define all(x) x.begin(),x.end()
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   10 | #define vi vector<int>
      | ~~~~~~~~~~~~~~~~~~~~~~
   11 | #define vvi vector<vi>
      | ~~~~~~~~~~~~~~~~~~~~~~
   12 | using namespace std;
      | ~~~~~~~~~~~~~~~~~~~~
   13 | const int N=1e5+5;
      | ~~~~~~~~~~~~~~~~~~
   14 | vi g[N];stack<int>st;
      | ~~~~~~~~~~~~~~~~~~~~~
   15 | vector<int>bst[500001];ll x=0,n;
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   16 | ll d[N]{0},lo[N]{0},t=0,ap[N]{0},id[N]{0},cur=1,isap[N]{0},sz[N];
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   17 | void dfs(int u,int p){x++;
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~
   18 |     lo[u]=d[u]=++t;st.push(u);
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~
   19 |     for(auto v:g[u]){
      |     ~~~~~~~~~~~~~~~~~
   20 |         if(!d[v]){
      |         ~~~~~~~~~~
   21 |             dfs(v,u);
      |             ~~~~~~~~~
   22 |             lo[u]=min(lo[u],lo[v]);
      |             ~~~~~~~~~~~~~~~~~~~~~~~
   23 |             if(d[u]<=lo[v]){
      |             ~~~~~~~~~~~~~~~~
   24 |                 bst[u].pb(cur+n);bst[cur+n].pb(u);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   25 |                 while(bst[cur+n].empty()||bst[cur+n].back()!=v){
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   26 |                     bst[cur+n].pb(st.top());bst[st.top()].pb(u);st.pop();
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   27 |                 }cur++;
      |                 ~~~~~~~
   28 |             }
      |             ~  
   29 |         }
      |         ~      
   30 |         else if(v!=p)lo[u]=min(lo[u],d[v]);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   31 |     }
      |     ~          
   32 | }
      | ~              
   33 | ll ans=0;
      | ~~~~~~~~~      
   34 | void solve(int u){
      | ~~~~~~~~~~~~~~~~~~
   35 |     sz[u]=(u<=n);
      |     ~~~~~~~~~~~~~
   36 |     for(auto v:bst[u]){
      |     ~~~~~~~~~~~~~~~~~~~
   37 |         solve(v);sz[u]+=sz[v];
      |         ~~~~~~~~~~~~~~~~~~~~~~
   38 |         if(u>n)ans-=sz[v]*(sz[v]-1)*sz(bst[u]-1);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
count_triplets.cpp:38:37: note: in expansion of macro 'sz'
   38 |         if(u>n)ans-=sz[v]*(sz[v]-1)*sz(bst[u]-1);
      |                                     ^~
count_triplets.cpp:8:22: error: request for member 'size' in '1', which is of non-class type 'int'
    8 | #define sz(x) (int)x.size()
      |                      ^~~~
count_triplets.cpp:38:37: note: in expansion of macro 'sz'
   38 |         if(u>n)ans-=sz[v]*(sz[v]-1)*sz(bst[u]-1);
      |                                     ^~
count_triplets.cpp:8:15: error: invalid cast from type 'std::vector<int>' to type 'int'
    8 | #define sz(x) (int)x.size()
      |               ^~~~~~~~~~~~~
    9 | #define all(x) x.begin(),x.end()
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   10 | #define vi vector<int>
      | ~~~~~~~~~~~~~~~~~~~~~~
   11 | #define vvi vector<vi>
      | ~~~~~~~~~~~~~~~~~~~~~~
   12 | using namespace std;
      | ~~~~~~~~~~~~~~~~~~~~
   13 | const int N=1e5+5;
      | ~~~~~~~~~~~~~~~~~~
   14 | vi g[N];stack<int>st;
      | ~~~~~~~~~~~~~~~~~~~~~
   15 | vector<int>bst[500001];ll x=0,n;
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   16 | ll d[N]{0},lo[N]{0},t=0,ap[N]{0},id[N]{0},cur=1,isap[N]{0},sz[N];
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   17 | void dfs(int u,int p){x++;
      | ~~~~~~~~~~~~~~~~~~~~~~~~~~
   18 |     lo[u]=d[u]=++t;st.push(u);
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~
   19 |     for(auto v:g[u]){
      |     ~~~~~~~~~~~~~~~~~
   20 |         if(!d[v]){
      |         ~~~~~~~~~~
   21 |             dfs(v,u);
      |             ~~~~~~~~~
   22 |             lo[u]=min(lo[u],lo[v]);
      |             ~~~~~~~~~~~~~~~~~~~~~~~
   23 |             if(d[u]<=lo[v]){
      |             ~~~~~~~~~~~~~~~~
   24 |                 bst[u].pb(cur+n);bst[cur+n].pb(u);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   25 |                 while(bst[cur+n].empty()||bst[cur+n].back()!=v){
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   26 |                     bst[cur+n].pb(st.top());bst[st.top()].pb(u);st.pop();
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   27 |                 }cur++;
      |                 ~~~~~~~
   28 |             }
      |             ~  
   29 |         }
      |         ~      
   30 |         else if(v!=p)lo[u]=min(lo[u],d[v]);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   31 |     }
      |     ~          
   32 | }
      | ~              
   33 | ll ans=0;
      | ~~~~~~~~~      
   34 | void solve(int u){
      | ~~~~~~~~~~~~~~~~~~
   35 |     sz[u]=(u<=n);
      |     ~~~~~~~~~~~~~
   36 |     for(auto v:bst[u]){
      |     ~~~~~~~~~~~~~~~~~~~
   37 |         solve(v);sz[u]+=sz[v];
      |         ~~~~~~~~~~~~~~~~~~~~~~
   38 |         if(u>n)ans-=sz[v]*(sz[v]-1)*sz(bst[u]-1);
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   39 |     }
      |     ~          
   40 |     if(u>n)ans-=(x-sz[u])*(x-sz[u]-1)*sz(bst[u]-1);
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
count_triplets.cpp:40:39: note: in expansion of macro 'sz'
   40 |     if(u>n)ans-=(x-sz[u])*(x-sz[u]-1)*sz(bst[u]-1);
      |                                       ^~
count_triplets.cpp:8:22: error: request for member 'size' in '1', which is of non-class type 'int'
    8 | #define sz(x) (int)x.size()
      |                      ^~~~
count_triplets.cpp:40:39: note: in expansion of macro 'sz'
   40 |     if(u>n)ans-=(x-sz[u])*(x-sz[u]-1)*sz(bst[u]-1);
      |                                       ^~