답안 #233853

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
233853 2020-05-22T02:02:06 Z gs18115 철인 이종 경기 (APIO18_duathlon) C++14
49 / 100
145 ms 52556 KB
#include<iostream>
#include<vector>
#include<algorithm>
#define ep emplace
#define eb emplace_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef pair<int,int>pi;
typedef pair<ll,ll>pl;
const int inf=1e9+7;
const ll INF=1e18+7;
vector<int>adj[100010];
vector<vector<pi> >bcc;
vector<pi>stk;
vector<int>cur;
int disc[100010];
int dct;
bool arp[100010];
int dfs(int x,int p)
{
    cur.eb(x);
    int ret=disc[x]=++dct;
    int c=0;
    for(int&t:adj[x])
    {
        if(t==p)
            continue;
        if(disc[t]!=0)
        {
            ret=min(ret,disc[t]);
            if(disc[x]>disc[t])
                stk.eb(t,x);
        }
        else
        {
            stk.eb(x,t);
            int rt=dfs(t,x);
            if(rt>=disc[x])
            {
                vector<pi>cb;
                pi b(-1,-1);
                while(b!=pi(x,t))
                {
                    b=stk.back();
                    stk.pop_back();
                    cb.eb(b);
                }
                bcc.eb(cb);
                c++;
            }
            ret=min(ret,rt);
        }
    }
    if(c-(p==0?1:0)>0)
        arp[x]=1;
    return ret;
}
vector<int>adj2[200010];
int sz[100010],siz[100010];
int pa[100010];
void dfs2(int x,int p)
{
    pa[x]=p;
    sz[x]=siz[x];
    for(int&t:adj2[x])
        if(t!=p)
            dfs2(t,x),sz[x]+=sz[t];
    return;
}
int num[100010];
inline ll npr(int n,int r)
{
    ll ret=1;
    for(int i=n;i>n-r;i--)
        ret*=i;
    return ret;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].eb(v);
        adj[v].eb(u);
    }
    ll ans=0;
    for(int v=0;v++<n;)
    {
        if(disc[v]==0)
        {
            cur.clear();
            bcc.clear();
            bcc.eb(vector<pi>());
            dfs(v,0);
            int bct=(int)bcc.size()-1,vct=bct;
            if(bct==0)
                continue;
            for(int&t:cur)
                if(arp[t])
                    num[t]=++vct;
            for(int i=0;i++<vct;)
                adj2[i].clear(),siz[i]=1;
            for(int i=0;i++<bct;)
            {
                vector<int>curv;
                for(pi&t:bcc[i])
                    curv.eb(t.fi),curv.eb(t.se);
                sort(all(curv));
                curv.erase(unique(all(curv)),curv.end());
                siz[i]=(int)curv.size();
                for(int&t:curv)
                    if(arp[t])
                        adj2[i].eb(num[t]),adj2[num[t]].eb(i),siz[i]--;
            }
            dfs2(1,0);
            ll cans=0;
            for(int i=0;i++<bct;)
            {
                int nsz=siz[i]+(int)adj2[i].size()-1;
                for(int&t:adj2[i])
                    if(t!=pa[i])
                        cans+=nsz*npr(sz[t],2);
                if(pa[i]!=0)
                    cans+=nsz*npr(sz[1]-sz[i],2);
            }
            ans+=npr(sz[1],3)-cans;
        }
    }
    cout<<ans<<endl;
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7424 KB Output is correct
2 Correct 9 ms 7424 KB Output is correct
3 Correct 8 ms 7424 KB Output is correct
4 Correct 9 ms 7424 KB Output is correct
5 Correct 8 ms 7424 KB Output is correct
6 Correct 9 ms 7424 KB Output is correct
7 Correct 8 ms 7424 KB Output is correct
8 Correct 9 ms 7424 KB Output is correct
9 Correct 8 ms 7424 KB Output is correct
10 Correct 9 ms 7424 KB Output is correct
11 Correct 8 ms 7424 KB Output is correct
12 Correct 8 ms 7424 KB Output is correct
13 Correct 9 ms 7424 KB Output is correct
14 Correct 8 ms 7424 KB Output is correct
15 Correct 9 ms 7424 KB Output is correct
16 Correct 9 ms 7424 KB Output is correct
17 Correct 9 ms 7424 KB Output is correct
18 Correct 8 ms 7424 KB Output is correct
19 Correct 8 ms 7424 KB Output is correct
20 Correct 9 ms 7424 KB Output is correct
21 Correct 9 ms 7424 KB Output is correct
22 Correct 9 ms 7424 KB Output is correct
23 Correct 8 ms 7424 KB Output is correct
24 Correct 9 ms 7424 KB Output is correct
25 Correct 9 ms 7424 KB Output is correct
26 Correct 9 ms 7424 KB Output is correct
27 Correct 9 ms 7424 KB Output is correct
28 Correct 8 ms 7424 KB Output is correct
29 Correct 9 ms 7424 KB Output is correct
30 Correct 8 ms 7424 KB Output is correct
31 Correct 10 ms 7424 KB Output is correct
32 Correct 8 ms 7424 KB Output is correct
33 Correct 8 ms 7424 KB Output is correct
34 Correct 9 ms 7424 KB Output is correct
35 Correct 8 ms 7424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7424 KB Output is correct
2 Correct 9 ms 7424 KB Output is correct
3 Correct 8 ms 7424 KB Output is correct
4 Correct 9 ms 7424 KB Output is correct
5 Correct 8 ms 7424 KB Output is correct
6 Correct 9 ms 7424 KB Output is correct
7 Correct 8 ms 7424 KB Output is correct
8 Correct 9 ms 7424 KB Output is correct
9 Correct 8 ms 7424 KB Output is correct
10 Correct 9 ms 7424 KB Output is correct
11 Correct 8 ms 7424 KB Output is correct
12 Correct 8 ms 7424 KB Output is correct
13 Correct 9 ms 7424 KB Output is correct
14 Correct 8 ms 7424 KB Output is correct
15 Correct 9 ms 7424 KB Output is correct
16 Correct 9 ms 7424 KB Output is correct
17 Correct 9 ms 7424 KB Output is correct
18 Correct 8 ms 7424 KB Output is correct
19 Correct 8 ms 7424 KB Output is correct
20 Correct 9 ms 7424 KB Output is correct
21 Correct 9 ms 7424 KB Output is correct
22 Correct 9 ms 7424 KB Output is correct
23 Correct 8 ms 7424 KB Output is correct
24 Correct 9 ms 7424 KB Output is correct
25 Correct 9 ms 7424 KB Output is correct
26 Correct 9 ms 7424 KB Output is correct
27 Correct 9 ms 7424 KB Output is correct
28 Correct 8 ms 7424 KB Output is correct
29 Correct 9 ms 7424 KB Output is correct
30 Correct 8 ms 7424 KB Output is correct
31 Correct 10 ms 7424 KB Output is correct
32 Correct 8 ms 7424 KB Output is correct
33 Correct 8 ms 7424 KB Output is correct
34 Correct 9 ms 7424 KB Output is correct
35 Correct 8 ms 7424 KB Output is correct
36 Correct 8 ms 7424 KB Output is correct
37 Correct 8 ms 7424 KB Output is correct
38 Correct 9 ms 7424 KB Output is correct
39 Correct 9 ms 7424 KB Output is correct
40 Correct 9 ms 7424 KB Output is correct
41 Correct 9 ms 7424 KB Output is correct
42 Correct 9 ms 7424 KB Output is correct
43 Correct 10 ms 7424 KB Output is correct
44 Correct 9 ms 7424 KB Output is correct
45 Correct 9 ms 7424 KB Output is correct
46 Correct 9 ms 7424 KB Output is correct
47 Correct 9 ms 7424 KB Output is correct
48 Correct 9 ms 7424 KB Output is correct
49 Correct 8 ms 7424 KB Output is correct
50 Correct 9 ms 7424 KB Output is correct
51 Correct 8 ms 7424 KB Output is correct
52 Correct 8 ms 7424 KB Output is correct
53 Correct 8 ms 7424 KB Output is correct
54 Correct 8 ms 7424 KB Output is correct
55 Correct 8 ms 7424 KB Output is correct
56 Correct 9 ms 7424 KB Output is correct
57 Correct 8 ms 7424 KB Output is correct
58 Correct 9 ms 7424 KB Output is correct
59 Correct 9 ms 7424 KB Output is correct
60 Correct 9 ms 7424 KB Output is correct
61 Correct 8 ms 7424 KB Output is correct
62 Correct 8 ms 7424 KB Output is correct
63 Correct 8 ms 7424 KB Output is correct
64 Correct 8 ms 7424 KB Output is correct
65 Correct 9 ms 7424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 99 ms 28760 KB Output is correct
2 Correct 100 ms 28760 KB Output is correct
3 Runtime error 138 ms 52556 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7552 KB Output is correct
2 Correct 9 ms 7552 KB Output is correct
3 Correct 9 ms 7552 KB Output is correct
4 Correct 9 ms 7680 KB Output is correct
5 Correct 9 ms 7680 KB Output is correct
6 Correct 9 ms 7680 KB Output is correct
7 Correct 9 ms 7680 KB Output is correct
8 Correct 10 ms 7680 KB Output is correct
9 Correct 9 ms 7680 KB Output is correct
10 Correct 9 ms 7552 KB Output is correct
11 Correct 9 ms 7552 KB Output is correct
12 Correct 9 ms 7552 KB Output is correct
13 Correct 9 ms 7552 KB Output is correct
14 Correct 9 ms 7424 KB Output is correct
15 Correct 9 ms 7424 KB Output is correct
16 Correct 9 ms 7424 KB Output is correct
17 Correct 9 ms 7552 KB Output is correct
18 Correct 9 ms 7552 KB Output is correct
19 Correct 9 ms 7552 KB Output is correct
20 Correct 9 ms 7552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 134 ms 47064 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7552 KB Output is correct
2 Correct 9 ms 7552 KB Output is correct
3 Correct 9 ms 7552 KB Output is correct
4 Correct 10 ms 7580 KB Output is correct
5 Correct 9 ms 7456 KB Output is correct
6 Correct 9 ms 7552 KB Output is correct
7 Correct 9 ms 7552 KB Output is correct
8 Correct 9 ms 7552 KB Output is correct
9 Correct 10 ms 7680 KB Output is correct
10 Correct 9 ms 7552 KB Output is correct
11 Correct 9 ms 7552 KB Output is correct
12 Correct 10 ms 7680 KB Output is correct
13 Correct 9 ms 7552 KB Output is correct
14 Correct 9 ms 7680 KB Output is correct
15 Correct 9 ms 7552 KB Output is correct
16 Correct 10 ms 7552 KB Output is correct
17 Correct 9 ms 7552 KB Output is correct
18 Correct 9 ms 7552 KB Output is correct
19 Correct 9 ms 7424 KB Output is correct
20 Correct 9 ms 7424 KB Output is correct
21 Correct 9 ms 7552 KB Output is correct
22 Correct 9 ms 7552 KB Output is correct
23 Correct 9 ms 7552 KB Output is correct
24 Correct 10 ms 7552 KB Output is correct
25 Correct 9 ms 7424 KB Output is correct
26 Correct 9 ms 7424 KB Output is correct
27 Correct 9 ms 7424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 145 ms 47292 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7424 KB Output is correct
2 Correct 9 ms 7424 KB Output is correct
3 Correct 8 ms 7424 KB Output is correct
4 Correct 9 ms 7424 KB Output is correct
5 Correct 8 ms 7424 KB Output is correct
6 Correct 9 ms 7424 KB Output is correct
7 Correct 8 ms 7424 KB Output is correct
8 Correct 9 ms 7424 KB Output is correct
9 Correct 8 ms 7424 KB Output is correct
10 Correct 9 ms 7424 KB Output is correct
11 Correct 8 ms 7424 KB Output is correct
12 Correct 8 ms 7424 KB Output is correct
13 Correct 9 ms 7424 KB Output is correct
14 Correct 8 ms 7424 KB Output is correct
15 Correct 9 ms 7424 KB Output is correct
16 Correct 9 ms 7424 KB Output is correct
17 Correct 9 ms 7424 KB Output is correct
18 Correct 8 ms 7424 KB Output is correct
19 Correct 8 ms 7424 KB Output is correct
20 Correct 9 ms 7424 KB Output is correct
21 Correct 9 ms 7424 KB Output is correct
22 Correct 9 ms 7424 KB Output is correct
23 Correct 8 ms 7424 KB Output is correct
24 Correct 9 ms 7424 KB Output is correct
25 Correct 9 ms 7424 KB Output is correct
26 Correct 9 ms 7424 KB Output is correct
27 Correct 9 ms 7424 KB Output is correct
28 Correct 8 ms 7424 KB Output is correct
29 Correct 9 ms 7424 KB Output is correct
30 Correct 8 ms 7424 KB Output is correct
31 Correct 10 ms 7424 KB Output is correct
32 Correct 8 ms 7424 KB Output is correct
33 Correct 8 ms 7424 KB Output is correct
34 Correct 9 ms 7424 KB Output is correct
35 Correct 8 ms 7424 KB Output is correct
36 Correct 8 ms 7424 KB Output is correct
37 Correct 8 ms 7424 KB Output is correct
38 Correct 9 ms 7424 KB Output is correct
39 Correct 9 ms 7424 KB Output is correct
40 Correct 9 ms 7424 KB Output is correct
41 Correct 9 ms 7424 KB Output is correct
42 Correct 9 ms 7424 KB Output is correct
43 Correct 10 ms 7424 KB Output is correct
44 Correct 9 ms 7424 KB Output is correct
45 Correct 9 ms 7424 KB Output is correct
46 Correct 9 ms 7424 KB Output is correct
47 Correct 9 ms 7424 KB Output is correct
48 Correct 9 ms 7424 KB Output is correct
49 Correct 8 ms 7424 KB Output is correct
50 Correct 9 ms 7424 KB Output is correct
51 Correct 8 ms 7424 KB Output is correct
52 Correct 8 ms 7424 KB Output is correct
53 Correct 8 ms 7424 KB Output is correct
54 Correct 8 ms 7424 KB Output is correct
55 Correct 8 ms 7424 KB Output is correct
56 Correct 9 ms 7424 KB Output is correct
57 Correct 8 ms 7424 KB Output is correct
58 Correct 9 ms 7424 KB Output is correct
59 Correct 9 ms 7424 KB Output is correct
60 Correct 9 ms 7424 KB Output is correct
61 Correct 8 ms 7424 KB Output is correct
62 Correct 8 ms 7424 KB Output is correct
63 Correct 8 ms 7424 KB Output is correct
64 Correct 8 ms 7424 KB Output is correct
65 Correct 9 ms 7424 KB Output is correct
66 Correct 8 ms 7424 KB Output is correct
67 Correct 9 ms 7424 KB Output is correct
68 Correct 9 ms 7552 KB Output is correct
69 Correct 9 ms 7552 KB Output is correct
70 Correct 10 ms 7680 KB Output is correct
71 Correct 9 ms 7424 KB Output is correct
72 Correct 9 ms 7424 KB Output is correct
73 Correct 9 ms 7424 KB Output is correct
74 Correct 9 ms 7424 KB Output is correct
75 Correct 9 ms 7552 KB Output is correct
76 Correct 9 ms 7424 KB Output is correct
77 Correct 9 ms 7552 KB Output is correct
78 Correct 9 ms 7552 KB Output is correct
79 Correct 9 ms 7424 KB Output is correct
80 Correct 10 ms 7552 KB Output is correct
81 Correct 9 ms 7552 KB Output is correct
82 Correct 9 ms 7552 KB Output is correct
83 Correct 9 ms 7552 KB Output is correct
84 Correct 9 ms 7552 KB Output is correct
85 Correct 9 ms 7552 KB Output is correct
86 Correct 9 ms 7544 KB Output is correct
87 Correct 9 ms 7424 KB Output is correct
88 Correct 9 ms 7424 KB Output is correct
89 Correct 9 ms 7424 KB Output is correct
90 Correct 9 ms 7424 KB Output is correct
91 Correct 9 ms 7552 KB Output is correct
92 Correct 9 ms 7552 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7424 KB Output is correct
2 Correct 9 ms 7424 KB Output is correct
3 Correct 8 ms 7424 KB Output is correct
4 Correct 9 ms 7424 KB Output is correct
5 Correct 8 ms 7424 KB Output is correct
6 Correct 9 ms 7424 KB Output is correct
7 Correct 8 ms 7424 KB Output is correct
8 Correct 9 ms 7424 KB Output is correct
9 Correct 8 ms 7424 KB Output is correct
10 Correct 9 ms 7424 KB Output is correct
11 Correct 8 ms 7424 KB Output is correct
12 Correct 8 ms 7424 KB Output is correct
13 Correct 9 ms 7424 KB Output is correct
14 Correct 8 ms 7424 KB Output is correct
15 Correct 9 ms 7424 KB Output is correct
16 Correct 9 ms 7424 KB Output is correct
17 Correct 9 ms 7424 KB Output is correct
18 Correct 8 ms 7424 KB Output is correct
19 Correct 8 ms 7424 KB Output is correct
20 Correct 9 ms 7424 KB Output is correct
21 Correct 9 ms 7424 KB Output is correct
22 Correct 9 ms 7424 KB Output is correct
23 Correct 8 ms 7424 KB Output is correct
24 Correct 9 ms 7424 KB Output is correct
25 Correct 9 ms 7424 KB Output is correct
26 Correct 9 ms 7424 KB Output is correct
27 Correct 9 ms 7424 KB Output is correct
28 Correct 8 ms 7424 KB Output is correct
29 Correct 9 ms 7424 KB Output is correct
30 Correct 8 ms 7424 KB Output is correct
31 Correct 10 ms 7424 KB Output is correct
32 Correct 8 ms 7424 KB Output is correct
33 Correct 8 ms 7424 KB Output is correct
34 Correct 9 ms 7424 KB Output is correct
35 Correct 8 ms 7424 KB Output is correct
36 Correct 8 ms 7424 KB Output is correct
37 Correct 8 ms 7424 KB Output is correct
38 Correct 9 ms 7424 KB Output is correct
39 Correct 9 ms 7424 KB Output is correct
40 Correct 9 ms 7424 KB Output is correct
41 Correct 9 ms 7424 KB Output is correct
42 Correct 9 ms 7424 KB Output is correct
43 Correct 10 ms 7424 KB Output is correct
44 Correct 9 ms 7424 KB Output is correct
45 Correct 9 ms 7424 KB Output is correct
46 Correct 9 ms 7424 KB Output is correct
47 Correct 9 ms 7424 KB Output is correct
48 Correct 9 ms 7424 KB Output is correct
49 Correct 8 ms 7424 KB Output is correct
50 Correct 9 ms 7424 KB Output is correct
51 Correct 8 ms 7424 KB Output is correct
52 Correct 8 ms 7424 KB Output is correct
53 Correct 8 ms 7424 KB Output is correct
54 Correct 8 ms 7424 KB Output is correct
55 Correct 8 ms 7424 KB Output is correct
56 Correct 9 ms 7424 KB Output is correct
57 Correct 8 ms 7424 KB Output is correct
58 Correct 9 ms 7424 KB Output is correct
59 Correct 9 ms 7424 KB Output is correct
60 Correct 9 ms 7424 KB Output is correct
61 Correct 8 ms 7424 KB Output is correct
62 Correct 8 ms 7424 KB Output is correct
63 Correct 8 ms 7424 KB Output is correct
64 Correct 8 ms 7424 KB Output is correct
65 Correct 9 ms 7424 KB Output is correct
66 Correct 99 ms 28760 KB Output is correct
67 Correct 100 ms 28760 KB Output is correct
68 Runtime error 138 ms 52556 KB Execution killed with signal 11 (could be triggered by violating memory limits)
69 Halted 0 ms 0 KB -