Submission #782536

# Submission time Handle Problem Language Result Execution time Memory
782536 2023-07-14T04:36:24 Z Cookie Paths (BOI18_paths) C++14
23 / 100
55 ms 8292 KB
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
ifstream fin("VNOICUP.INP");
ofstream fout("VNOICUP.OUT");
#define sz(a) (int)a.size()
#define ll long long
#define pb push_back
#define forr(i, a, b) for(int i = a; i < b; i++)
#define dorr(i, a, b) for(int i = a; i >= b; i--)
#define ld long double
#define vt vector
#include<fstream>
#define fi first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>
const ld PI = 3.14159265359;
using u128 = __uint128_t;
//const int x[4] = {1, -1, 0, 0};
//const int y[4] = {0, 0, 1, -1};
const ll mod = 1000001;
const int mxn = 1e4 + 1, mxq = 2e5 + 5, sq = 400, mxv = 2e7 + 5, p = 31;
//const int base = (1 << 18);
const ll inf = 1e9 + 5, neg = -69420;
ll dp[mxn + 1][(1 << 5)], c[mxn + 1];
int n, m, k;
vt<int>adj[mxn + 1];
void input(){
    cin >> n >> m >> k;
    for(int i = 1; i <= n; i++){
        cin >> c[i]; c[i]--;
        dp[i][(1 << c[i])] = 1;
    }
    forr(i, 0, m){
        int u, v; cin >> u >> v;
        adj[u].pb(v); adj[v].pb(u);
    }
}
void process(){
    ll ans = 0;
   for(int i = 1; i < (1 << k); i++){
      for(int j = 1; j <= n; j++){
         if((i >> c[j]) & 1){
            for(auto l: adj[j]){
                dp[j][i] += dp[l][i ^ (1 << c[j])];
            }
         }
         ans += dp[j][i];
      }
   }
   cout << ans - n;
}

signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    input();
    process();
    return(0);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 572 KB Output is correct
4 Correct 1 ms 580 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 576 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 55 ms 8292 KB Output is correct
2 Correct 34 ms 6548 KB Output is correct
3 Runtime error 5 ms 6228 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 572 KB Output is correct
4 Correct 1 ms 580 KB Output is correct
5 Correct 1 ms 596 KB Output is correct
6 Correct 1 ms 596 KB Output is correct
7 Correct 1 ms 576 KB Output is correct
8 Correct 1 ms 596 KB Output is correct
9 Correct 1 ms 468 KB Output is correct
10 Correct 1 ms 468 KB Output is correct
11 Correct 55 ms 8292 KB Output is correct
12 Correct 34 ms 6548 KB Output is correct
13 Runtime error 5 ms 6228 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 14 ms 2544 KB Output is correct
3 Correct 13 ms 2516 KB Output is correct
4 Runtime error 4 ms 6224 KB Execution killed with signal 11
5 Halted 0 ms 0 KB -