# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
59614 | 2018-07-22T17:50:24 Z | IvanC | Paths (BOI18_paths) | C++17 | 2212 ms | 109436 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int MAXN = 3*1e5 + 10; int N,M,K,cor[MAXN]; vector<int> grafo[MAXN]; ll tot,valor[MAXN]; void processa(vector<int> ordem){ if(ordem.size() == 1) return; for(int i = 1;i<=N;i++){ valor[i] = 0; if(cor[i] == ordem[0]) valor[i] = 1; } for(int i = 1;i<ordem.size()-1;i++){ for(int v = 1;v<=N;v++){ if(cor[v] != ordem[i]) continue; for(int u : grafo[v]){ if(cor[u] == ordem[i-1]) valor[v] += valor[u]; } } } for(int i = 1;i<=N;i++){ if(cor[i] != ordem.back()) continue; for(int u : grafo[i]){ if(cor[u] == ordem[ordem.size()-2]) tot += valor[u]; } } } int main(){ scanf("%d %d %d",&N,&M,&K); for(int i = 1;i<=N;i++){ scanf("%d",&cor[i]); cor[i]--; } for(int i =1;i<=M;i++){ int u,v; scanf("%d %d",&u,&v); grafo[u].push_back(v); grafo[v].push_back(u); } for(int bitmask = 1;bitmask < (1 << K);bitmask++){ vector<int> temp; for(int i = 0;i<K;i++){ if(bitmask & (1 << i)) temp.push_back(i); } do{ processa(temp); }while(next_permutation(temp.begin(),temp.end())); } printf("%lld\n",tot); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 7288 KB | Output is correct |
2 | Correct | 9 ms | 7400 KB | Output is correct |
3 | Correct | 11 ms | 7440 KB | Output is correct |
4 | Correct | 10 ms | 7648 KB | Output is correct |
5 | Correct | 10 ms | 7728 KB | Output is correct |
6 | Correct | 11 ms | 7728 KB | Output is correct |
7 | Correct | 12 ms | 7728 KB | Output is correct |
8 | Correct | 10 ms | 7728 KB | Output is correct |
9 | Correct | 10 ms | 7728 KB | Output is correct |
10 | Correct | 11 ms | 7728 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 159 ms | 14232 KB | Output is correct |
2 | Correct | 109 ms | 16224 KB | Output is correct |
3 | Correct | 651 ms | 29220 KB | Output is correct |
4 | Correct | 231 ms | 29220 KB | Output is correct |
5 | Correct | 231 ms | 29220 KB | Output is correct |
6 | Correct | 467 ms | 37580 KB | Output is correct |
7 | Correct | 518 ms | 44432 KB | Output is correct |
8 | Correct | 638 ms | 49700 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 8 ms | 7288 KB | Output is correct |
2 | Correct | 9 ms | 7400 KB | Output is correct |
3 | Correct | 11 ms | 7440 KB | Output is correct |
4 | Correct | 10 ms | 7648 KB | Output is correct |
5 | Correct | 10 ms | 7728 KB | Output is correct |
6 | Correct | 11 ms | 7728 KB | Output is correct |
7 | Correct | 12 ms | 7728 KB | Output is correct |
8 | Correct | 10 ms | 7728 KB | Output is correct |
9 | Correct | 10 ms | 7728 KB | Output is correct |
10 | Correct | 11 ms | 7728 KB | Output is correct |
11 | Correct | 159 ms | 14232 KB | Output is correct |
12 | Correct | 109 ms | 16224 KB | Output is correct |
13 | Correct | 651 ms | 29220 KB | Output is correct |
14 | Correct | 231 ms | 29220 KB | Output is correct |
15 | Correct | 231 ms | 29220 KB | Output is correct |
16 | Correct | 467 ms | 37580 KB | Output is correct |
17 | Correct | 518 ms | 44432 KB | Output is correct |
18 | Correct | 638 ms | 49700 KB | Output is correct |
19 | Correct | 191 ms | 49700 KB | Output is correct |
20 | Correct | 146 ms | 49700 KB | Output is correct |
21 | Correct | 598 ms | 58532 KB | Output is correct |
22 | Correct | 272 ms | 58532 KB | Output is correct |
23 | Correct | 205 ms | 58532 KB | Output is correct |
24 | Correct | 427 ms | 66928 KB | Output is correct |
25 | Correct | 614 ms | 73960 KB | Output is correct |
26 | Correct | 654 ms | 79004 KB | Output is correct |
27 | Correct | 228 ms | 79004 KB | Output is correct |
28 | Correct | 272 ms | 79004 KB | Output is correct |
29 | Correct | 1534 ms | 87968 KB | Output is correct |
30 | Correct | 1034 ms | 87968 KB | Output is correct |
31 | Correct | 1020 ms | 92048 KB | Output is correct |
32 | Correct | 1587 ms | 100672 KB | Output is correct |
33 | Correct | 12 ms | 100672 KB | Output is correct |
34 | Correct | 9 ms | 100672 KB | Output is correct |
35 | Correct | 9 ms | 100672 KB | Output is correct |
36 | Correct | 10 ms | 100672 KB | Output is correct |
37 | Correct | 9 ms | 100672 KB | Output is correct |
38 | Correct | 9 ms | 100672 KB | Output is correct |
39 | Correct | 8 ms | 100672 KB | Output is correct |
40 | Correct | 10 ms | 100672 KB | Output is correct |
41 | Correct | 9 ms | 100672 KB | Output is correct |
42 | Correct | 10 ms | 100672 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 11 ms | 100672 KB | Output is correct |
2 | Correct | 238 ms | 100672 KB | Output is correct |
3 | Correct | 46 ms | 100672 KB | Output is correct |
4 | Correct | 204 ms | 100672 KB | Output is correct |
5 | Correct | 144 ms | 100672 KB | Output is correct |
6 | Correct | 2212 ms | 100672 KB | Output is correct |
7 | Correct | 84 ms | 100672 KB | Output is correct |
8 | Correct | 473 ms | 100672 KB | Output is correct |
9 | Correct | 278 ms | 102400 KB | Output is correct |
10 | Correct | 291 ms | 103760 KB | Output is correct |
11 | Correct | 766 ms | 103760 KB | Output is correct |
12 | Correct | 1156 ms | 104964 KB | Output is correct |
13 | Correct | 810 ms | 105116 KB | Output is correct |
14 | Correct | 2179 ms | 107960 KB | Output is correct |
15 | Correct | 2099 ms | 109436 KB | Output is correct |
16 | Correct | 10 ms | 109436 KB | Output is correct |
17 | Correct | 10 ms | 109436 KB | Output is correct |
18 | Correct | 10 ms | 109436 KB | Output is correct |
19 | Correct | 10 ms | 109436 KB | Output is correct |
20 | Correct | 10 ms | 109436 KB | Output is correct |
21 | Correct | 9 ms | 109436 KB | Output is correct |
22 | Correct | 11 ms | 109436 KB | Output is correct |
23 | Correct | 10 ms | 109436 KB | Output is correct |
24 | Correct | 8 ms | 109436 KB | Output is correct |
25 | Correct | 9 ms | 109436 KB | Output is correct |