# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
669819 |
2022-12-07T11:00:25 Z |
ghostwriter |
Paths (BOI18_paths) |
C++17 |
|
137 ms |
32908 KB |
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include <debug.h>
#else
#define debug(...)
#endif
#define ft front
#define bk back
#define st first
#define nd second
#define ins insert
#define ers erase
#define pb push_back
#define pf push_front
#define _pb pop_back
#define _pf pop_front
#define lb lower_bound
#define ub upper_bound
#define mtp make_tuple
#define bg begin
#define ed end
#define all(x) (x).bg(), (x).ed()
#define sz(x) (int)(x).size()
typedef long long ll; typedef unsigned long long ull;
typedef double db; typedef long double ldb;
typedef pair<int, int> pi; typedef pair<ll, ll> pll;
typedef vector<int> vi; typedef vector<ll> vll; typedef vector<pi> vpi; typedef vector<pll> vpll;
typedef string str;
#define FOR(i, l, r) for (int i = (l); i <= (r); ++i)
#define FOS(i, r, l) for (int i = (r); i >= (l); --i)
#define FRN(i, n) for (int i = 0; i < (n); ++i)
#define FSN(i, n) for (int i = (n) - 1; i >= 0; --i)
#define EACH(i, x) for (auto &i : (x))
#define WHILE while
template<typename T> T gcd(T a, T b) { WHILE(b) { a = a % b; swap(a, b); } return a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define file "TEST"
mt19937 rd(chrono::steady_clock::now().time_since_epoch().count());
ll rand(ll l, ll r) { return uniform_int_distribution<ll>(l, r)(rd); }
/*
----------------------------------------------------------------
END OF TEMPLATE
----------------------------------------------------------------
Tran The Bao - ghostwriter
Training for VOI23 gold medal
----------------------------------------------------------------
GOAT
----------------------------------------------------------------
*/
const int N = 1e5 + 5;
int n, m, k, c[N];
ll d[N][1 << 5], rs = 0;
vi adj[N];
void input() {
cin >> n >> m >> k;
FOR(i, 1, n) {
cin >> c[i];
--c[i];
}
FOR(i, 1, m) {
int u, v;
cin >> u >> v;
adj[u].pb(v);
adj[v].pb(u);
}
}
void solve() {
FSN(j, 1 << k)
FOR(i, 1, n) {
if (!(j & (1 << c[i]))) continue;
EACH(z, adj[i])
if (!(j & (1 << c[z])))
d[i][j] += d[z][j | (1 << c[z])] + 1;
}
FOR(i, 1, n) rs += d[i][1 << c[i]];
cout << rs;
}
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
// freopen(file".inp", "r", stdin);
// freopen(file".out", "w", stdout);
input();
solve();
return 0;
}
/*
----------------------------------------------------------------
From Benq:
stuff you should look for
* int overflow, array bounds
* special cases (n=1?)
* do smth instead of nothing and stay organized
* WRITE STUFF DOWN
* DON'T GET STUCK ON ONE APPROACH
----------------------------------------------------------------
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2684 KB |
Output is correct |
3 |
Correct |
2 ms |
2584 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
1 ms |
2684 KB |
Output is correct |
9 |
Correct |
2 ms |
2684 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
62 ms |
10376 KB |
Output is correct |
2 |
Correct |
51 ms |
8704 KB |
Output is correct |
3 |
Incorrect |
6 ms |
3340 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
2 ms |
2684 KB |
Output is correct |
3 |
Correct |
2 ms |
2584 KB |
Output is correct |
4 |
Correct |
2 ms |
2644 KB |
Output is correct |
5 |
Correct |
2 ms |
2644 KB |
Output is correct |
6 |
Correct |
2 ms |
2644 KB |
Output is correct |
7 |
Correct |
2 ms |
2644 KB |
Output is correct |
8 |
Correct |
1 ms |
2684 KB |
Output is correct |
9 |
Correct |
2 ms |
2684 KB |
Output is correct |
10 |
Correct |
2 ms |
2644 KB |
Output is correct |
11 |
Correct |
62 ms |
10376 KB |
Output is correct |
12 |
Correct |
51 ms |
8704 KB |
Output is correct |
13 |
Incorrect |
6 ms |
3340 KB |
Output isn't correct |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
2644 KB |
Output is correct |
2 |
Correct |
32 ms |
4632 KB |
Output is correct |
3 |
Correct |
18 ms |
4672 KB |
Output is correct |
4 |
Correct |
78 ms |
32236 KB |
Output is correct |
5 |
Correct |
51 ms |
32896 KB |
Output is correct |
6 |
Correct |
121 ms |
32240 KB |
Output is correct |
7 |
Correct |
22 ms |
4660 KB |
Output is correct |
8 |
Correct |
89 ms |
32236 KB |
Output is correct |
9 |
Correct |
66 ms |
32908 KB |
Output is correct |
10 |
Correct |
70 ms |
32756 KB |
Output is correct |
11 |
Correct |
70 ms |
18312 KB |
Output is correct |
12 |
Correct |
77 ms |
25768 KB |
Output is correct |
13 |
Correct |
73 ms |
18396 KB |
Output is correct |
14 |
Correct |
137 ms |
32312 KB |
Output is correct |
15 |
Correct |
123 ms |
32224 KB |
Output is correct |
16 |
Correct |
2 ms |
2644 KB |
Output is correct |
17 |
Correct |
2 ms |
2644 KB |
Output is correct |
18 |
Correct |
2 ms |
2644 KB |
Output is correct |
19 |
Correct |
2 ms |
2644 KB |
Output is correct |
20 |
Correct |
2 ms |
2644 KB |
Output is correct |
21 |
Correct |
2 ms |
2644 KB |
Output is correct |
22 |
Correct |
2 ms |
2644 KB |
Output is correct |
23 |
Correct |
1 ms |
2644 KB |
Output is correct |
24 |
Correct |
2 ms |
2684 KB |
Output is correct |
25 |
Correct |
2 ms |
2684 KB |
Output is correct |