제출 #790101

#제출 시각아이디문제언어결과실행 시간메모리
790101Lyrically철인 이종 경기 (APIO18_duathlon)C++17
0 / 100
43 ms10756 KiB
#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)/2)*(E[i]-2); } else { //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; }

컴파일 시 표준 에러 (stderr) 메시지

count_triplets.cpp: In function 'void work()':
count_triplets.cpp:42:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |    if(E[i]==Set[i].size())
      |       ~~~~^~~~~~~~~~~~~~~
count_triplets.cpp: In function 'long long int read()':
count_triplets.cpp:8:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 | int read(){int x;scanf("%lld",&x);return x;}
      |                  ~~~~~^~~~~~~~~~~
count_triplets.cpp: In function 'void file(std::string)':
count_triplets.cpp:12:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |  freopen((s+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
count_triplets.cpp:13:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  freopen((s+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...