답안 #986246

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
986246 2024-05-20T06:37:00 Z Aiperiii Paths (BOI18_paths) C++14
70 / 100
456 ms 66452 KB
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
using namespace std;
const int N=3e5+5;
int cl[N],cnt[N][6];
vector <int> g[N][6];
signed main(){
    ios_base::sync_with_stdio();
    cin.tie(0);cout.tie(0);
    int n,m,k;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++)cin>>cl[i];
    while(m--){
        int u,v;
        cin>>u>>v;
        g[u][cl[v]].pb(v);
        g[v][cl[u]].pb(u);
    }
    int ans=0;
    if(k>=2){
        for(int i=1;i<=n;i++){
            for(int a=1;a<=k;a++){
                if(cl[i]!=a)ans+=g[i][a].size();
            }
        }
    }
    if(k>=3){
        for(int i=1;i<=n;i++){
            for(int a=1;a<=k;a++){
                for(int b=1;b<=k;b++){
                    if(a!=b && a!=cl[i] && b!=cl[i])ans+=g[i][a].size()*g[i][b].size();
                }
            }
        }
    }
    if(k>=4){
        for(int i=1;i<=n;i++){
            for(int b=1;b<=k;b++){
                for(int c=1;c<=k;c++){
                    for(int a=1;a<=k;a++){
                        if(a!=b && a!=cl[i] && b!=cl[i] && c!=b && c!=a && c!=cl[i]){
                            for(auto to : g[i][b])ans+=g[i][a].size()*g[to][c].size();
                        }
                    }
                    
                }
                
            }
        }
    }
    cout<<ans<<"\n";
}

/*
 4 3 3
 1 2 1 3
 1 2
 2 3
 4 2
 
 
9 11 4
1 2 3 4 1 2 1 2 2
1 2
1 3
2 3
2 4
3 6
6 2
6 5
4 3
4 5
7 8
9 8
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 45500 KB Output is correct
2 Correct 10 ms 45656 KB Output is correct
3 Correct 11 ms 45776 KB Output is correct
4 Correct 11 ms 45660 KB Output is correct
5 Correct 10 ms 45660 KB Output is correct
6 Correct 10 ms 45712 KB Output is correct
7 Correct 10 ms 45656 KB Output is correct
8 Correct 10 ms 45720 KB Output is correct
9 Correct 10 ms 45660 KB Output is correct
10 Correct 10 ms 45660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 129 ms 55616 KB Output is correct
2 Correct 102 ms 53684 KB Output is correct
3 Correct 321 ms 63344 KB Output is correct
4 Correct 166 ms 56056 KB Output is correct
5 Correct 164 ms 55792 KB Output is correct
6 Correct 259 ms 60108 KB Output is correct
7 Correct 319 ms 63572 KB Output is correct
8 Correct 313 ms 64340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 45500 KB Output is correct
2 Correct 10 ms 45656 KB Output is correct
3 Correct 11 ms 45776 KB Output is correct
4 Correct 11 ms 45660 KB Output is correct
5 Correct 10 ms 45660 KB Output is correct
6 Correct 10 ms 45712 KB Output is correct
7 Correct 10 ms 45656 KB Output is correct
8 Correct 10 ms 45720 KB Output is correct
9 Correct 10 ms 45660 KB Output is correct
10 Correct 10 ms 45660 KB Output is correct
11 Correct 129 ms 55616 KB Output is correct
12 Correct 102 ms 53684 KB Output is correct
13 Correct 321 ms 63344 KB Output is correct
14 Correct 166 ms 56056 KB Output is correct
15 Correct 164 ms 55792 KB Output is correct
16 Correct 259 ms 60108 KB Output is correct
17 Correct 319 ms 63572 KB Output is correct
18 Correct 313 ms 64340 KB Output is correct
19 Correct 126 ms 56656 KB Output is correct
20 Correct 100 ms 54784 KB Output is correct
21 Correct 322 ms 65684 KB Output is correct
22 Correct 166 ms 57424 KB Output is correct
23 Correct 157 ms 57184 KB Output is correct
24 Correct 252 ms 62072 KB Output is correct
25 Correct 326 ms 65284 KB Output is correct
26 Correct 314 ms 66348 KB Output is correct
27 Correct 104 ms 55120 KB Output is correct
28 Correct 147 ms 56732 KB Output is correct
29 Correct 456 ms 66452 KB Output is correct
30 Correct 301 ms 61488 KB Output is correct
31 Correct 332 ms 62624 KB Output is correct
32 Correct 439 ms 66128 KB Output is correct
33 Correct 11 ms 45772 KB Output is correct
34 Correct 10 ms 45696 KB Output is correct
35 Correct 10 ms 45660 KB Output is correct
36 Correct 11 ms 45660 KB Output is correct
37 Correct 10 ms 45744 KB Output is correct
38 Correct 10 ms 45660 KB Output is correct
39 Correct 10 ms 45656 KB Output is correct
40 Correct 10 ms 45660 KB Output is correct
41 Correct 11 ms 45680 KB Output is correct
42 Correct 10 ms 45656 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 45660 KB Output is correct
2 Incorrect 45 ms 48848 KB Output isn't correct
3 Halted 0 ms 0 KB -