hao1nan 发表于 2017-12-8 19:05:08

【习题5-4 UVA-10763】Foreign Exchange

#include <bits/stdc++.h>  using namespace std;
  int n;
  map <pair<int, int>, int> mmap;
  int main()
  {
  //freopen(&quot;F:\\rush.txt&quot;, &quot;r&quot;, stdin);
  while (~scanf(&quot;%d&quot;, &n) && n)
  {
  mmap.clear();
  for (int i = 0; i < n; i++)
  {
  int x, y;
  scanf(&quot;%d%d&quot;, &x, &y);
  if (x > y)
  {
  swap(x, y);
  mmap--;
  }
  else
  mmap++;
  }
  bool ok = true;
  for (auto temp : mmap)
  {
  if (temp.second!=0)
  {
  ok = false;
  break;
  }
  }
  if (ok)
  puts(&quot;YES&quot;);
  else
  puts(&quot;NO&quot;);
  }
  return 0;
  }
页: [1]
查看完整版本: 【习题5-4 UVA-10763】Foreign Exchange