Submission #69076979


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	long ans=(long)n*(n-1)/2;
	vector<vector<int>>g(n);
	vector<int>deg(n);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		deg[u]++;
		deg[v]++;
	}
	int r=0;
	for(int i=0;i<n;i++)r+=(n-1-deg[i])&1;
	assert(r&1^1);
	cout<<ans-r/2<<'\n';
}

Submission Info

Submission Time
Task B - Triangle Toggle
User Kagemeka
Language C++ 20 (gcc 12.2)
Score 500
Code Size 347 Byte
Status AC
Exec Time 72 ms
Memory 8708 KiB

Compile Error

In file included from /usr/include/c++/12/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/12/bits/stdc++.h:33,
                 from Main.cpp:1:
Main.cpp: In function ‘int main()’:
Main.cpp:18:17: warning: suggest parentheses around arithmetic in operand of ‘^’ [-Wparentheses]
   18 |         assert(r&1^1);
      |                ~^~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 3
AC × 22
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3468 KiB
00_sample_01.txt AC 1 ms 3456 KiB
00_sample_02.txt AC 2 ms 6472 KiB
01_handmade_00.txt AC 4 ms 8596 KiB
01_handmade_01.txt AC 37 ms 8708 KiB
01_handmade_02.txt AC 37 ms 8652 KiB
01_handmade_03.txt AC 1 ms 3500 KiB
01_handmade_04.txt AC 1 ms 3472 KiB
01_handmade_05.txt AC 1 ms 3644 KiB
01_handmade_06.txt AC 1 ms 3560 KiB
01_handmade_07.txt AC 48 ms 3460 KiB
01_handmade_08.txt AC 48 ms 3528 KiB
02_random_00.txt AC 51 ms 4480 KiB
02_random_01.txt AC 62 ms 4164 KiB
02_random_02.txt AC 16 ms 7372 KiB
02_random_03.txt AC 63 ms 4916 KiB
02_random_04.txt AC 24 ms 3484 KiB
02_random_05.txt AC 70 ms 8608 KiB
02_random_06.txt AC 40 ms 8584 KiB
02_random_07.txt AC 71 ms 8700 KiB
02_random_08.txt AC 68 ms 8592 KiB
02_random_09.txt AC 72 ms 8660 KiB