2016弱校联盟十一专场10.3,BNU52308,大模拟
2016-10-04 01:57
531 查看
大模拟
时限60s
你没有看错
是s不是ms
https://www.bnuoj.com/v3/problem_show.php?pid=52308
开两个set
一个是前面20%
一个是后面80%
然后就在两个set的边界处操作
= =
操作,好烦啊啊啊啊啊啊啊啊 啊啊啊
还有种写法是开两个map类似
无论哪一种,代码量都大的可怕= =
HH用map写了150行
cdm用map写了200行(听说4个map)
从下午四点开始写
一开始用map写,写了100+行,样例调了半天,秒WA
调到10点,气哭
后来听zm说可以用两个set,似乎好写一点
然后再写,再WA,再换写法,再发现之前少了一句。。。
终于,发现评测机跑了10s以上基本就是过了
不是因为网速卡,因为,时限有60s= =!
以后写模拟题还是要细心啊,诶,好累
时限60s
你没有看错
是s不是ms
https://www.bnuoj.com/v3/problem_show.php?pid=52308
开两个set
一个是前面20%
一个是后面80%
然后就在两个set的边界处操作
= =
操作,好烦啊啊啊啊啊啊啊啊 啊啊啊
还有种写法是开两个map类似
无论哪一种,代码量都大的可怕= =
HH用map写了150行
cdm用map写了200行(听说4个map)
从下午四点开始写
一开始用map写,写了100+行,样例调了半天,秒WA
调到10点,气哭
后来听zm说可以用两个set,似乎好写一点
然后再写,再WA,再换写法,再发现之前少了一句。。。
终于,发现评测机跑了10s以上基本就是过了
不是因为网速卡,因为,时限有60s= =!
以后写模拟题还是要细心啊,诶,好累
#include <set> #include <map> #include <cstdio> #include <iostream> #include <algorithm> using namespace std; const int N = 100007; struct node{ string name; int val,time; void read(int x){time = x;cin>>name>>val;} bool operator < (const node &a)const{ return val!=a.val?val>a.val:time>a.time; } }arr ; int n; map<string,int>val; map<string,int>tim; set <node> work; set <node> rest; set<node>::iterator it; void newGuy(string st,int time){ n++; int x;scanf("%d",&x); node tmp,newguy = node{st,x,time}; val[st] = x; tim[st] = time ; it=rest.begin(); tmp = (*it); if ((work.size()+1)*5<=n){ if (newguy<tmp){ work.insert(newguy); cout<<newguy.name<<" is working hard now."<<endl; }else { rest.insert(newguy); cout<<newguy.name<<" is not working now."<<endl; rest.erase(tmp); work.insert(tmp); cout<<tmp.name<<" is working hard now."<<endl; } }else { if (work.empty()){ rest.insert(newguy); cout<<newguy.name<<" is not working now."<<endl; }else { it = work.end(); it--; tmp = (*it); if (newguy<tmp){ work.insert(newguy); work.erase(tmp); rest.insert(tmp); cout<<newguy.name<<" is working hard now."<<endl; cout<<tmp.name<<" is not working now."<<endl; }else { rest.insert(newguy); cout<<newguy.name<<" is not working now."<<endl; } } } } void leave(string st){ n--; node tmp,leaveguy=node{st,val[st],tim[st]}; if (work.find(leaveguy)!=work.end()){ work.erase(leaveguy); if ((work.size()+1)*5<=n){ it = rest.begin(); tmp = (*it); rest.erase(tmp); work.insert(tmp); cout<<tmp.name<<" is working hard now."<<endl; } }else { rest.erase(leaveguy); if ((work.size()+1)*5<=n){ it = rest.begin(); tmp = (*it); rest.erase(tmp); work.insert(tmp); cout<<tmp.name<<" is working hard now."<<endl; }else if (work.size()*5>n&&!work.empty()){ it = work.end();it--; tmp = (*it); work.erase(tmp); rest.insert(tmp); cout<<tmp.name<<" is not working now."<<endl; } } } int main(){ for (int m;cin>>n;){ work.clear() ; rest.clear() ; for (int i=1;i<=n;i++) arr[i].read(i-n); sort( arr+1, arr+n+1) ; for (int i=1;i<=n;i++){ node tmp = arr[i]; val[tmp.name] = tmp.val ; tim[tmp.name] = tmp.time; if (i<=(int)(n/5.0))work.insert(arr[i]); else rest.insert(arr[i]); } char ch;string st; scanf("%d",&m); for (int i=1;i<=m;i++){ cin>>ch>>st; if (ch=='+')newGuy(st,i); else leave(st); } } return 0; }
相关文章推荐
- 2016弱校联盟十一专场10.3(12点场)
- [弱校联萌2016]2016弱校联盟十一专场10.3
- 2016弱校联盟十一专场10.3---Similarity of Subtrees(深搜+hash、映射)
- 2016弱校联盟十一专场10.3---We don't wanna work!(STL--set的使用)
- 2016弱校联盟十一专场10.3 C. We don't wanna work!(集合操作)
- 2016弱校联盟十一专场10.3 We don't wanna work!
- 2016弱校联盟十一专场10.3 A Best Matched Pair(水)
- [弱校联萌2016]2016弱校联盟十一专场10.2
- 2016弱校联盟十一专场10.5---As Easy As Possible(倍增)
- 2016弱校联盟十一专场10.2 Longest Increasing Subsequence
- (2016弱小联盟十一专场10.3)Parentheses 找规律
- 2016弱校联盟十一专场10.2 Longest Increasing Subsequence
- POJ 3735 Training little cats(矩阵乘法 + 稀疏矩阵优化)——2016弱校联盟十一专场10.7(12点场)
- (2016弱小联盟十一专场10.3) Best Matched Pair 暴力
- 2016弱校联盟十一专场10.2——Around the World
- 2016弱校连萌十一专场10.3 部分题解
- 2016弱校联盟十一专场10.2---Around the World(深搜+组合数、逆元)
- 2016弱校联盟十一专场10.5 F Fibonacci of Fibonacci(矩阵快速幂 + 循环节)
- [Contests]2016弱校联盟十一专场10.7
- (2016弱小联盟十一专场10.3) Help the Princess! BFS