CSU 1503: ZZ买衣服

好吧,水了

有点要注意了,用ges(..)超时, scanf(...)就A掉了。。。

#include <iostream>
#include <stdio.h>
#include <string>
#include <set>
using namespace std;

int main ()
{
  set<string> st;
  pair< set<string>::iterator, bool > pr;
  char str[25];
  int n, m;
  while (scanf("%d%d", &n, &m) == 2)
  {
      getchar();
      while (n--)
      {
          scanf("%s",str);
          st.insert(str);
      }
      while (m--)
      {
          scanf("%s",str);
          pr = st.insert(str);
          if (pr.second)
              puts("YES");
          else
              puts("NO");
      }
      st.clear();
  }

  return 0;
}

 

posted @ 2013-04-29 10:28  旅行的蜗牛  阅读(136)  评论(0编辑  收藏  举报