# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
790111 | 2023-07-22T10:42:23 Z | Lyrically | Duathlon (APIO18_duathlon) | C++17 | 49 ms | 10832 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()) { res+=E[i]*(E[i]-1)*(E[i]-2); } else { res+=(E[i]-1)*(E[i]-2)*(E[i]-3)/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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 49 ms | 10832 KB | Output is correct |
2 | Correct | 36 ms | 10828 KB | Output is correct |
3 | Incorrect | 35 ms | 10680 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 38 ms | 10284 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 4948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 37 ms | 10256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 4948 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |