Submission #579763

# Submission time Handle Problem Language Result Execution time Memory
579763 2022-06-19T19:28:36 Z HeyYouNotYouYou Paths (BOI18_paths) C++14
100 / 100
585 ms 112056 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] , col[N] , ans;
int dp[N][(1<<5)+5];
vector<int>edges[N];
int dfs(int node , int mask){
  if(dp[node][mask]!=-1){
    return dp[node][mask];
  }
  dp[node][mask]=1;
  for(auto e:edges[node]){
    if(!((1<<col[e])&mask)){
      dp[node][mask]+=dfs(e , mask|(1<<col[e]));
    }
  }
  return dp[node][mask];
}
int32_t main()
{
  //freopen("abc.in", "r", stdin);
  memset(dp,-1,sizeof dp);
  cin >> n >> m >> k ;
  for(int i = 1 ; i <= n ; i ++){
    cin >> x;
    col[i]=x;
  }
  for(int i = 0 ; i < m ; i ++)
  {
    int u , v ;
    cin >> u >> v;
    edges[u].push_back(v);
    edges[v].push_back(u);
  }
  for(int i = 1 ; i <= n ; i++)
  {
    ans+=dfs(i,1<<col[i]);
  }
  cout<<ans-n<<endl;
}
# Verdict Execution time Memory Grader output
1 Correct 36 ms 94192 KB Output is correct
2 Correct 37 ms 94176 KB Output is correct
3 Correct 36 ms 94128 KB Output is correct
4 Correct 43 ms 94144 KB Output is correct
5 Correct 38 ms 94120 KB Output is correct
6 Correct 37 ms 94164 KB Output is correct
7 Correct 37 ms 94244 KB Output is correct
8 Correct 36 ms 94164 KB Output is correct
9 Correct 36 ms 94208 KB Output is correct
10 Correct 38 ms 94220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 214 ms 101452 KB Output is correct
2 Correct 165 ms 101360 KB Output is correct
3 Correct 462 ms 107176 KB Output is correct
4 Correct 236 ms 102504 KB Output is correct
5 Correct 224 ms 102484 KB Output is correct
6 Correct 383 ms 104724 KB Output is correct
7 Correct 436 ms 111648 KB Output is correct
8 Correct 432 ms 112056 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 94192 KB Output is correct
2 Correct 37 ms 94176 KB Output is correct
3 Correct 36 ms 94128 KB Output is correct
4 Correct 43 ms 94144 KB Output is correct
5 Correct 38 ms 94120 KB Output is correct
6 Correct 37 ms 94164 KB Output is correct
7 Correct 37 ms 94244 KB Output is correct
8 Correct 36 ms 94164 KB Output is correct
9 Correct 36 ms 94208 KB Output is correct
10 Correct 38 ms 94220 KB Output is correct
11 Correct 214 ms 101452 KB Output is correct
12 Correct 165 ms 101360 KB Output is correct
13 Correct 462 ms 107176 KB Output is correct
14 Correct 236 ms 102504 KB Output is correct
15 Correct 224 ms 102484 KB Output is correct
16 Correct 383 ms 104724 KB Output is correct
17 Correct 436 ms 111648 KB Output is correct
18 Correct 432 ms 112056 KB Output is correct
19 Correct 194 ms 104288 KB Output is correct
20 Correct 170 ms 103644 KB Output is correct
21 Correct 465 ms 111556 KB Output is correct
22 Correct 247 ms 105852 KB Output is correct
23 Correct 232 ms 105948 KB Output is correct
24 Correct 337 ms 108660 KB Output is correct
25 Correct 443 ms 111548 KB Output is correct
26 Correct 426 ms 112008 KB Output is correct
27 Correct 202 ms 103680 KB Output is correct
28 Correct 223 ms 105648 KB Output is correct
29 Correct 585 ms 111576 KB Output is correct
30 Correct 406 ms 108240 KB Output is correct
31 Correct 491 ms 108224 KB Output is correct
32 Correct 519 ms 111652 KB Output is correct
33 Correct 45 ms 94168 KB Output is correct
34 Correct 38 ms 94216 KB Output is correct
35 Correct 43 ms 94208 KB Output is correct
36 Correct 36 ms 94124 KB Output is correct
37 Correct 36 ms 94164 KB Output is correct
38 Correct 35 ms 94228 KB Output is correct
39 Correct 36 ms 94220 KB Output is correct
40 Correct 37 ms 94208 KB Output is correct
41 Correct 37 ms 94224 KB Output is correct
42 Correct 42 ms 94136 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 36 ms 94192 KB Output is correct
2 Correct 92 ms 96404 KB Output is correct
3 Correct 77 ms 97128 KB Output is correct
4 Correct 141 ms 99752 KB Output is correct
5 Correct 130 ms 100304 KB Output is correct
6 Correct 186 ms 99768 KB Output is correct
7 Correct 88 ms 97152 KB Output is correct
8 Correct 165 ms 99868 KB Output is correct
9 Correct 134 ms 100244 KB Output is correct
10 Correct 144 ms 100448 KB Output is correct
11 Correct 181 ms 98308 KB Output is correct
12 Correct 133 ms 99260 KB Output is correct
13 Correct 148 ms 98704 KB Output is correct
14 Correct 202 ms 99812 KB Output is correct
15 Correct 167 ms 100044 KB Output is correct
16 Correct 37 ms 94120 KB Output is correct
17 Correct 37 ms 94176 KB Output is correct
18 Correct 41 ms 94124 KB Output is correct
19 Correct 37 ms 94160 KB Output is correct
20 Correct 38 ms 94140 KB Output is correct
21 Correct 39 ms 94156 KB Output is correct
22 Correct 42 ms 94148 KB Output is correct
23 Correct 40 ms 94132 KB Output is correct
24 Correct 38 ms 94156 KB Output is correct
25 Correct 37 ms 94232 KB Output is correct