Problem:
Score : 100 points

Problem Statement

It is September 9 in Japan now.

You are given a two-digit integer N. Answer the question: Is 9 contained in the decimal notation of N?

Constraints

10≤N≤99

Input

Input is given from Standard Input in the following format:

N

Output

If 9 is contained in the decimal notation of N, print Yes; if not, print No.

Sample Input 1

29

Sample Output 1

Yes

The one's digit of 29 is 9.

Sample Input 2

72

Sample Output 2

No

72 does not contain 9.

Sample Input 3

91

Sample Output 3

Yes

Solution in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#include <bits/stdc++.h>
using namespace std;
const int maxn = 200 + 50;
const int INF = 10000000;
int n, m, r;
int R[maxn];
int g[maxn][maxn];
vector<int> G[maxn];
struct edge{
    int u, v;
    int cost;
    bool friend operator < (edge a, edge b){
        return a.cost < b.cost;
    }
}e[100];
int p[maxn];
int find(int  x){return p[x] == x? x : p[x] = find(p[x]);}
int main(){
  //  freopen("input.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m >> r;
    for(int i = 0; i < r; i++)
        cin >> R[i];
    for(int i = 0; i < m; i++){
        int u, v, c;
        cin >> u >> v >> c;
        g[u][v] = g[v][u] = c;
    }
    for(int k = 1; k <= n; k++)
        for(int i = 1; i <= n; i++)
            for(int j = 1; j <= n; j++)
                g[i][j] = min(g[i][j] ,g[i][k] + g[k][j]);
    int tot = 0;
    for(int i = 0; i < r; i++)
        for(int j = i+1; j < r; j++){
            int u = R[i], v = R[j];
            e[tot++] = (edge){u, v, g[u][v]};
            e[tot++] = (edge){v, u, g[u][v]};
        }
    sort(e,e+tot);
    int ans = 0;
    for(int i = 0; i <= n; i++) p[i] = i;
    for(int i = 0; i < tot; i++){
        int x = find(e[i].u);
        int y = find(e[i].v);
        if(x != y) {ans+=e[i].cost; p[x] = y;}
    }
    cout << ans << "\n";
    return 0;
}