Submission #8530054
Source Code Expand
// from https://atcoder.jp/contests/code-festival-2017-qualb/submissions/8517446 #include<bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) #define ll long long using namespace std; ll color[110000]; vector<ll> v[110000]; bool dfs(ll x, ll c){ color[x]=c; rep(i, v[x].size()){ if(color[v[x][i]]==c)return false; if(color[v[x][i]]==0 && !dfs(v[x][i], -c) )return false; } return true; } int main(){ ll n,m; cin>>n>>m; rep(i, m){ ll a,b; cin>>a>>b; v[a].push_back(b); v[b].push_back(a); } if(dfs(1,1)){ ll count=0; rep(i, n){ if(color[i]==1)count++; } cout<<count*(n-count)-m; }else{ cout<<n*(n-1)/2-m; } return 0; }
Submission Info
Submission Time | |
---|---|
Task | C - 3 Steps |
User | colorbox |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 754 Byte |
Status | WA |
Exec Time | 83 ms |
Memory | 7680 KB |
Judge Result
Set Name | sample | all | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 500 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
sample | sample-01.txt, sample-02.txt |
all | sample-01.txt, sample-02.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt, 02-01.txt, 02-02.txt, 02-03.txt, 02-04.txt, 02-05.txt, 02-06.txt, 02-07.txt, 02-08.txt, 02-09.txt, 02-10.txt, 02-11.txt, 02-12.txt, 02-13.txt, 02-14.txt, sample-01.txt, sample-02.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01-01.txt | AC | 2 ms | 2816 KB |
01-02.txt | WA | 2 ms | 2816 KB |
01-03.txt | AC | 2 ms | 2816 KB |
01-04.txt | AC | 2 ms | 2816 KB |
01-05.txt | AC | 3 ms | 2816 KB |
01-06.txt | AC | 3 ms | 2816 KB |
01-07.txt | AC | 3 ms | 2816 KB |
01-08.txt | WA | 3 ms | 2816 KB |
01-09.txt | AC | 3 ms | 2944 KB |
01-10.txt | AC | 5 ms | 2944 KB |
02-01.txt | AC | 73 ms | 7040 KB |
02-02.txt | AC | 77 ms | 7296 KB |
02-03.txt | AC | 76 ms | 7296 KB |
02-04.txt | AC | 80 ms | 7296 KB |
02-05.txt | AC | 83 ms | 7296 KB |
02-06.txt | AC | 83 ms | 7296 KB |
02-07.txt | AC | 72 ms | 6400 KB |
02-08.txt | AC | 73 ms | 7040 KB |
02-09.txt | AC | 74 ms | 7296 KB |
02-10.txt | WA | 49 ms | 5632 KB |
02-11.txt | WA | 59 ms | 5888 KB |
02-12.txt | WA | 73 ms | 7040 KB |
02-13.txt | WA | 74 ms | 7168 KB |
02-14.txt | WA | 79 ms | 7680 KB |
sample-01.txt | AC | 2 ms | 2816 KB |
sample-02.txt | AC | 2 ms | 2816 KB |