Submission #426254

#TimeUsernameProblemLanguageResultExecution timeMemory
426254lovrotPaths (BOI18_paths)C++11
23 / 100
73 ms11040 KiB
#include <bits/stdc++.h> #define X first #define Y second #define ll long long using namespace std; const int N = 2010; int n,a,b; int c[N]; long long int out; long long int memo[N][N]; vector<int> p[N]; long long int dfs(int x,int y){ if(memo[x][y] != 0) return memo[x][y]; memo[x][y] = 1; for(int i=0;i<p[x].size();i++){ if((1<<c[p[x][i]]) & y) continue; memo[x][y]+=dfs(p[x][i],y+(1<<c[p[x][i]])); } return memo[x][y]; } int main(){ ios_base::sync_with_stdio(false); int m,k; cin >> n >> m >> k; for(int i=0;i<n;i++) cin >> c[i]; for(int i=0;i<m;i++){ cin >> a >> b; a--; b--; p[a].push_back(b); p[b].push_back(a); } for(int i=0;i<n;i++){ out+=dfs(i,0+(1<<c[i])); } cout<< out-n << "\n"; return 0; }

Compilation message (stderr)

paths.cpp: In function 'long long int dfs(int, int)':
paths.cpp:24:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |  for(int i=0;i<p[x].size();i++){
      |              ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...