# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
927149 |
2024-02-14T10:25:27 Z |
vjudge1 |
Paths (BOI18_paths) |
C++17 |
|
3000 ms |
45480 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];
vector <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 ) {
long long ans = 0;
for ( int i = 1 ; i <= m ; i++ ) {
long long x , y;
cin >> x >> y;
if ( col[x] != col[y] ) {
ans+=2;
}
}
cout << ans;
}
else if ( k == 3 ) {
long long ans = 0;
vector <pair<long long , long long>> v;
for ( int i = 1 ; i <= m ; i++ ) {
long long x , y;
cin >> x >> y;
g[x].push_back( y );
g[y].push_back( x );
if ( col[x] != col[y] ) {
v.push_back( { x , y } );
v.push_back( { y , x } );
ans+=2;
}
}
for ( auto it : v ) {
for ( auto it1 : g[it.second] ) {
if ( col[it1] != col[it.first] && col[it1] != col[it.second] ) {
ans++;
}
}
}
cout << ans;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
25176 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
395 ms |
40648 KB |
Output is correct |
2 |
Correct |
2025 ms |
39356 KB |
Output is correct |
3 |
Correct |
170 ms |
45480 KB |
Output is correct |
4 |
Correct |
41 ms |
25176 KB |
Output is correct |
5 |
Correct |
39 ms |
25180 KB |
Output is correct |
6 |
Execution timed out |
3053 ms |
42420 KB |
Time limit exceeded |
7 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
25176 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
25180 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |