NC25592. Cards with Numbers
描述
输入描述
The first line of the input is an integer n (1 <= n <= 106), the number of operations. Next n lines represent n operations, and two integers k ( k∈{0,1}) and x (0<=x<=109) are separated by spaces on each line, as described above.
输出描述
For each query, output one line "yes" if there is a card with the number x in the box, otherwise output one line "no".
示例1
输入:
5 0 1 1 2 0 2 1 3 1 2
输出:
no no yes
C++11(clang++ 3.9) 解法, 执行用时: 883ms, 内存消耗: 40944K, 提交时间: 2019-06-01 19:19:51
#include<bits/stdc++.h> using namespace std; unordered_map<int,int>p; int main(){ int n,a,b; scanf("%d",&n); while(n--){ scanf("%d %d",&a,&b); if(a==0) p[b]=1; else printf("%s\n",(p[b])?"yes":"no"); } }