답안 #206893

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
206893 2020-03-05T18:04:00 Z oko Paths (BOI18_paths) C++14
70 / 100
591 ms 211272 KB
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long n,m,k,a[300005],ans,dp[300005][40],vis[300005][40];
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 9 ms 7416 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 9 ms 7416 KB Output is correct
4 Correct 8 ms 7416 KB Output is correct
5 Correct 8 ms 7416 KB Output is correct
6 Correct 9 ms 7416 KB Output is correct
7 Correct 8 ms 7416 KB Output is correct
8 Correct 8 ms 7416 KB Output is correct
9 Correct 8 ms 7416 KB Output is correct
10 Correct 9 ms 7416 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 100 ms 14200 KB Output is correct
2 Correct 76 ms 11400 KB Output is correct
3 Correct 518 ms 210496 KB Output is correct
4 Correct 145 ms 34168 KB Output is correct
5 Correct 128 ms 34040 KB Output is correct
6 Correct 356 ms 145512 KB Output is correct
7 Correct 499 ms 210536 KB Output is correct
8 Correct 491 ms 211192 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7416 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 9 ms 7416 KB Output is correct
4 Correct 8 ms 7416 KB Output is correct
5 Correct 8 ms 7416 KB Output is correct
6 Correct 9 ms 7416 KB Output is correct
7 Correct 8 ms 7416 KB Output is correct
8 Correct 8 ms 7416 KB Output is correct
9 Correct 8 ms 7416 KB Output is correct
10 Correct 9 ms 7416 KB Output is correct
11 Correct 100 ms 14200 KB Output is correct
12 Correct 76 ms 11400 KB Output is correct
13 Correct 518 ms 210496 KB Output is correct
14 Correct 145 ms 34168 KB Output is correct
15 Correct 128 ms 34040 KB Output is correct
16 Correct 356 ms 145512 KB Output is correct
17 Correct 499 ms 210536 KB Output is correct
18 Correct 491 ms 211192 KB Output is correct
19 Correct 107 ms 17020 KB Output is correct
20 Correct 79 ms 13688 KB Output is correct
21 Correct 504 ms 210504 KB Output is correct
22 Correct 142 ms 34168 KB Output is correct
23 Correct 125 ms 34296 KB Output is correct
24 Correct 371 ms 145384 KB Output is correct
25 Correct 508 ms 210488 KB Output is correct
26 Correct 480 ms 211272 KB Output is correct
27 Correct 95 ms 13688 KB Output is correct
28 Correct 135 ms 19704 KB Output is correct
29 Correct 591 ms 210424 KB Output is correct
30 Correct 424 ms 112368 KB Output is correct
31 Correct 449 ms 112472 KB Output is correct
32 Correct 583 ms 210484 KB Output is correct
33 Correct 9 ms 7544 KB Output is correct
34 Correct 10 ms 7416 KB Output is correct
35 Correct 10 ms 7416 KB Output is correct
36 Correct 9 ms 7416 KB Output is correct
37 Correct 9 ms 7416 KB Output is correct
38 Correct 9 ms 7416 KB Output is correct
39 Correct 9 ms 7416 KB Output is correct
40 Correct 10 ms 7416 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 9 ms 7416 KB Output is correct
2 Incorrect 46 ms 8696 KB Output isn't correct
3 Halted 0 ms 0 KB -