답안 #538188

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
538188 2022-03-16T07:43:44 Z new_acc Paths (BOI18_paths) C++14
53 / 100
288 ms 31420 KB
#include<bits/stdc++.h>
#define fi first
#define se second
#define pitem item*
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=1e5+10;
ll dp[1<<5][N];
vi graf[N];
int k[N];
void solve(){
	int n,m,kk;
	cin>>n>>m>>kk;
	for(int i=1;i<=n;i++) cin>>k[i];
	for(int i=1,a,b,c;i<=m;i++){
		cin>>a>>b;
		graf[a].push_back(b),graf[b].push_back(a);
	}
	ll res=0;
	for(int i=1;i<(1<<kk);i++){
		for(int wsk=1;wsk<=n;wsk++){
			if((1<<(k[wsk]-1))&i){
				if(__builtin_popcount(i)==1) dp[i][wsk]=1;
				else for(auto u:graf[wsk]) dp[i][wsk]+=dp[i-(1<<(k[wsk]-1))][u];
			}
			res+=dp[i][wsk];
		}
	}
	cout<<res-n<<"\n";
}
int main(){
	solve();
}

Compilation message

paths.cpp: In function 'void solve()':
paths.cpp:17:18: warning: unused variable 'c' [-Wunused-variable]
   17 |  for(int i=1,a,b,c;i<=m;i++){
      |                  ^
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2644 KB Output is correct
2 Correct 3 ms 2660 KB Output is correct
3 Correct 3 ms 2660 KB Output is correct
4 Correct 3 ms 2664 KB Output is correct
5 Correct 3 ms 2644 KB Output is correct
6 Correct 3 ms 2644 KB Output is correct
7 Correct 2 ms 2664 KB Output is correct
8 Correct 2 ms 2672 KB Output is correct
9 Correct 3 ms 2664 KB Output is correct
10 Correct 3 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 229 ms 7880 KB Output is correct
2 Correct 147 ms 7644 KB Output is correct
3 Runtime error 80 ms 6724 KB Execution killed with signal 11
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2644 KB Output is correct
2 Correct 3 ms 2660 KB Output is correct
3 Correct 3 ms 2660 KB Output is correct
4 Correct 3 ms 2664 KB Output is correct
5 Correct 3 ms 2644 KB Output is correct
6 Correct 3 ms 2644 KB Output is correct
7 Correct 2 ms 2664 KB Output is correct
8 Correct 2 ms 2672 KB Output is correct
9 Correct 3 ms 2664 KB Output is correct
10 Correct 3 ms 2644 KB Output is correct
11 Correct 229 ms 7880 KB Output is correct
12 Correct 147 ms 7644 KB Output is correct
13 Runtime error 80 ms 6724 KB Execution killed with signal 11
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2772 KB Output is correct
2 Correct 55 ms 4692 KB Output is correct
3 Correct 50 ms 4488 KB Output is correct
4 Correct 149 ms 12628 KB Output is correct
5 Correct 111 ms 13260 KB Output is correct
6 Correct 280 ms 31320 KB Output is correct
7 Correct 54 ms 4604 KB Output is correct
8 Correct 160 ms 18808 KB Output is correct
9 Correct 146 ms 19584 KB Output is correct
10 Correct 152 ms 18676 KB Output is correct
11 Correct 142 ms 17968 KB Output is correct
12 Correct 147 ms 23440 KB Output is correct
13 Correct 130 ms 16912 KB Output is correct
14 Correct 276 ms 31396 KB Output is correct
15 Correct 288 ms 31420 KB Output is correct
16 Correct 3 ms 2672 KB Output is correct
17 Correct 2 ms 2664 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2664 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 3 ms 2644 KB Output is correct
22 Correct 2 ms 2660 KB Output is correct
23 Correct 2 ms 2664 KB Output is correct
24 Correct 3 ms 2644 KB Output is correct
25 Correct 3 ms 2644 KB Output is correct