Submission #473382

# Submission time Handle Problem Language Result Execution time Memory
473382 2021-09-15T12:57:39 Z fadi57 Paths (BOI18_paths) C++14
53 / 100
214 ms 56700 KB
#include<bits/stdc++.h>
using namespace std;
const int mx=1e5+10;
typedef long long ll;
int mod=1e9+7;
const int MXm=22;
#define F first
#define S second
const int inf=1e9+10;

 ll dp[mx][1<<5];
 int c[mx];
 vector<int>adj[mx];
 int n,m,k;
  ll solve(int node,int mask){

  ll &ret=dp[node][mask];
if(ret!=-1){

    return ret;
  }
 ret=1;

   for(auto it:adj[node]){
    if(!((1<<c[it])&mask)){

        ret+=solve(it,mask|(1<<c[it]));
    }
   }
 return ret;


  }
  int main(){
    memset(dp,-1,sizeof(dp));
    cin>>n>>m>>k;

    for(int i=1;i<=n;i++){
        cin>>c[i];
        c[i]--;
    }
  ll ans=0;
      for(int i=1;i<=m;i++){
       int a,b;cin>>a>>b;
       adj[a].push_back(b);
       adj[b].push_back(a);
      }
    for(int i=1;i<=n;i++){
        ans+=solve(i,1<<c[i]);
    }
  cout<<ans-n;

      }
# Verdict Execution time Memory Grader output
1 Correct 14 ms 27660 KB Output is correct
2 Correct 14 ms 27608 KB Output is correct
3 Correct 16 ms 27600 KB Output is correct
4 Correct 14 ms 27596 KB Output is correct
5 Correct 15 ms 27692 KB Output is correct
6 Correct 14 ms 27596 KB Output is correct
7 Correct 17 ms 27596 KB Output is correct
8 Correct 14 ms 27596 KB Output is correct
9 Correct 15 ms 27596 KB Output is correct
10 Correct 14 ms 27656 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 214 ms 31344 KB Output is correct
2 Correct 182 ms 31256 KB Output is correct
3 Runtime error 96 ms 56700 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 27660 KB Output is correct
2 Correct 14 ms 27608 KB Output is correct
3 Correct 16 ms 27600 KB Output is correct
4 Correct 14 ms 27596 KB Output is correct
5 Correct 15 ms 27692 KB Output is correct
6 Correct 14 ms 27596 KB Output is correct
7 Correct 17 ms 27596 KB Output is correct
8 Correct 14 ms 27596 KB Output is correct
9 Correct 15 ms 27596 KB Output is correct
10 Correct 14 ms 27656 KB Output is correct
11 Correct 214 ms 31344 KB Output is correct
12 Correct 182 ms 31256 KB Output is correct
13 Runtime error 96 ms 56700 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 13 ms 27596 KB Output is correct
2 Correct 88 ms 28688 KB Output is correct
3 Correct 70 ms 28788 KB Output is correct
4 Correct 150 ms 30900 KB Output is correct
5 Correct 155 ms 31600 KB Output is correct
6 Correct 187 ms 30784 KB Output is correct
7 Correct 76 ms 28868 KB Output is correct
8 Correct 172 ms 30860 KB Output is correct
9 Correct 133 ms 31564 KB Output is correct
10 Correct 156 ms 31676 KB Output is correct
11 Correct 146 ms 29700 KB Output is correct
12 Correct 143 ms 30992 KB Output is correct
13 Correct 143 ms 29780 KB Output is correct
14 Correct 187 ms 30756 KB Output is correct
15 Correct 171 ms 30968 KB Output is correct
16 Correct 15 ms 27592 KB Output is correct
17 Correct 15 ms 27656 KB Output is correct
18 Correct 15 ms 27596 KB Output is correct
19 Correct 16 ms 27596 KB Output is correct
20 Correct 14 ms 27596 KB Output is correct
21 Correct 14 ms 27620 KB Output is correct
22 Correct 14 ms 27596 KB Output is correct
23 Correct 14 ms 27612 KB Output is correct
24 Correct 14 ms 27668 KB Output is correct
25 Correct 14 ms 27596 KB Output is correct