답안 #642588

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
642588 2022-09-20T07:18:27 Z andreast12 Paths (BOI18_paths) C++17
23 / 100
3000 ms 9184 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
const int mod=998244353, maxn=1e5+5;
int n, m, k, c[maxn], u, v, ans;
vector<int> adj[maxn];
bool vis[maxn];

void dfs(int now, int state, int jml) {
    if(!vis[now]&&(((1<<c[now])&state)==0)) {
        if(jml==1) {
            ans++;
        } else {
            vis[now]=true;
            for(auto nxt:adj[now]) {
                dfs(nxt, state|(1<<c[now]), jml-1);
            }
        }
        vis[now]=false;
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n >> m >> k;
    for(int i=1; i<=n; i++) cin >> c[i];
    while(m--) {
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for(int jml=2; jml<=k; jml++) {
        for(int i=1; i<=n; i++) {
            dfs(i, 0, jml);
        }
    }
    cout << ans << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2680 KB Output is correct
4 Correct 2 ms 2680 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 2680 KB Output is correct
8 Correct 1 ms 2644 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 489 ms 9184 KB Output is correct
2 Correct 2329 ms 8568 KB Output is correct
3 Incorrect 9 ms 3412 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 2 ms 2680 KB Output is correct
4 Correct 2 ms 2680 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 2680 KB Output is correct
8 Correct 1 ms 2644 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 489 ms 9184 KB Output is correct
12 Correct 2329 ms 8568 KB Output is correct
13 Incorrect 9 ms 3412 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Execution timed out 3091 ms 4484 KB Time limit exceeded
3 Halted 0 ms 0 KB -