Submission #1150169

#TimeUsernameProblemLanguageResultExecution timeMemory
1150169Robert_juniorPaths (BOI18_paths)C++20
23 / 100
63 ms328 KiB
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(x) x.begin(), x.end()
#define ins insert
#define pb push_back
#define F first
#define S second
const int N = 101, M = 5e5 + 7;
int a[N], g[N][N];
void solve(){
    int n, m, k; 
    cin>>n>>m>>k;
    for(int i = 1; i <= n; i++){
        cin>>a[i];
    }
    for(int i = 1; i <= m; i++){
        int u, v;
        cin>>u>>v;
        g[u][v] = 1;
        g[v][u] = 1;
    }
    int ans[4] = {0, 0, 0, 0};
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(a[i] == a[j]) continue;
            for(int k = 1; k <= n; k++){
                if(a[i] == a[k] || a[j] == a[k ]) continue;
                for(int l = 1; l <= n; l++){
                    if(a[i] == a[l] || a[j] == a[l] || a[k] == a[l]) continue;
                    if(g[i][j] && g[j][k] && g[k][l]) ans[3]++;
                }
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(a[i] == a[j]) continue;
            for(int k = 1; k <= n; k++){
                if(a[i] == a[k] || a[j] == a[k ]) continue;
                if(g[i][j] && g[j][k]) ans[2]++;
            }
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            if(a[i] == a[j]) continue;
            if(g[i][j]) ans[1]++;
        }
    }
    for(int i = 1; i <= n; i++){
        ans[0]++;
    }
    int res = 0;
    for(int i = 1; i < k; i++){
        res += ans[i];
    }
    cout<<res<<'\n';
}
main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    int t = 1;
    //cin>>t; 
    for(int i = 1; i <= t; i++){
        //cout<<"Case "<<i<<": ";
        solve();
    }
}

Compilation message (stderr)

paths.cpp:60:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   60 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...