# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
368941 |
2021-02-20T08:15:24 Z |
YJU |
Duathlon (APIO18_duathlon) |
C++14 |
|
170 ms |
66144 KB |
#include<bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector,Ofast")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ll N=1e6+5;
const ld pi=acos(-1);
const ll INF=(1LL<<60);
#define SQ(i) ((i)*(i))
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define setp setprecision
#define lwb lower_bound
#define SZ(_a) (ll)_a.size()
ll n,m,x,y;
ll low[N],depth[N],cnt=0,ptr,w[N],ans,sz[N];
vector<ll> G[N],v[N];
ll stk[N],now;
void DFS1(ll nd,ll pa){
++cnt;
low[nd]=depth[nd]=depth[pa]+1;
stk[++now]=nd;
for(ll i:v[nd]){
if(i==pa)continue;
if(depth[i]){
low[nd]=min(low[nd],depth[i]);
}else{
//
//
DFS1(i,nd);
if(low[i]==depth[nd]){
//cout<<"FIND BCC\n";
++ptr;
while(stk[now]!=nd){
//cout<<stk[now]<<" ";
++w[ptr];w[stk[now]]=-1;
G[stk[now]].pb(ptr);
G[ptr].pb(stk[now]);
--now;
}
//cout<<stk[now]<<"\n";
++w[ptr];w[stk[now]]=-1;
G[stk[now]].pb(ptr);
G[ptr].pb(stk[now]);
}
low[nd]=min(low[nd],low[i]);
}
}
}
void DFS2(ll nd,ll pa){
sz[nd]=(nd<=n?1:0);
for(auto i:G[nd]){
if(i==pa)continue;
DFS2(i,nd);
ans+=2*w[nd]*sz[nd]*sz[i];
sz[nd]+=sz[i];
}
ans+=2*w[nd]*sz[nd]*(cnt-sz[nd]);
}
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);
cin>>n>>m;
ptr=n;
REP(i,m){
cin>>x>>y;
v[x].pb(y),v[y].pb(x);
}
REP1(i,n){
if(!depth[i]){
cnt=now=0;
DFS1(i,0);
DFS2(i,0);
}
}
cout<<ans<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
47340 KB |
Output is correct |
2 |
Correct |
29 ms |
47340 KB |
Output is correct |
3 |
Correct |
29 ms |
47340 KB |
Output is correct |
4 |
Correct |
30 ms |
47340 KB |
Output is correct |
5 |
Correct |
29 ms |
47472 KB |
Output is correct |
6 |
Correct |
36 ms |
47400 KB |
Output is correct |
7 |
Incorrect |
33 ms |
47468 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
47340 KB |
Output is correct |
2 |
Correct |
29 ms |
47340 KB |
Output is correct |
3 |
Correct |
29 ms |
47340 KB |
Output is correct |
4 |
Correct |
30 ms |
47340 KB |
Output is correct |
5 |
Correct |
29 ms |
47472 KB |
Output is correct |
6 |
Correct |
36 ms |
47400 KB |
Output is correct |
7 |
Incorrect |
33 ms |
47468 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
149 ms |
66132 KB |
Output is correct |
2 |
Correct |
170 ms |
66144 KB |
Output is correct |
3 |
Incorrect |
135 ms |
59928 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
32 ms |
47340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
109 ms |
53484 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
38 ms |
47340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
96 ms |
53484 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
47340 KB |
Output is correct |
2 |
Correct |
29 ms |
47340 KB |
Output is correct |
3 |
Correct |
29 ms |
47340 KB |
Output is correct |
4 |
Correct |
30 ms |
47340 KB |
Output is correct |
5 |
Correct |
29 ms |
47472 KB |
Output is correct |
6 |
Correct |
36 ms |
47400 KB |
Output is correct |
7 |
Incorrect |
33 ms |
47468 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
37 ms |
47340 KB |
Output is correct |
2 |
Correct |
29 ms |
47340 KB |
Output is correct |
3 |
Correct |
29 ms |
47340 KB |
Output is correct |
4 |
Correct |
30 ms |
47340 KB |
Output is correct |
5 |
Correct |
29 ms |
47472 KB |
Output is correct |
6 |
Correct |
36 ms |
47400 KB |
Output is correct |
7 |
Incorrect |
33 ms |
47468 KB |
Output isn't correct |
8 |
Halted |
0 ms |
0 KB |
- |