#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N = 300001,INF=1e12;
int n , m , k , x , vis[N];
vector<int>col[5];
vector<set<int>>edges(N);
int ans=0;
int32_t main()
{
//freopen("abc.in", "r", stdin);
cin >> n >> m >> k ;
for(int i = 1 ; i <= n ; i ++){
cin >> x;
col[x].push_back(i);
}
for(int i = 0 ; i < m ; i ++)
{
int u , v ;
cin >> u >> v;
edges[u].insert(v);
edges[v].insert(u);
}
vector<vector<int>>v;
v.push_back({1,2});
if(k==3){
v.push_back({1,3});
//v.push_back({1,4});
v.push_back({2,3});}
// v.push_back({2,4});
// v.push_back({3,4});
map<pair<int,int>,int>mp;
int ans=0;
for(int i = 0 ; i < v.size() ; i ++){
for(int j = 0 ; j < col[v[i][0]].size() ; j ++){
for(int p = 0 ; p < col[v[i][1]].size() ; p ++){
if(edges[col[v[i][0]][j]].count(col[v[i][1]][p])){
ans+=2;
mp[{v[i][0],v[i][1]}]++;
mp[{v[i][1],v[i][0]}]++;
}
}
}
}
if(k==3){
vector<int>v1={1,2,3};
do{
int cur=1;
for(int i = 1 ; i < v1.size() ; i++){
// cout<<v1[i-1]<<" "<<v1[i]<<" "<<mp[{v1[i-1],v1[i]}]<<endl;
cur*=mp[{v1[i-1],v1[i]}];
}
ans+=cur;
}while(next_permutation(v1.begin(),v1.end()));}
else if(k==1){
ans=n;
}
cout<<ans<<endl;
}
Compilation message
paths.cpp: In function 'int32_t main()':
paths.cpp:35:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | for(int i = 0 ; i < v.size() ; i ++){
| ~~^~~~~~~~~~
paths.cpp:36:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | for(int j = 0 ; j < col[v[i][0]].size() ; j ++){
| ~~^~~~~~~~~~~~~~~~~~~~~
paths.cpp:37:25: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
37 | for(int p = 0 ; p < col[v[i][1]].size() ; p ++){
| ~~^~~~~~~~~~~~~~~~~~~~~
paths.cpp:50:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for(int i = 1 ; i < v1.size() ; i++){
| ~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
14292 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
720 ms |
42652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
14292 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
14292 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |