# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1165229 | dzhoz0 | Paths (BOI18_paths) | C++20 | 365 ms | 78132 KiB |
/*
ghmt the cutie :3
UwU
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define INF 1e18
#define f first
#define s second
#define pii pair<int, int>
#define vi vector<int>
const int MOD = 1'000'000'000;
void setIO(string name = "")
{
ios_base::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
#ifdef LOCAL
freopen("inp.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#else
if (!name.empty())
{
freopen((name + ".INP").c_str(), "r", stdin);
freopen((name + ".OUT").c_str(), "w", stdout);
}
#endif
}
const int MAXN = 3e5 + 7;
ll dp[1 << 5][MAXN + 1];
int color[MAXN + 1];
vi g[MAXN + 1];
void solve()
{
int n, m; cin >> n >> m;
int k; cin >> k;
for(int i = 1; i <= n; i++) {
cin >> color[i]; color[i]--;
dp[1 << color[i]][i] = 1;
}
while(m--) {
int u, v; cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
for(int b = 0; b < (1 << 5); b++) {
for(int u = 1; u <= n; u++) {
if(b & (1 << color[u])) continue;
for(int v : g[u]) {
if(!(b & (1 << color[v]))) continue;
dp[b | (1 << color[u])][u] += dp[b][v];
}
}
}
ll res = 0;
for(int i = 1; i <= n; i++) {
for(int b = 0; b < (1 << 5); b++) {
if(__popcount(b) > 1) res += dp[b][i];
}
}
cout << res << '\n';
}
signed main()
{
setIO();
int t = 1;
// cin >> t;
while (t--)
solve();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |