hiho week 118 register

Ended

Participants:1068

Verdict:Wrong Answer
Score:0 / 100
Submitted:2016-10-05 03:39:25

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream>
#include<map>
using namespace std;
int main(int argc, const char* argv[]){
    map<int, int> m;
    int nodes, edges;
    cin >> nodes >> edges;
    int i, j;
    map<int, int>::iterator it;
    int state = 0;
    while(cin >> i >> j){
        if (m.empty()) {
            m[i] = j;
        }
        else{
            for (it = m.begin(); it != m.end(); it++) {
                if (i == it->first || j== it->second) {
                    state = 1;
                }
            }
            if (state == 0) {
                m[i] = j;
            }
        }
        state = 0;
    }
    cout << nodes - m.size() << endl;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX