Submission #1679340
Source Code Expand
#include<iostream> #include<cstdio> #include<cstring> template<typename T>inline void read(T &x) { char c=x=0; for(c=getchar();!isdigit(c);c=getchar()); for(;isdigit(c);c=getchar())x=(x<<3)+(x<<1)+(c^48); } namespace Good_problem { typedef long long ll; const int N=101000,M=N*4; int begin[N],next[M],to[M]; int n,m,e; ll A,B,C; void add(int x,int y,bool k=1) { to[++e]=y; next[e]=begin[x]; begin[x]=e; if(k)add(y,x,0); } int col[N]; bool dfs(int p,int x) { if(col[p])return col[p]==x; col[p]=x; bool ret=1; for(int i=begin[p],q;i;i=next[i]) if(!dfs(q=to[i],3-x))ret=0; return ret; } void initialize() { read(n),read(m); for(int i=1,u,v;i<=m;i++) read(u),read(v),add(u,v); } void solve() { initialize(); A=B=C=0; for(int i=1;i<=n;i++) if(!col[i]) { if(!dfs(i,1))B++; else if(begin[i])A++; else C++; } printf("%lld\n",2*A*A+2*A*B+B*B+2*n*C-C*C); } } int main() { Good_problem::solve(); return 0; }
Submission Info
Submission Time | |
---|---|
Task | A - Airport Bus |
User | Demerzel_IV |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 1043 Byte |
Status | RE |
Exec Time | 163 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 300 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt |
All | sample1.txt, sample2.txt, in1.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, sample1.txt, sample2.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in1.txt | WA | 1 ms | 256 KB |
in2.txt | RE | 163 ms | 256 KB |
in3.txt | RE | 100 ms | 256 KB |
in4.txt | RE | 102 ms | 256 KB |
in5.txt | WA | 1 ms | 256 KB |
in6.txt | RE | 99 ms | 256 KB |
in7.txt | RE | 101 ms | 256 KB |
in8.txt | RE | 98 ms | 256 KB |
sample1.txt | WA | 1 ms | 256 KB |
sample2.txt | WA | 1 ms | 256 KB |