Submission #537877

# Submission time Handle Problem Language Result Execution time Memory
537877 2022-03-15T18:35:51 Z __Variatto Paths (BOI18_paths) C++17
53 / 100
134 ms 31972 KB
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define ll long long
const int MAX=1e5+10, K=1<<5;
ll n, m, k, dp[K][MAX], kol[MAX];
vector<int>g[MAX];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin>>n>>m>>k;
    for(int i=1; i<=n; i++)
        cin>>kol[i];
    for(int i=1; i<=m; i++){
        int a,b;
        cin>>a>>b;
        g[a].pb(b), g[b].pb(a);
    }
    ll wyn=0;
    for(int i=1; i<K; i++){
        for(int v=1; v<=n; v++){
            if(!(i&(1<<(kol[v]-1)))) continue;
            if(__builtin_popcount(i)==1)
                dp[i][v]=1;
            //cout<<i<<" "<<kol[v]<<"\n";
            for(auto s:g[v])
                dp[i][v]+=dp[i-(1<<(kol[v]-1))][s];
            if(__builtin_popcount(i)>1)
                wyn+=dp[i][v];
        }
    }
    cout<<wyn<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2772 KB Output is correct
2 Correct 2 ms 2772 KB Output is correct
3 Correct 2 ms 2776 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2772 KB Output is correct
7 Correct 2 ms 2812 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
9 Correct 2 ms 2808 KB Output is correct
10 Correct 2 ms 2772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 68 ms 10488 KB Output is correct
2 Correct 52 ms 8804 KB Output is correct
3 Runtime error 21 ms 10740 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2772 KB Output is correct
2 Correct 2 ms 2772 KB Output is correct
3 Correct 2 ms 2776 KB Output is correct
4 Correct 2 ms 2772 KB Output is correct
5 Correct 2 ms 2772 KB Output is correct
6 Correct 2 ms 2772 KB Output is correct
7 Correct 2 ms 2812 KB Output is correct
8 Correct 2 ms 2772 KB Output is correct
9 Correct 2 ms 2808 KB Output is correct
10 Correct 2 ms 2772 KB Output is correct
11 Correct 68 ms 10488 KB Output is correct
12 Correct 52 ms 8804 KB Output is correct
13 Runtime error 21 ms 10740 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2772 KB Output is correct
2 Correct 20 ms 4752 KB Output is correct
3 Correct 17 ms 4740 KB Output is correct
4 Correct 100 ms 29408 KB Output is correct
5 Correct 111 ms 30216 KB Output is correct
6 Correct 129 ms 31972 KB Output is correct
7 Correct 18 ms 4692 KB Output is correct
8 Correct 119 ms 31040 KB Output is correct
9 Correct 91 ms 31820 KB Output is correct
10 Correct 96 ms 30192 KB Output is correct
11 Correct 57 ms 18244 KB Output is correct
12 Correct 62 ms 23876 KB Output is correct
13 Correct 59 ms 17124 KB Output is correct
14 Correct 124 ms 31748 KB Output is correct
15 Correct 134 ms 31948 KB Output is correct
16 Correct 2 ms 2804 KB Output is correct
17 Correct 2 ms 2772 KB Output is correct
18 Correct 2 ms 2772 KB Output is correct
19 Correct 2 ms 2772 KB Output is correct
20 Correct 2 ms 2772 KB Output is correct
21 Correct 2 ms 2812 KB Output is correct
22 Correct 1 ms 2772 KB Output is correct
23 Correct 2 ms 2804 KB Output is correct
24 Correct 2 ms 2804 KB Output is correct
25 Correct 2 ms 2812 KB Output is correct