답안 #206894

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
206894 2020-03-05T18:05:08 Z oko Paths (BOI18_paths) C++14
100 / 100
653 ms 348244 KB
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long n,m,k,a[300005],ans,dp[300005][70],vis[300005][70];
vector<int>gr[300005];
long long dfs(int x,int mask)
{
    long long num=0;
    if(vis[x][mask])return dp[x][mask];
    vis[x][mask]=1;
    for(int i=0;i<gr[x].size();i++)
    {
        int u=gr[x][i];
        if((mask&(1<<a[u])))continue;
        num+=dfs(u,(mask|(1<<a[u])));
    }
    return dp[x][mask]=num+1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        gr[x].push_back(y);
        gr[y].push_back(x);
    }
    for(int i=1;i<=n;i++)ans+=dfs(i,(1<<a[i]));
    cout<<ans-n;
}

Compilation message

paths.cpp: In function 'long long int dfs(int, int)':
paths.cpp:11:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<gr[x].size();i++)
                 ~^~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 7416 KB Output is correct
2 Correct 9 ms 7544 KB Output is correct
3 Correct 9 ms 7416 KB Output is correct
4 Correct 9 ms 7416 KB Output is correct
5 Correct 9 ms 7416 KB Output is correct
6 Correct 9 ms 7544 KB Output is correct
7 Correct 9 ms 7416 KB Output is correct
8 Correct 8 ms 7544 KB Output is correct
9 Correct 8 ms 7416 KB Output is correct
10 Correct 8 ms 7416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 95 ms 16636 KB Output is correct
2 Correct 76 ms 11768 KB Output is correct
3 Correct 590 ms 347644 KB Output is correct
4 Correct 153 ms 45560 KB Output is correct
5 Correct 130 ms 45628 KB Output is correct
6 Correct 402 ms 235860 KB Output is correct
7 Correct 571 ms 347384 KB Output is correct
8 Correct 549 ms 348244 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 7416 KB Output is correct
2 Correct 9 ms 7544 KB Output is correct
3 Correct 9 ms 7416 KB Output is correct
4 Correct 9 ms 7416 KB Output is correct
5 Correct 9 ms 7416 KB Output is correct
6 Correct 9 ms 7544 KB Output is correct
7 Correct 9 ms 7416 KB Output is correct
8 Correct 8 ms 7544 KB Output is correct
9 Correct 8 ms 7416 KB Output is correct
10 Correct 8 ms 7416 KB Output is correct
11 Correct 95 ms 16636 KB Output is correct
12 Correct 76 ms 11768 KB Output is correct
13 Correct 590 ms 347644 KB Output is correct
14 Correct 153 ms 45560 KB Output is correct
15 Correct 130 ms 45628 KB Output is correct
16 Correct 402 ms 235860 KB Output is correct
17 Correct 571 ms 347384 KB Output is correct
18 Correct 549 ms 348244 KB Output is correct
19 Correct 99 ms 17144 KB Output is correct
20 Correct 78 ms 12280 KB Output is correct
21 Correct 561 ms 347256 KB Output is correct
22 Correct 154 ms 45508 KB Output is correct
23 Correct 127 ms 45304 KB Output is correct
24 Correct 394 ms 235624 KB Output is correct
25 Correct 563 ms 347128 KB Output is correct
26 Correct 574 ms 347640 KB Output is correct
27 Correct 95 ms 11896 KB Output is correct
28 Correct 143 ms 20708 KB Output is correct
29 Correct 653 ms 347000 KB Output is correct
30 Correct 460 ms 178920 KB Output is correct
31 Correct 474 ms 179184 KB Output is correct
32 Correct 642 ms 346872 KB Output is correct
33 Correct 9 ms 7416 KB Output is correct
34 Correct 9 ms 7548 KB Output is correct
35 Correct 9 ms 7416 KB Output is correct
36 Correct 9 ms 7416 KB Output is correct
37 Correct 11 ms 7416 KB Output is correct
38 Correct 9 ms 7544 KB Output is correct
39 Correct 9 ms 7416 KB Output is correct
40 Correct 9 ms 7544 KB Output is correct
41 Correct 9 ms 7416 KB Output is correct
42 Correct 9 ms 7416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 7420 KB Output is correct
2 Correct 49 ms 8952 KB Output is correct
3 Correct 35 ms 9908 KB Output is correct
4 Correct 160 ms 121952 KB Output is correct
5 Correct 135 ms 122604 KB Output is correct
6 Correct 207 ms 121848 KB Output is correct
7 Correct 41 ms 9848 KB Output is correct
8 Correct 185 ms 121848 KB Output is correct
9 Correct 144 ms 122604 KB Output is correct
10 Correct 174 ms 122608 KB Output is correct
11 Correct 147 ms 65524 KB Output is correct
12 Correct 132 ms 94192 KB Output is correct
13 Correct 137 ms 65648 KB Output is correct
14 Correct 202 ms 121976 KB Output is correct
15 Correct 178 ms 121976 KB Output is correct
16 Correct 9 ms 7416 KB Output is correct
17 Correct 9 ms 7544 KB Output is correct
18 Correct 9 ms 7416 KB Output is correct
19 Correct 10 ms 7544 KB Output is correct
20 Correct 9 ms 7544 KB Output is correct
21 Correct 9 ms 7544 KB Output is correct
22 Correct 9 ms 7416 KB Output is correct
23 Correct 9 ms 7544 KB Output is correct
24 Correct 9 ms 7544 KB Output is correct
25 Correct 9 ms 7416 KB Output is correct