比赛 20160414 评测结果 AAAAWAWAAAAAWAAAAAAA
题目名称 树木园 最终得分 85
用户昵称 asddddd 运行时间 3.261 s
代码语言 C++ 内存使用 3.92 MiB
提交时间 2016-04-14 16:52:58
显示代码纯文本
//
//  main.cpp
//  树木园
//
//  Created by Qing Liu on 16/4/14.
//  Copyright © 2016年 Qing Liu. All rights reserved.
//

#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#define maxn 100050
using namespace std;
vector<int>G1[maxn],G2[maxn];
int dushu1[maxn],dushu2[maxn],dushu3[maxn],dushu4[maxn];
void addedge1(int from,int to){
    G1[from].push_back(to);
    G1[to].push_back(from);
}
void addedge2(int from,int to){
    G2[from].push_back(to);
    G2[to].push_back(from);
}
int main() {
    freopen("cactus.in", "r", stdin);
    freopen("cactus.out", "w", stdout);
    int n,m;
    cin>>n>>m;
    for (int i=0; i<m; i++) {
        int from,to;
        cin>>from>>to;
        addedge1(from,to);
        dushu1[from]++;
        dushu1[to]++;
    }
    for (int i=0; i<m; i++) {
        int from,to;
        cin>>from>>to;
        addedge2(from,to);
        dushu3[from]++;
        dushu3[to]++;
    }
    for (int i=1; i<=n;i++ ) {
        for (int j=0; j<G1[i].size(); j++) {
            int u=G1[i][j];
            dushu2[i]+=dushu1[u];
        }
    }
    for (int i=1; i<=n;i++ ) {
        for (int j=0; j<G2[i].size(); j++) {
            int u=G2[i][j];
            dushu4[i]+=dushu3[u];
        }
    }
    sort(dushu2+1, dushu2+n+1);
    sort(dushu4+1, dushu4+n+1);
    for (int i=1; i<=n; i++) {
        if (dushu2[i]!=dushu4[i]) {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
    return 0;
}