// 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];
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 );
g[y].insert( x );
}
}
for ( auto it : v ) {
for ( auto it1 : g[it.second] ) {
if ( col[it1] != col[it.first] && col[it1] != col[it.second] ) {
ans++;
}
}
}
cout << ans + v.size();
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
15 ms |
47704 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
3037 ms |
91476 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
15 ms |
47704 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
9 ms |
47708 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |