답안 #206892

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
206892 2020-03-05T18:02:06 Z oko Paths (BOI18_paths) C++14
23 / 100
3000 ms 14072 KB
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long n,m,k,a[300005],ans;
vector<int>gr[300005];
long long dfs(int x,int mask)
{
    long long num=0;
    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 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:9: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 9 ms 7416 KB Output is correct
3 Correct 9 ms 7288 KB Output is correct
4 Correct 9 ms 7416 KB Output is correct
5 Correct 9 ms 7416 KB Output is correct
6 Correct 11 ms 7416 KB Output is correct
7 Correct 9 ms 7416 KB Output is correct
8 Correct 10 ms 7416 KB Output is correct
9 Correct 9 ms 7416 KB Output is correct
10 Correct 9 ms 7420 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2444 ms 14072 KB Output is correct
2 Execution timed out 3076 ms 13176 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7416 KB Output is correct
2 Correct 9 ms 7416 KB Output is correct
3 Correct 9 ms 7288 KB Output is correct
4 Correct 9 ms 7416 KB Output is correct
5 Correct 9 ms 7416 KB Output is correct
6 Correct 11 ms 7416 KB Output is correct
7 Correct 9 ms 7416 KB Output is correct
8 Correct 10 ms 7416 KB Output is correct
9 Correct 9 ms 7416 KB Output is correct
10 Correct 9 ms 7420 KB Output is correct
11 Correct 2444 ms 14072 KB Output is correct
12 Execution timed out 3076 ms 13176 KB Time limit exceeded
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 7416 KB Output is correct
2 Execution timed out 3075 ms 9208 KB Time limit exceeded
3 Halted 0 ms 0 KB -