Submission #2526968
Source Code Expand
#include <cstdio>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
int N, M;
std::vector<int> G[100000];
int col[100000];
bool dfs( int v, int c )
{
col[v] = c;
for( auto &u : G[v] )
{
if( col[u] == c )
return false;
if( !col[u] )
dfs( u, -c );
}
return true;
}
int main()
{
scanf( "%d%d", &N, &M );
rep( i, M )
{
int A, B;
scanf( "%d%d", &A, &B );
--A; --B;
G[A].push_back( B );
G[B].push_back( A );
}
bool bi = dfs( 0, 1 );
if( bi )
{
int B = 0, W = 0;
rep( i, N )
{
if( col[i] == 1 )
++W;
else
++B;
}
printf( "%d\n", B*W-M );
}
else
printf( "%d\n", N*(N-1)/2-M );
return 0;
}
Submission Info
Submission Time |
|
Task |
C - 3 Steps |
User |
As_sqr |
Language |
C++14 (GCC 5.4.1) |
Score |
0 |
Code Size |
809 Byte |
Status |
WA |
Exec Time |
41 ms |
Memory |
6912 KB |
Compile Error
./Main.cpp: In function ‘int main()’:
./Main.cpp:27:26: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf( "%d%d", &N, &M );
^
./Main.cpp:31:28: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf( "%d%d", &A, &B );
^
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 |
WA |
2 ms |
2560 KB |
01-02.txt |
AC |
2 ms |
2560 KB |
01-03.txt |
WA |
2 ms |
2560 KB |
01-04.txt |
WA |
2 ms |
2560 KB |
01-05.txt |
WA |
2 ms |
2560 KB |
01-06.txt |
AC |
2 ms |
2560 KB |
01-07.txt |
AC |
2 ms |
2560 KB |
01-08.txt |
AC |
2 ms |
2560 KB |
01-09.txt |
AC |
3 ms |
2688 KB |
01-10.txt |
AC |
3 ms |
2688 KB |
02-01.txt |
WA |
41 ms |
6784 KB |
02-02.txt |
WA |
40 ms |
6144 KB |
02-03.txt |
WA |
40 ms |
6144 KB |
02-04.txt |
WA |
40 ms |
6144 KB |
02-05.txt |
WA |
40 ms |
6144 KB |
02-06.txt |
WA |
40 ms |
6144 KB |
02-07.txt |
WA |
36 ms |
6016 KB |
02-08.txt |
WA |
40 ms |
6912 KB |
02-09.txt |
WA |
40 ms |
6528 KB |
02-10.txt |
AC |
18 ms |
3968 KB |
02-11.txt |
AC |
26 ms |
4352 KB |
02-12.txt |
AC |
36 ms |
5632 KB |
02-13.txt |
AC |
33 ms |
6016 KB |
02-14.txt |
AC |
39 ms |
6528 KB |
sample-01.txt |
AC |
2 ms |
2560 KB |
sample-02.txt |
AC |
2 ms |
2560 KB |