| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 791944 | Lyrically | 철인 이종 경기 (APIO18_duathlon) | C++17 | 104 ms | 31132 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
int read(){int x;scanf("%lld",&x);return x;}
void print(int x){printf("%lld\n",x);}
void file(string s)
{
freopen((s+".in").c_str(),"r",stdin);
freopen((s+".out").c_str(),"w",stdout);
}
const int mod=998244353;
int n,m,tot,cnt,all;
int w[200005];
vector<int> edge[100005],g[200005];
int low[100005],dfn[100005];
stack<int> stk;
void tarjan(int x)
{
dfn[x]=low[x]=++tot;stk.push(x);
all++;
for(int to:edge[x])
{
if(dfn[to]){low[x]=min(low[x],dfn[to]);}
else
{
tarjan(to);
low[x]=min(low[x],low[to]);
if(low[to]==dfn[x])
{
cnt++;
while(!stk.empty())
{
int y=stk.top();stk.pop();
g[cnt].pb(y);
g[y].pb(cnt);
w[cnt]++;
if(y==to){break;}
}
g[cnt].pb(x);
g[x].pb(cnt);
w[cnt]++;
}
}
}
}
int res;
int sz[200005];
void dfs(int x,int fa)
{
sz[x]=(x<=n);
for(int to:g[x])
{
if(to==fa){continue;}
dfs(to,x);
res+=2*w[x]*sz[x]*sz[to];
sz[x]+=sz[to];
}
res+=2*w[x]*sz[x]*(all-sz[x]);
}
signed main()
{
n=read(),m=read();cnt=n;
rep1(i,n){w[i]=-1;}
rep1(i,m)
{
int u=read(),v=read();
edge[u].pb(v),edge[v].pb(u);
}
rep1(i,n)
{
if(!dfn[i])
{
all=0;
while(!stk.empty()){stk.pop();}
tarjan(i);
dfs(i,0);
}
}
print(res);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
