# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
790109 | 2023-07-22T10:39:43 Z | Lyrically | 철인 이종 경기 (APIO18_duathlon) | C++17 | 83 ms | 13076 KB |
#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; vector<int> edge[100005]; int deg[100005]; int Fa[100005]; vector<int> Set[100005]; int E[100005]; int Find(int x){return Fa[x]==x?x:Fa[x]=Find(Fa[x]);} void work() { rep1(i,n) { Set[Find(i)].pb(i); } rep1(i,n) { for(auto v:edge[i]) { if(i>=v){continue;} E[Find(i)]++; } } int res=0; rep1(i,n) { if(!Set[i].empty()) { if(E[i]==Set[i].size()) { //cyc res+=(E[i]*(E[i]-1))*(E[i]-2); } else { assert((E[i]==(int)Set[i].size()-1)); //chain int v=Set[i].size(); res+=v*(v-1)*(v-2)/3; } } } print(res); } signed main() { n=read(),m=read();rep1(i,n){Fa[i]=i;} rep1(i,m) { int u=read(),v=read();Fa[Find(u)]=Find(v); edge[u].pb(v),edge[v].pb(u); deg[u]++,deg[v]++; } bool f=1; rep1(i,n){f&=(deg[i]<=2);} if(f){work();return 0;} return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 73 ms | 10824 KB | Output is correct |
2 | Correct | 35 ms | 12012 KB | Output is correct |
3 | Correct | 47 ms | 11836 KB | Output is correct |
4 | Correct | 38 ms | 12308 KB | Output is correct |
5 | Correct | 34 ms | 12012 KB | Output is correct |
6 | Correct | 34 ms | 12008 KB | Output is correct |
7 | Correct | 38 ms | 11860 KB | Output is correct |
8 | Correct | 36 ms | 12192 KB | Output is correct |
9 | Correct | 36 ms | 12120 KB | Output is correct |
10 | Correct | 71 ms | 12016 KB | Output is correct |
11 | Correct | 83 ms | 13076 KB | Output is correct |
12 | Correct | 69 ms | 12820 KB | Output is correct |
13 | Correct | 63 ms | 12900 KB | Output is correct |
14 | Correct | 39 ms | 12780 KB | Output is correct |
15 | Correct | 47 ms | 12376 KB | Output is correct |
16 | Correct | 48 ms | 12244 KB | Output is correct |
17 | Correct | 7 ms | 10068 KB | Output is correct |
18 | Correct | 8 ms | 10068 KB | Output is correct |
19 | Correct | 7 ms | 9940 KB | Output is correct |
20 | Correct | 8 ms | 9940 KB | Output is correct |
21 | Correct | 7 ms | 9684 KB | Output is correct |
22 | Correct | 10 ms | 9684 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 4948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 46 ms | 10240 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 4948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 79 ms | 10212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |