sdut 3252 Lowest Unique Price set

来源:互联网 发布:剑道眼镜知乎 编辑:程序博客网 时间:2024/06/05 10:31

Lowest Unique Price

Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^

题目描述

Recently my buddies and I came across an idea! We want to build a website to sell things in a new way.
For each product, everyone could bid at a price, or cancel his previous bid, finally we sale the product to the one who offered the "lowest unique price". The lowest unique price is defined to be the lowest price that was called only once.
So we need a program to find the "lowest unique price", We'd like to write a program to process the customers' bids and answer the query of what's the current lowest unique price.
All what we need now is merely a programmer. We will give you an "Accepted" as long as you help us to write the program.
 

输入

The first line of input contains an integer T, indicating the number of test cases (T ≤ 60).
Each test case begins with a integer N (1 ≤ N ≤ 200000) indicating the number of operations.
Next N lines each represents an operation.
There are three kinds of operations:
"b x": x (1 ≤ x ≤ 106) is an integer, this means a customer bids at price x.
"c x": a customer has canceled his bid at price x.
"q" : means "Query". You should print the current lowest unique price.
Our customers are honest, they won\'t cancel the price they didn't bid at.
 

输出

 Please print the current lowest unique price for every query ("q"). Print "none" (without quotes) if there is no lowest unique price.

示例输入

2 3 b 2 b 2 q 12 b 2 b 2 b 3 b 3 q b 4 q c 4 c 3 q c 2 q

示例输出

none none 4 3 2

提示

 

来源

 

示例程序

 

  • 提交 
  • 状态 
  • 讨论
    • set 乱搞一下就好了
      #pragma warning(disable:4786)//使命名长度不受限制#pragma comment(linker, "/STACK:102400000,102400000")//手工开栈#include <map>#include <set>#include <queue>#include <cmath>#include <stack>#include <cctype>#include <cstdio>#include <cstring>#include <stdlib.h>#include <iostream>#include <algorithm>#define rd(x) scanf("%d",&x)#define rd2(x,y) scanf("%d%d",&x,&y)#define rd3(x,y,z) scanf("%d%d%d,&x,&y,&z)#define rdl(x) scanf("%I64d,&x);#define rds(x) scanf("%s",x)#define rdc(x) scanf("%c",&x)#define ll long long int#define ull unsigned long long#define maxn 200005#define mod 1000000007#define INF 0x3f3f3f3f //int 最大值#define FOR(i,f_start,f_end) for(int i=f_start;i<=f_end;++i)#define MT(x,i) memset(x,i,sizeof(x))#define PI  acos(-1.0)#define E  exp(1)#define eps 1e-8ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}ll mul(ll a,ll b,ll p){ll sum=0;for(;b;a=(a+a)%p,b>>=1)if(b&1)sum=(sum+a)%p;return sum;}inline void Scan(int &x) {      char c;while((c=getchar())<'0' || c>'9');x=c-'0';      while((c=getchar())>='0' && c<='9') x=(x<<3)+(x<<1)+c-'0';}using namespace std;int vis[maxn];int main(){    int n,loop,cnt=1,t;    scanf("%d",&loop);    while(loop--){        scanf("%d",&n);        char str[4];        set<int >q;        memset(vis,0,sizeof(vis));        for(int i=0;i<n;++i){            scanf("%s",str);            if(str[0]=='b'){                scanf("%d",&t);                q.insert(t);                vis[t]++;            }            else if(str[0]=='c'){                scanf("%d",&t);                vis[t]--;                if(!vis[t])q.erase(t);            }            else{                set<int>::iterator id;                bool flag=true;                for(id=q.begin();flag&&id!=q.end();id++)                    if(vis[*id]==1){                            cout<<*id<<'\12';                        flag=false;                    }                if(flag)puts("none");            }        }    }    return 0;}


0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 上海医保本丢了怎么办? 新版医保卡丢了怎么办 武汉社保卡掉了怎么办 职工社保卡丢了怎么办 杭州社保卡丢了怎么办 农村医疗卡丢了怎么办 陕西省医保卡丢了怎么办 小孩社保卡掉了怎么办 社区医保本丢了怎么办 宝宝医保卡掉了怎么办 同煤医疗卡丢了怎么办 杭州医保卡丢了怎么办 新的医保卡丢了怎么办 二代医保卡丢了怎么办 老医保卡丢了怎么办 上海医保卡余额用完了怎么办 身份证丢了医疗报销怎么办 取公积金身份证丢了怎么办 身份证丢了怎么办就诊卡 人在外地怎么办农村社保卡 武汉医保卡丢了怎么办 济宁社保卡丢了怎么办 农村医疗本丢了怎么办 常熟医保卡丢了怎么办 农民社保卡丢了怎么办 常熟社保卡坏了怎么办 社保卡丢失补办期看病怎么办 社保卡补办期间看病怎么办 医保卡冻结了出院结算怎么办 住院医保卡钱不够怎么办 住院押金条丢了怎么办 急用新社保卡要怎么办 看病没带社保卡怎么办 医保卡掉了住院怎么办 厦门医保卡丢了怎么办 成都医保卡丢了怎么办 长春医保卡丢了怎么办 县城医保卡丢了怎么办 医保卡丢了怎么办南宁 西安职工医保丢了怎么办 重庆医保卡丢了怎么办