Submission #69074682


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
#define rep(i, s, t) for(int i = (s); i <= (t); i ++)
#define per(i, s, t) for(int i = (s); i >= (t); i --)
template<typename T, typename T2>
inline void chmin(T &x, T2 &&y) { x = min(x, y); }
template<typename T, typename T2>
inline void chmax(T &x, T2 &&y) { x = max(x, y); }
typedef long long ll;

const int N = 2e5 + 5;
int d[N], n, m;

signed main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    cin >> n >> m;
    rep(i, 1, m)
    {
        int x, y; cin >> x >> y;
        d[x] ++, d[y] ++;
    }
    int cnt = 0;
    ll ans = 1ll * n * (n - 1) / 2;
    rep(i, 1, n)
    {
        if((n - 1 - d[i]) & 1)
            cnt ++, ans --;
    }
    // cerr << cnt << endl;
    assert(cnt % 2 == 0);
    ans += cnt / 2;
    cout << ans;

    return 0;
}

Submission Info

Submission Time
Task B - Triangle Toggle
User adam01
Language C++ 20 (gcc 12.2)
Score 500
Code Size 832 Byte
Status AC
Exec Time 21 ms
Memory 4384 KiB

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 3384 KiB
00_sample_01.txt AC 1 ms 3476 KiB
00_sample_02.txt AC 1 ms 3456 KiB
01_handmade_00.txt AC 1 ms 3468 KiB
01_handmade_01.txt AC 11 ms 4228 KiB
01_handmade_02.txt AC 11 ms 4224 KiB
01_handmade_03.txt AC 1 ms 3532 KiB
01_handmade_04.txt AC 1 ms 3460 KiB
01_handmade_05.txt AC 1 ms 3464 KiB
01_handmade_06.txt AC 1 ms 3520 KiB
01_handmade_07.txt AC 14 ms 3456 KiB
01_handmade_08.txt AC 15 ms 3524 KiB
02_random_00.txt AC 15 ms 3680 KiB
02_random_01.txt AC 18 ms 3604 KiB
02_random_02.txt AC 6 ms 4064 KiB
02_random_03.txt AC 18 ms 3720 KiB
02_random_04.txt AC 7 ms 3504 KiB
02_random_05.txt AC 20 ms 4384 KiB
02_random_06.txt AC 12 ms 4308 KiB
02_random_07.txt AC 21 ms 4172 KiB
02_random_08.txt AC 19 ms 4164 KiB
02_random_09.txt AC 21 ms 4304 KiB