# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
173519 | rzbt | Paths (BOI18_paths) | C++14 | 549 ms | 107512 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define MAXN 300005
typedef long long ll;
using namespace std;
vector<ll> niz[MAXN];
ll dp[MAXN][35];
ll koji[MAXN];
ll n,m,k;
ll res=0;
int main()
{
scanf("%lld %lld %lld", &n, &m, &k);
for(ll i=1;i<=n;i++){
ll t;
scanf("%lld", &t);
t--;
dp[i][1<<t]=1;
koji[i]=1<<t;
}
for(ll i=1;i<=m;i++){
ll t1,t2;
scanf("%lld %lld", &t1, &t2);
niz[t1].pb(t2);
niz[t2].pb(t1);
}
for(ll j=1;j<(1<<k);j++){
for(ll i=1;i<=n;i++){
if(!(koji[i]&j))continue;
for(auto x:niz[i]){
dp[i][j]+=dp[x][j-koji[i]];
}
res+=dp[i][j];
//printf(" %lld %lld %lld\n",i,j,dp[i][j]);
}
}
printf("%lld",res-n);
return 0;
}
컴파일 시 표준 에러 (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... |