# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1111697 |
2024-11-12T16:43:33 Z |
PagodePaiva |
Paths (BOI18_paths) |
C++17 |
|
284 ms |
39424 KB |
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 300010;
int n,m, k;
vector <int> g[N];
int cor[N];
int res = 0;
int dp[N][6];
void solve(int x){
if(x == 2){
int t = 0;
for(int i = 1;i <= n;i++){
for(auto x : g[i]){
if(cor[x] != cor[i]) t++;
}
}
res += t;
return;
}
if(x == 3){
for(int v = 1;v <= n;v++){
int resp = 0;
for(auto x : g[v]){
if(cor[x] == cor[v]) continue;
for(int j = 1;j <= 5;j++){
if(j == cor[x] or j == cor[v]) continue;
resp += dp[v][j];
}
}
res += resp;
}
return;
}
}
int32_t main(){
cin >> n >> m >> k;
for(int i = 1;i <= n;i++){
cin >> cor[i];
}
for(int i = 0;i < m;i++){
int a, b;
cin >> a >> b;
g[a].push_back(b);
g[b].push_back(a);
}
for(int i = 1;i <= n;i++){
int v = i;
for(auto x : g[v]){
dp[v][cor[x]]++;
}
}
for(int i = 2;i <= k;i++){
solve(i);
}
cout << res << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
7504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
108 ms |
17736 KB |
Output is correct |
2 |
Correct |
90 ms |
16712 KB |
Output is correct |
3 |
Correct |
284 ms |
38732 KB |
Output is correct |
4 |
Correct |
131 ms |
20552 KB |
Output is correct |
5 |
Correct |
150 ms |
20552 KB |
Output is correct |
6 |
Correct |
211 ms |
31160 KB |
Output is correct |
7 |
Correct |
244 ms |
38732 KB |
Output is correct |
8 |
Correct |
269 ms |
39424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
7504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
7504 KB |
Output is correct |
2 |
Incorrect |
33 ms |
10320 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |