| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1150185 | Robert_junior | Paths (BOI18_paths) | C++20 | 931 ms | 98400 KiB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define ins insert
#define pb push_back
#define F first
#define S second
const int N = 3e5 + 7, M = 5e5 + 7;
int a[N];
vector<int>g[N];
int cnt[N][33];
void solve(){
int n, m, k;
cin>>n>>m>>k;
int ans[6] = {0, 0, 0, 0, 0, 0};
int res = 0;
for(int i = 1; i <= n; i++){
cin>>a[i];
a[i]--;
cnt[i][(1<<a[i])]++;
}
for(int i = 1; i <= m; i++){
int u, v;
cin>>u>>v;
g[u].pb(v);
g[v].pb(u);
}
for(int i = 2; i <= 5; i++){
for(int v = 1; v <= n; v++){
for(auto to : g[v]){
for(int msk = 1; msk < (1<<5); msk++){
if((msk>>a[to]) & 1) continue;
if((__builtin_popcount((msk | (1<<a[to]))) != i)) continue;
cnt[to][(msk | (1<<a[to]))] += cnt[v][msk];
}
}
}
}
for(int v = 1; v <= n; v++){
for(int msk = 1; msk < (1<<5); msk++){
int cnt1 = __builtin_popcount(msk);
if(cnt1 <= 1 || cnt1 > k) continue;
res += cnt[v][msk];
}
}
cout<<res<<'\n';
}
main(){
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
//cin>>t;
for(int i = 1; i <= t; i++){
//cout<<"Case "<<i<<": ";
solve();
}
}컴파일 시 표준 에러 (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... | ||||
