Submission #63180

# Submission time Handle Problem Language Result Execution time Memory
63180 2018-08-01T04:09:48 Z 노영훈(#1832) Paths (BOI18_paths) C++11
70 / 100
605 ms 53176 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=300010, inf=2e9;

int n, m, k;
vector<int> G[MX];
int C[MX];

int A[MX][5];
int B[MX][25];

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    cin>>n>>m>>k;
    for(int i=1; i<=n; i++) cin>>C[i], C[i]--;
    for(int i=1; i<=m; i++){
        int u,v; cin>>u>>v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    for(int i=1; i<=n; i++) for(int x:G[i]) A[i][C[x]]++;
    for(int i=1; i<=n; i++) A[i][C[i]]=0;
    for(int i=1; i<=n; i++)
        for(int x:G[i])
            for(int j=0; j<k; j++) B[i][C[x]*5+j]+=A[x][j];

    ll ans=0;
    for(int i=1; i<=n; i++){
        // 2
        for(int a=0; a<k; a++) ans+=A[i][a];

        // 3
        for(int a=0; a<k; a++)
            for(int b=a+1; b<k; b++) ans+=2LL*A[i][a]*A[i][b];
        if(k==3) continue;

        // 4
        for(int a=0; a<k; a++) for(int b=0; b<k; b++) for(int c=0; c<k; c++){
            if(a==b || b==c || c==a) continue;
            if(a==C[i] || b==C[i] || c==C[i]) continue;
            ans+=1LL*A[i][a]*B[i][b*5+c];
        }
        if(k==4) continue;

        

    }

    cout<<ans<<'\n';

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7416 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 8 ms 7600 KB Output is correct
4 Correct 8 ms 7600 KB Output is correct
5 Correct 9 ms 7600 KB Output is correct
6 Correct 8 ms 7600 KB Output is correct
7 Correct 9 ms 7740 KB Output is correct
8 Correct 10 ms 7740 KB Output is correct
9 Correct 9 ms 7740 KB Output is correct
10 Correct 8 ms 7740 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 129 ms 11844 KB Output is correct
2 Correct 84 ms 11844 KB Output is correct
3 Correct 512 ms 52520 KB Output is correct
4 Correct 193 ms 52520 KB Output is correct
5 Correct 231 ms 52520 KB Output is correct
6 Correct 307 ms 52520 KB Output is correct
7 Correct 522 ms 52520 KB Output is correct
8 Correct 495 ms 53176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 7416 KB Output is correct
2 Correct 8 ms 7416 KB Output is correct
3 Correct 8 ms 7600 KB Output is correct
4 Correct 8 ms 7600 KB Output is correct
5 Correct 9 ms 7600 KB Output is correct
6 Correct 8 ms 7600 KB Output is correct
7 Correct 9 ms 7740 KB Output is correct
8 Correct 10 ms 7740 KB Output is correct
9 Correct 9 ms 7740 KB Output is correct
10 Correct 8 ms 7740 KB Output is correct
11 Correct 129 ms 11844 KB Output is correct
12 Correct 84 ms 11844 KB Output is correct
13 Correct 512 ms 52520 KB Output is correct
14 Correct 193 ms 52520 KB Output is correct
15 Correct 231 ms 52520 KB Output is correct
16 Correct 307 ms 52520 KB Output is correct
17 Correct 522 ms 52520 KB Output is correct
18 Correct 495 ms 53176 KB Output is correct
19 Correct 99 ms 53176 KB Output is correct
20 Correct 88 ms 53176 KB Output is correct
21 Correct 464 ms 53176 KB Output is correct
22 Correct 237 ms 53176 KB Output is correct
23 Correct 161 ms 53176 KB Output is correct
24 Correct 307 ms 53176 KB Output is correct
25 Correct 419 ms 53176 KB Output is correct
26 Correct 516 ms 53176 KB Output is correct
27 Correct 82 ms 53176 KB Output is correct
28 Correct 108 ms 53176 KB Output is correct
29 Correct 562 ms 53176 KB Output is correct
30 Correct 363 ms 53176 KB Output is correct
31 Correct 348 ms 53176 KB Output is correct
32 Correct 605 ms 53176 KB Output is correct
33 Correct 10 ms 53176 KB Output is correct
34 Correct 12 ms 53176 KB Output is correct
35 Correct 10 ms 53176 KB Output is correct
36 Correct 10 ms 53176 KB Output is correct
37 Correct 9 ms 53176 KB Output is correct
38 Correct 9 ms 53176 KB Output is correct
39 Correct 9 ms 53176 KB Output is correct
40 Correct 9 ms 53176 KB Output is correct
41 Correct 9 ms 53176 KB Output is correct
42 Correct 8 ms 53176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 53176 KB Output is correct
2 Incorrect 40 ms 53176 KB Output isn't correct
3 Halted 0 ms 0 KB -