답안 #579755

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
579755 2022-06-19T19:07:44 Z HeyYouNotYouYou Paths (BOI18_paths) C++14
0 / 100
673 ms 42524 KB
#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});
  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]}]++;
        }
      }
    }
  }
  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()));
  cout<<ans<<endl;
}

Compilation message

paths.cpp: In function 'int32_t main()':
paths.cpp:34: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]
   34 |   for(int i = 0 ; i < v.size() ; i ++){
      |                   ~~^~~~~~~~~~
paths.cpp:35: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]
   35 |     for(int j = 0 ; j < col[v[i][0]].size() ; j ++){
      |                     ~~^~~~~~~~~~~~~~~~~~~~~
paths.cpp:36: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]
   36 |       for(int p = 0 ; p < col[v[i][1]].size() ; p ++){
      |                       ~~^~~~~~~~~~~~~~~~~~~~~
paths.cpp:48: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]
   48 |     for(int i = 1 ; i < v1.size() ; i++){
      |                     ~~^~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 14292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 673 ms 42524 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 8 ms 14292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 7 ms 14292 KB Output isn't correct
2 Halted 0 ms 0 KB -