답안 #927158

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
927158 2024-02-14T10:42:36 Z vjudge1 Paths (BOI18_paths) C++17
20 / 100
589 ms 110264 KB
// By ObeliX
#include <bits/stdc++.h>
#pragma GCC target( "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#include <unordered_map>
#include <cstddef>
#include <cassert>
#include <bitset>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <queue>
#include <map>
#include <set>

using namespace std;

const long long N = 1e6 + 5;
const long long MOD = 1e9+7;
const long long INF = 1e18;

string al = "abcdefghijklmnopqrstuvwxyz";

long long n , m , k;
long long col[N];
long long cnt[10][N];

set <long long> g[N];

int main(){
    //freopen( "cinema.in" , "r" , stdin );
    //freopen( "cinema.out" , "w" , stdout );
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> k;
    for ( int i = 1 ; i <= n ; i++ ) {
        cin >> col[i];
    }
    if ( k == 1 ) {
        for ( int i = 1 ; i <= m ; i++ ) {
            long long x , y;
            cin >> x >> y;
        }
        cout << 0;
    }
    else if ( k == 2 ) {
        set <pair<long long , long long>> v;
        for ( int i = 1 ; i <= m ; i++ ) {
            long long x , y;
            cin >> x >> y;
            if ( col[x] != col[y] ) {
                v.insert( { x , y } );
                v.insert( { y , x } );
            }
        }
        cout << v.size();
    }
    else if ( k == 3 ) {
        long long ans = 0;
        set <pair<long long , long long>> v;
        for ( int i = 1 ; i <= m ; i++ ) {
            long long x , y;
            cin >> x >> y;
            if ( col[x] != col[y] ) {
                v.insert( { x , y } );
                v.insert( { y , x } );
                g[x].insert( y );
                cnt[col[y]][x]++;
                g[y].insert( x );
                cnt[col[x]][y]++;
            }
        }
        for ( auto it : v ) {
            ans += cnt[6-(col[it.first] + col[it.second])][it.second];
        }
        cout << ans + v.size();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 49756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 483 ms 99764 KB Output is correct
2 Correct 555 ms 100028 KB Output is correct
3 Correct 585 ms 110088 KB Output is correct
4 Correct 189 ms 70676 KB Output is correct
5 Correct 54 ms 51800 KB Output is correct
6 Correct 524 ms 108148 KB Output is correct
7 Correct 589 ms 109904 KB Output is correct
8 Correct 574 ms 110264 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 10 ms 49756 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 11 ms 49752 KB Output isn't correct
2 Halted 0 ms 0 KB -