其他分享
首页 > 其他分享> > UVA-10763 Foreign Exchange

UVA-10763 Foreign Exchange

作者:互联网

Vjudge题目链接,STL的map,我上来就set写了一个,wa了才发现每组有重复输入的,所以set不行。

#include<cstdio>
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;

int main(){
    int n;
    while(~scanf("%d", &n) && n){
        map<int, int> mp;
        int a1, a2;
        for(int i = 0; i < n; i++){scanf("%d %d", &a1, &a2); mp[a1]--; mp[a2]++;}
        bool ans = true;
        for(map<int,int>::iterator it = mp.begin(); it != mp.end(); it++){
            if((it->second) != 0){ans = false; break;}
        }
        if(ans)printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

good vegetable 发布了21 篇原创文章 · 获赞 1 · 访问量 7461 私信 关注

标签:map,Exchange,int,a1,10763,mp,ans,UVA,include
来源: https://blog.csdn.net/Aldielshala/article/details/104422533