답안 #54035

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
54035 2018-07-02T08:43:05 Z Bodo171 철인 이종 경기 (APIO18_duathlon) C++14
49 / 100
1000 ms 60576 KB
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
const int nmax=300005;
vector <pair<int,int> > v[nmax];
vector<int> agatat[nmax],ad[nmax],li[nmax],vec[nmax];
long long ans;
int a[nmax],b[nmax],st[nmax],lev[nmax],low[nmax],unic[nmax],rada[nmax],ap[nmax],tt[nmax],L[nmax],gr[nmax];
int n,m,i,j,bcc,u,Xul;
void chestie(int x)
{
    if(unic[x]&&unic[x]!=bcc) unic[x]=-1;
    else unic[x]=bcc;
}
void mark(int P)
{
    li[bcc].push_back(a[st[u]]);
    li[bcc].push_back(b[st[u]]);
    chestie(a[st[u]]);
    chestie(b[st[u]]);
    while(!agatat[u].empty())
    {
        ad[n+bcc].push_back(agatat[u].back());
        ad[agatat[u].back()].push_back(n+bcc);
        agatat[u].pop_back();
    }
    if(st[u]==P)
    {
        u--;
        agatat[u].push_back(Xul);
        return;
    }
    u--;
    mark(P);
}
void dfs(int x)
{
    int nod=0;
    low[x]=lev[x];
    for(int i=0;i<v[x].size();i++)
        if(!lev[v[x][i].first])
    {
        nod=v[x][i].first;st[++u]=v[x][i].second;
        lev[nod]=lev[x]+1;
        dfs(nod);
        if(low[nod]<low[x]) low[x]=low[nod];
        if(low[nod]>=lev[x])
        {
            bcc++;
            ad[x].push_back(n+bcc);
            ad[n+bcc].push_back(x);
            Xul=x;
            mark(v[x][i].second);
        }
    }
    else low[x]=min(low[x],lev[v[x][i].first]);
}
void defeseu(int x)
{
    int nod=0;
    if(x<=n) ans+=1LL*L[x]-1;
    for(int i=0;i<vec[x].size();i++)
    {
        nod=vec[x][i];
        if(!tt[nod])
        {
            tt[nod]=x;
            L[nod]=L[x]+gr[nod];
            defeseu(nod);
        }
    }
}
int main()
{
    //freopen("data.in","r",stdin);
    cin>>n>>m;
    for(i=1;i<=m;i++)
    {
        cin>>a[i]>>b[i];
        v[a[i]].push_back({b[i],i});
        v[b[i]].push_back({a[i],i});
    }
    for(int rr=1;rr<=n;rr++)
        if(!lev[rr])
    {
        rada[rr]=1;
        lev[rr]=1;
        dfs(rr);
    }
    for(i=1;i<=n;i++)
        if(rada[i]==0&&unic[i]!=-1)
    {
        ad[n+unic[i]].push_back(i);
        ad[i].push_back(unic[i]+n);
    }
    for(i=1;i<=n+bcc;i++)
    {
        for(j=0;j<ad[i].size();j++)
            ap[ad[i][j]]=1;
        for(j=0;j<ad[i].size();j++)
            if(ap[ad[i][j]])
              ap[ad[i][j]]=0,vec[i].push_back(ad[i][j]);
        if(i>n) gr[i]=vec[i].size()-1;
    }
    //O(n) pana aici
    for(int rr=1;rr<=n;rr++)
    {
        for(i=1;i<=n+bcc;i++)
            tt[i]=L[i]=0;
        tt[rr]=-1;
        defeseu(rr);
        ans++;
    }
    //brutulica aici
    cout<<ans;
    return 0;
}

Compilation message

count_triplets.cpp: In function 'void dfs(int)':
count_triplets.cpp:41:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<v[x].size();i++)
                 ~^~~~~~~~~~~~
count_triplets.cpp: In function 'void defeseu(int)':
count_triplets.cpp:63:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<vec[x].size();i++)
                 ~^~~~~~~~~~~~~~
count_triplets.cpp: In function 'int main()':
count_triplets.cpp:99:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(j=0;j<ad[i].size();j++)
                 ~^~~~~~~~~~~~~
