# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1111699 |
2024-11-12T16:46:46 Z |
PagodePaiva |
Paths (BOI18_paths) |
C++17 |
|
331 ms |
39380 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 <= k;j++){
if(j == cor[x] or j == cor[v]) continue;
resp += dp[v][j];
}
}
res += resp;
}
return;
}
if(x == 4){
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 <= k;j++){
if(cor[x] == j or cor[v] == j) continue;
for(int t = 1;t <= k;t++){
if(cor[x] == t or cor[v] == t or j == t) continue;
resp += dp[v][j]*dp[x][t];
}
}
}
res += resp;
}
}
}
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 |
Correct |
2 ms |
11344 KB |
Output is correct |
2 |
Correct |
3 ms |
11428 KB |
Output is correct |
3 |
Correct |
3 ms |
11432 KB |
Output is correct |
4 |
Correct |
2 ms |
11344 KB |
Output is correct |
5 |
Correct |
3 ms |
11356 KB |
Output is correct |
6 |
Correct |
2 ms |
11344 KB |
Output is correct |
7 |
Correct |
3 ms |
11344 KB |
Output is correct |
8 |
Correct |
2 ms |
11344 KB |
Output is correct |
9 |
Correct |
3 ms |
11512 KB |
Output is correct |
10 |
Correct |
2 ms |
11344 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
101 ms |
22164 KB |
Output is correct |
2 |
Correct |
86 ms |
19784 KB |
Output is correct |
3 |
Correct |
192 ms |
34380 KB |
Output is correct |
4 |
Correct |
119 ms |
21576 KB |
Output is correct |
5 |
Correct |
124 ms |
20720 KB |
Output is correct |
6 |
Correct |
192 ms |
30392 KB |
Output is correct |
7 |
Correct |
243 ms |
34376 KB |
Output is correct |
8 |
Correct |
249 ms |
34888 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
11344 KB |
Output is correct |
2 |
Correct |
3 ms |
11428 KB |
Output is correct |
3 |
Correct |
3 ms |
11432 KB |
Output is correct |
4 |
Correct |
2 ms |
11344 KB |
Output is correct |
5 |
Correct |
3 ms |
11356 KB |
Output is correct |
6 |
Correct |
2 ms |
11344 KB |
Output is correct |
7 |
Correct |
3 ms |
11344 KB |
Output is correct |
8 |
Correct |
2 ms |
11344 KB |
Output is correct |
9 |
Correct |
3 ms |
11512 KB |
Output is correct |
10 |
Correct |
2 ms |
11344 KB |
Output is correct |
11 |
Correct |
101 ms |
22164 KB |
Output is correct |
12 |
Correct |
86 ms |
19784 KB |
Output is correct |
13 |
Correct |
192 ms |
34380 KB |
Output is correct |
14 |
Correct |
119 ms |
21576 KB |
Output is correct |
15 |
Correct |
124 ms |
20720 KB |
Output is correct |
16 |
Correct |
192 ms |
30392 KB |
Output is correct |
17 |
Correct |
243 ms |
34376 KB |
Output is correct |
18 |
Correct |
249 ms |
34888 KB |
Output is correct |
19 |
Correct |
114 ms |
19528 KB |
Output is correct |
20 |
Correct |
92 ms |
18792 KB |
Output is correct |
21 |
Correct |
271 ms |
38772 KB |
Output is correct |
22 |
Correct |
140 ms |
25116 KB |
Output is correct |
23 |
Correct |
185 ms |
24132 KB |
Output is correct |
24 |
Correct |
211 ms |
31928 KB |
Output is correct |
25 |
Correct |
264 ms |
38804 KB |
Output is correct |
26 |
Correct |
264 ms |
39380 KB |
Output is correct |
27 |
Correct |
117 ms |
18604 KB |
Output is correct |
28 |
Correct |
120 ms |
23112 KB |
Output is correct |
29 |
Correct |
245 ms |
38656 KB |
Output is correct |
30 |
Correct |
191 ms |
31100 KB |
Output is correct |
31 |
Correct |
215 ms |
31164 KB |
Output is correct |
32 |
Correct |
331 ms |
38728 KB |
Output is correct |
33 |
Correct |
3 ms |
11344 KB |
Output is correct |
34 |
Correct |
5 ms |
9296 KB |
Output is correct |
35 |
Correct |
3 ms |
9296 KB |
Output is correct |
36 |
Correct |
3 ms |
11344 KB |
Output is correct |
37 |
Correct |
5 ms |
11344 KB |
Output is correct |
38 |
Correct |
3 ms |
9296 KB |
Output is correct |
39 |
Correct |
3 ms |
11344 KB |
Output is correct |
40 |
Correct |
3 ms |
11512 KB |
Output is correct |
41 |
Correct |
3 ms |
9296 KB |
Output is correct |
42 |
Correct |
2 ms |
9552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
7672 KB |
Output is correct |
2 |
Incorrect |
38 ms |
10056 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |