Submission #645464

# Submission time Handle Problem Language Result Execution time Memory
645464 2022-09-27T07:49:20 Z mychecksedad Paths (BOI18_paths) C++17
23 / 100
62 ms 30228 KB
/* Author : Mychecksdead */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define PI 3.1415926535
#define pb push_back
#define setp() cout << setprecision(15)
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " is " << x << '\n';
const int N = 1e6+100, M = 1e5+10, F = 2147483646, K = 20;



int n, m, k, a[N];
ll ans = 0;
vector<int> g[N];


void dfs1(int v, int p, int d, vector<int> &x){
    if(d>1){    
        ans++;
    }
    for(int u: g[v]){
        if(u != p){
            if(x[a[u]]) continue;
            x[a[u]] = 1;
            dfs1(u, v, d + 1, x);
            x[a[u]] = 0;
        }
    }
}

void solve(){
    cin >> n >> m >> k;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    for(int i = 1; i <= n; ++i) --a[i];
    for(int i = 0; i < m; ++i){
        int u, v; cin >> u >> v;
        g[u].pb(v);
        g[v].pb(u);
    }
    if(n <= 100){
        vector<int> v (4);
        for(int i = 1; i <= n; ++i){
            v[0] = v[1] = v[2] = v[3] = 0;
            v[a[i]] = 1; 
            dfs1(i, 0, 1, v);
        }
    }else{

    }


    cout << ans;
}   





int main(){
    cin.tie(0); ios::sync_with_stdio(0);
    int T = 1, aa;
    // cin >> T;aa=T;
    while(T--){
        // cout << "Case #" << aa-T << ": ";
        solve();
        cout << '\n';
    }
    return 0;
 
}

Compilation message

paths.cpp: In function 'int main()':
paths.cpp:66:16: warning: unused variable 'aa' [-Wunused-variable]
   66 |     int T = 1, aa;
      |                ^~
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23764 KB Output is correct
3 Correct 12 ms 23816 KB Output is correct
4 Correct 12 ms 23820 KB Output is correct
5 Correct 12 ms 23820 KB Output is correct
6 Correct 13 ms 23724 KB Output is correct
7 Correct 13 ms 23764 KB Output is correct
8 Correct 11 ms 23764 KB Output is correct
9 Correct 11 ms 23816 KB Output is correct
10 Correct 11 ms 23764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 62 ms 30228 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 12 ms 23764 KB Output is correct
2 Correct 12 ms 23764 KB Output is correct
3 Correct 12 ms 23816 KB Output is correct
4 Correct 12 ms 23820 KB Output is correct
5 Correct 12 ms 23820 KB Output is correct
6 Correct 13 ms 23724 KB Output is correct
7 Correct 13 ms 23764 KB Output is correct
8 Correct 11 ms 23764 KB Output is correct
9 Correct 11 ms 23816 KB Output is correct
10 Correct 11 ms 23764 KB Output is correct
11 Incorrect 62 ms 30228 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 23736 KB Output isn't correct
2 Halted 0 ms 0 KB -