count_triplets.cpp:101:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(j=0;j<ad[i].size();j++)
                 ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 35576 KB Output is correct
2 Correct 31 ms 35576 KB Output is correct
3 Correct 32 ms 35724 KB Output is correct
4 Correct 31 ms 35724 KB Output is correct
5 Correct 31 ms 35724 KB Output is correct
6 Correct 32 ms 35800 KB Output is correct
7 Correct 35 ms 35800 KB Output is correct
8 Correct 32 ms 35800 KB Output is correct
9 Correct 33 ms 35800 KB Output is correct
10 Correct 34 ms 35800 KB Output is correct
11 Correct 32 ms 35800 KB Output is correct
12 Correct 33 ms 35800 KB Output is correct
13 Correct 33 ms 35800 KB Output is correct
14 Correct 32 ms 35800 KB Output is correct
15 Correct 32 ms 35800 KB Output is correct
16 Correct 32 ms 35800 KB Output is correct
17 Correct 32 ms 35800 KB Output is correct
18 Correct 37 ms 35800 KB Output is correct
19 Correct 31 ms 35912 KB Output is correct
20 Correct 33 ms 35912 KB Output is correct
21 Correct 33 ms 35912 KB Output is correct
22 Correct 31 ms 35912 KB Output is correct
23 Correct 31 ms 35912 KB Output is correct
24 Correct 31 ms 35912 KB Output is correct
25 Correct 36 ms 35912 KB Output is correct
26 Correct 31 ms 35912 KB Output is correct
27 Correct 32 ms 35912 KB Output is correct
28 Correct 34 ms 35912 KB Output is correct
29 Correct 32 ms 35912 KB Output is correct
30 Correct 32 ms 35912 KB Output is correct
31 Correct 32 ms 35912 KB Output is correct
32 Correct 34 ms 35912 KB Output is correct
33 Correct 32 ms 35912 KB Output is correct
34 Correct 32 ms 35912 KB Output is correct
35 Correct 30 ms 35912 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 35576 KB Output is correct
2 Correct 31 ms 35576 KB Output is correct
3 Correct 32 ms 35724 KB Output is correct
4 Correct 31 ms 35724 KB Output is correct
5 Correct 31 ms 35724 KB Output is correct
6 Correct 32 ms 35800 KB Output is correct
7 Correct 35 ms 35800 KB Output is correct
8 Correct 32 ms 35800 KB Output is correct
9 Correct 33 ms 35800 KB Output is correct
10 Correct 34 ms 35800 KB Output is correct
11 Correct 32 ms 35800 KB Output is correct
12 Correct 33 ms 35800 KB Output is correct
13 Correct 33 ms 35800 KB Output is correct
14 Correct 32 ms 35800 KB Output is correct
15 Correct 32 ms 35800 KB Output is correct
16 Correct 32 ms 35800 KB Output is correct
17 Correct 32 ms 35800 KB Output is correct
18 Correct 37 ms 35800 KB Output is correct
19 Correct 31 ms 35912 KB Output is correct
20 Correct 33 ms 35912 KB Output is correct
21 Correct 33 ms 35912 KB Output is correct
22 Correct 31 ms 35912 KB Output is correct
23 Correct 31 ms 35912 KB Output is correct
24 Correct 31 ms 35912 KB Output is correct
25 Correct 36 ms 35912 KB Output is correct
26 Correct 31 ms 35912 KB Output is correct
27 Correct 32 ms 35912 KB Output is correct
28 Correct 34 ms 35912 KB Output is correct
29 Correct 32 ms 35912 KB Output is correct
30 Correct 32 ms 35912 KB Output is correct
31 Correct 32 ms 35912 KB Output is correct
32 Correct 34 ms 35912 KB Output is correct
33 Correct 32 ms 35912 KB Output is correct
34 Correct 32 ms 35912 KB Output is correct
35 Correct 30 ms 35912 KB Output is correct
36 Correct 33 ms 35912 KB Output is correct
37 Correct 33 ms 35912 KB Output is correct
38 Correct 35 ms 35912 KB Output is correct
39 Correct 34 ms 35912 KB Output is correct
40 Correct 34 ms 35912 KB Output is correct
41 Correct 30 ms 35912 KB Output is correct
42 Correct 30 ms 35912 KB Output is correct
43 Correct 31 ms 35976 KB Output is correct
44 Correct 31 ms 35976 KB Output is correct
45 Correct 31 ms 35976 KB Output is correct
46 Correct 31 ms 35976 KB Output is correct
47 Correct 33 ms 35976 KB Output is correct
48 Correct 36 ms 35976 KB Output is correct
49 Correct 34 ms 35976 KB Output is correct
50 Correct 37 ms 35976 KB Output is correct
51 Correct 35 ms 35976 KB Output is correct
52 Correct 34 ms 35976 KB Output is correct
53 Correct 36 ms 35976 KB Output is correct
54 Correct 31 ms 35976 KB Output is correct
55 Correct 37 ms 35976 KB Output is correct
56 Correct 36 ms 35976 KB Output is correct
57 Correct 36 ms 35976 KB Output is correct
58 Correct 32 ms 35976 KB Output is correct
59 Correct 36 ms 35976 KB Output is correct
60 Correct 33 ms 35976 KB Output is correct
61 Correct 33 ms 35976 KB Output is correct
62 Correct 32 ms 35976 KB Output is correct
63 Correct 33 ms 35976 KB Output is correct
64 Correct 32 ms 35976 KB Output is correct
65 Correct 32 ms 35976 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1081 ms 57156 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 71 ms 57156 KB Output is correct
2 Correct 73 ms 57156 KB Output is correct
3 Correct 74 ms 57156 KB Output is correct
4 Correct 91 ms 57156 KB Output is correct
5 Correct 77 ms 57156 KB Output is correct
6 Correct 85 ms 57156 KB Output is correct
7 Correct 75 ms 57156 KB Output is correct
8 Correct 80 ms 57156 KB Output is correct
9 Correct 75 ms 57156 KB Output is correct
10 Correct 65 ms 57156 KB Output is correct
11 Correct 59 ms 57156 KB Output is correct
12 Correct 53 ms 57156 KB Output is correct
13 Correct 40 ms 57156 KB Output is correct
14 Correct 35 ms 57156 KB Output is correct
15 Correct 34 ms 57156 KB Output is correct
16 Correct 35 ms 57156 KB Output is correct
17 Correct 56 ms 57156 KB Output is correct
18 Correct 57 ms 57156 KB Output is correct
19 Correct 58 ms 57156 KB Output is correct
20 Correct 57 ms 57156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1084 ms 60576 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 73 ms 60576 KB Output is correct
2 Correct 69 ms 60576 KB Output is correct
3 Correct 67 ms 60576 KB Output is correct
4 Correct 75 ms 60576 KB Output is correct
5 Correct 52 ms 60576 KB Output is correct
6 Correct 48 ms 60576 KB Output is correct
7 Correct 55 ms 60576 KB Output is correct
8 Correct 49 ms 60576 KB Output is correct
9 Correct 46 ms 60576 KB Output is correct
10 Correct 45 ms 60576 KB Output is correct
11 Correct 46 ms 60576 KB Output is correct
12 Correct 64 ms 60576 KB Output is correct
13 Correct 67 ms 60576 KB Output is correct
14 Correct 62 ms 60576 KB Output is correct
15 Correct 64 ms 60576 KB Output is correct
16 Correct 53 ms 60576 KB Output is correct
17 Correct 49 ms 60576 KB Output is correct
18 Correct 42 ms 60576 KB Output is correct
19 Correct 33 ms 60576 KB Output is correct
20 Correct 36 ms 60576 KB Output is correct
21 Correct 59 ms 60576 KB Output is correct
22 Correct 58 ms 60576 KB Output is correct
23 Correct 57 ms 60576 KB Output is correct
24 Correct 57 ms 60576 KB Output is correct
25 Correct 32 ms 60576 KB Output is correct
26 Correct 33 ms 60576 KB Output is correct
27 Correct 38 ms 60576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1077 ms 60576 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 35576 KB Output is correct
2 Correct 31 ms 35576 KB Output is correct
3 Correct 32 ms 35724 KB Output is correct
4 Correct 31 ms 35724 KB Output is correct
5 Correct 31 ms 35724 KB Output is correct
6 Correct 32 ms 35800 KB Output is correct
7 Correct 35 ms 35800 KB Output is correct
8 Correct 32 ms 35800 KB Output is correct
9 Correct 33 ms 35800 KB Output is correct
10 Correct 34 ms 35800 KB Output is correct
11 Correct 32 ms 35800 KB Output is correct
12 Correct 33 ms 35800 KB Output is correct
13 Correct 33 ms 35800 KB Output is correct
14 Correct 32 ms 35800 KB Output is correct
15 Correct 32 ms 35800 KB Output is correct
16 Correct 32 ms 35800 KB Output is correct
17 Correct 32 ms 35800 KB Output is correct
18 Correct 37 ms 35800 KB Output is correct
19 Correct 31 ms 35912 KB Output is correct
20 Correct 33 ms 35912 KB Output is correct
21 Correct 33 ms 35912 KB Output is correct
22 Correct 31 ms 35912 KB Output is correct
23 Correct 31 ms 35912 KB Output is correct
24 Correct 31 ms 35912 KB Output is correct
25 Correct 36 ms 35912 KB Output is correct
26 Correct 31 ms 35912 KB Output is correct
27 Correct 32 ms 35912 KB Output is correct
28 Correct 34 ms 35912 KB Output is correct
29 Correct 32 ms 35912 KB Output is correct
30 Correct 32 ms 35912 KB Output is correct
31 Correct 32 ms 35912 KB Output is correct
32 Correct 34 ms 35912 KB Output is correct
33 Correct 32 ms 35912 KB Output is correct
34 Correct 32 ms 35912 KB Output is correct
35 Correct 30 ms 35912 KB Output is correct
36 Correct 33 ms 35912 KB Output is correct
37 Correct 33 ms 35912 KB Output is correct
38 Correct 35 ms 35912 KB Output is correct
39 Correct 34 ms 35912 KB Output is correct
40 Correct 34 ms 35912 KB Output is correct
41 Correct 30 ms 35912 KB Output is correct
42 Correct 30 ms 35912 KB Output is correct
43 Correct 31 ms 35976 KB Output is correct
44 Correct 31 ms 35976 KB Output is correct
45 Correct 31 ms 35976 KB Output is correct
46 Correct 31 ms 35976 KB Output is correct
47 Correct 33 ms 35976 KB Output is correct
48 Correct 36 ms 35976 KB Output is correct
49 Correct 34 ms 35976 KB Output is correct
50 Correct 37 ms 35976 KB Output is correct
51 Correct 35 ms 35976 KB Output is correct
52 Correct 34 ms 35976 KB Output is correct
53 Correct 36 ms 35976 KB Output is correct
54 Correct 31 ms 35976 KB Output is correct
55 Correct 37 ms 35976 KB Output is correct
56 Correct 36 ms 35976 KB Output is correct
57 Correct 36 ms 35976 KB Output is correct
58 Correct 32 ms 35976 KB Output is correct
59 Correct 36 ms 35976 KB Output is correct
60 Correct 33 ms 35976 KB Output is correct
61 Correct 33 ms 35976 KB Output is correct
62 Correct 32 ms 35976 KB Output is correct
63 Correct 33 ms 35976 KB Output is correct
64 Correct 32 ms 35976 KB Output is correct
65 Correct 32 ms 35976 KB Output is correct
66 Correct 37 ms 60576 KB Output is correct
67 Correct 35 ms 60576 KB Output is correct
68 Correct 47 ms 60576 KB Output is correct
69 Correct 44 ms 60576 KB Output is correct
70 Correct 43 ms 60576 KB Output is correct
71 Correct 34 ms 60576 KB Output is correct
72 Correct 36 ms 60576 KB Output is correct
73 Correct 36 ms 60576 KB Output is correct
74 Correct 33 ms 60576 KB Output is correct
75 Correct 33 ms 60576 KB Output is correct
76 Correct 31 ms 60576 KB Output is correct
77 Correct 59 ms 60576 KB Output is correct
78 Correct 53 ms 60576 KB Output is correct
79 Correct 47 ms 60576 KB Output is correct
80 Correct 46 ms 60576 KB Output is correct
81 Correct 46 ms 60576 KB Output is correct
82 Correct 43 ms 60576 KB Output is correct
83 Correct 43 ms 60576 KB Output is correct
84 Correct 52 ms 60576 KB Output is correct
85 Correct 55 ms 60576 KB Output is correct
86 Correct 53 ms 60576 KB Output is correct
87 Correct 40 ms 60576 KB Output is correct
88 Correct 43 ms 60576 KB Output is correct
89 Correct 34 ms 60576 KB Output is correct
90 Correct 35 ms 60576 KB Output is correct
91 Correct 49 ms 60576 KB Output is correct
92 Correct 48 ms 60576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 35576 KB Output is correct
2 Correct 31 ms 35576 KB Output is correct
3 Correct 32 ms 35724 KB Output is correct
4 Correct 31 ms 35724 KB Output is correct
5 Correct 31 ms 35724 KB Output is correct
6 Correct 32 ms 35800 KB Output is correct
7 Correct 35 ms 35800 KB Output is correct
8 Correct 32 ms 35800 KB Output is correct
9 Correct 33 ms 35800 KB Output is correct
10 Correct 34 ms 35800 KB Output is correct
11 Correct 32 ms 35800 KB Output is correct
12 Correct 33 ms 35800 KB Output is correct
13 Correct 33 ms 35800 KB Output is correct
14 Correct 32 ms 35800 KB Output is correct
15 Correct 32 ms 35800 KB Output is correct
16 Correct 32 ms 35800 KB Output is correct
17 Correct 32 ms 35800 KB Output is correct
18 Correct 37 ms 35800 KB Output is correct
19 Correct 31 ms 35912 KB Output is correct
20 Correct 33 ms 35912 KB Output is correct
21 Correct 33 ms 35912 KB Output is correct
22 Correct 31 ms 35912 KB Output is correct
23 Correct 31 ms 35912 KB Output is correct
24 Correct 31 ms 35912 KB Output is correct
25 Correct 36 ms 35912 KB Output is correct
26 Correct 31 ms 35912 KB Output is correct
27 Correct 32 ms 35912 KB Output is correct
28 Correct 34 ms 35912 KB Output is correct
29 Correct 32 ms 35912 KB Output is correct
30 Correct 32 ms 35912 KB Output is correct
31 Correct 32 ms 35912 KB Output is correct
32 Correct 34 ms 35912 KB Output is correct
33 Correct 32 ms 35912 KB Output is correct
34 Correct 32 ms 35912 KB Output is correct
35 Correct 30 ms 35912 KB Output is correct
36 Correct 33 ms 35912 KB Output is correct
37 Correct 33 ms 35912 KB Output is correct
38 Correct 35 ms 35912 KB Output is correct
39 Correct 34 ms 35912 KB Output is correct
40 Correct 34 ms 35912 KB Output is correct
41 Correct 30 ms 35912 KB Output is correct
42 Correct 30 ms 35912 KB Output is correct
43 Correct 31 ms 35976 KB Output is correct
44 Correct 31 ms 35976 KB Output is correct
45 Correct 31 ms 35976 KB Output is correct
46 Correct 31 ms 35976 KB Output is correct
47 Correct 33 ms 35976 KB Output is correct
48 Correct 36 ms 35976 KB Output is correct
49 Correct 34 ms 35976 KB Output is correct
50 Correct 37 ms 35976 KB Output is correct
51 Correct 35 ms 35976 KB Output is correct
52 Correct 34 ms 35976 KB Output is correct
53 Correct 36 ms 35976 KB Output is correct
54 Correct 31 ms 35976 KB Output is correct
55 Correct 37 ms 35976 KB Output is correct
56 Correct 36 ms 35976 KB Output is correct
57 Correct 36 ms 35976 KB Output is correct
58 Correct 32 ms 35976 KB Output is correct
59 Correct 36 ms 35976 KB Output is correct
60 Correct 33 ms 35976 KB Output is correct
61 Correct 33 ms 35976 KB Output is correct
62 Correct 32 ms 35976 KB Output is correct
63 Correct 33 ms 35976 KB Output is correct
64 Correct 32 ms 35976 KB Output is correct
65 Correct 32 ms 35976 KB Output is correct
66 Execution timed out 1081 ms 57156 KB Time limit exceeded
67 Halted 0 ms 0 KB -