답안 #1108301

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1108301 2024-11-03T17:21:19 Z overwatch9 Paths (BOI18_paths) C++17
23 / 100
3000 ms 12448 KB
#include <bits/stdc++.h>
using namespace std;
int n, m, k;
const int maxn = 3e5+1;
vector <int> adj[maxn];
int col[maxn];
int cnt;
bool vis[maxn];
void solve(int s, int p, int x, int len, int has) {
    if (vis[s] || len > k)
        return;
    vis[s] = true;
    if (len > 1)
        cnt++;
    for (auto i : adj[s]) {
        if (i == p)
            continue;
        if (has & (1 << col[i]))
            continue;
        solve(i, s, x + (1 << len) * col[i], len + 1, has + (1 << col[i]));
    }
    vis[s] = false;
}
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 >> col[i];
    for (int i = 0; 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++)
        solve(i, i, col[i], 1, (1 << col[i]));
    cout << cnt << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8784 KB Output is correct
2 Correct 3 ms 8784 KB Output is correct
3 Correct 2 ms 8636 KB Output is correct
4 Correct 2 ms 8784 KB Output is correct
5 Correct 2 ms 8784 KB Output is correct
6 Correct 2 ms 8784 KB Output is correct
7 Correct 2 ms 8784 KB Output is correct
8 Correct 2 ms 8784 KB Output is correct
9 Correct 2 ms 8784 KB Output is correct
10 Correct 2 ms 8784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2866 ms 12448 KB Output is correct
2 Execution timed out 3077 ms 12368 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8784 KB Output is correct
2 Correct 3 ms 8784 KB Output is correct
3 Correct 2 ms 8636 KB Output is correct
4 Correct 2 ms 8784 KB Output is correct
5 Correct 2 ms 8784 KB Output is correct
6 Correct 2 ms 8784 KB Output is correct
7 Correct 2 ms 8784 KB Output is correct
8 Correct 2 ms 8784 KB Output is correct
9 Correct 2 ms 8784 KB Output is correct
10 Correct 2 ms 8784 KB Output is correct
11 Correct 2866 ms 12448 KB Output is correct
12 Execution timed out 3077 ms 12368 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 8784 KB Output is correct
2 Execution timed out 3054 ms 9808 KB Time limit exceeded
3 Halted 0 ms 0 KB -