Codeforces 845 Driving Test(模拟)
来源:互联网 发布:灯杆数据基础调研 编辑:程序博客网 时间:2024/06/05 06:13
题目地址
题意:驾照考试,你会有6个操作,问你你最少对交警说没看到几次标识来解释自己才能保证自己能过考试
- 1、(1 a)改变车的速度为a
- 2、(2)你超车了
- 3、(3 a)该路段限速为a
- 4、(4)该路段允许超车
- 5、(5)该路段的限速取消
- 6、(6)改路段不允许超车
思路:直接模拟(看代码注释),就唯一要注意的是有你可能改变速度后原本被判定没有超速的标识也可能要说是没看到。
#include <iostream>#include <cstring>#include <string>#include <queue>#include <vector>#include <map>#include <set>#include <stack>#include <cmath>#include <cstdio>#include <algorithm>#define N 100010#define M 90010#define LL __int64#define inf 0x3f3f3f3f#define lson l,mid,ans<<1#define rson mid+1,r,ans<<1|1#define getMid (l+r)>>1#define movel ans<<1#define mover ans<<1|1using namespace std;const LL mod = 1e9 + 7;int main() { cin.sync_with_stdio(false); int n, car, cc, ans, a, b; vector<int>v; while (cin >> n) { ans = 0; cin >> a >> b; car = b; v.clear(); cc = 0; for (int i = 1; i < n; i++) { cin >> a; if (a == 1) { cin >> b; car = b; while (v.size() && v.back() < car) {//判断之前的有没有要作废的标识 v.pop_back(); ans++; } } else if (a == 2) { ans += cc;//加上禁止超车标识的数量 cc = 0; } else if (a == 3) { cin >> b;//更新超速标识的时候也要判断之前的有没有问题 v.push_back(b); while (v.size() && v.back() < car) { v.pop_back(); ans++; } } else if (a == 4) { cc = 0;//因为取消了禁止超车的标识,所以清零 } else if (a == 5) { v.clear();//因为取消了限速的标识,所以清零 } else { cc++;//增加禁止超车的标识 } } cout << ans << endl; } return 0;}
阅读全文
0 0
- Codeforces 845 Driving Test(模拟)
- Educational Codeforces Round 27- D Driving Test
- codefcodeforces 845D Driving Test(栈)
- Test Driving Expression Template Programming
- Pragmatic eBook 介绍 :Test-Driving JavaScript Applications
- Codeforces Testing Round #8 / 328A IQ Test(模拟)
- 模拟@Test功能(注解)
- Driving and Test-driven programming--Where do we stand?
- codeforces--Spreadsheets(模拟)
- codeforces--Spreadsheets(模拟)
- CodeForces - 25E Test (KMP应用)
- codeforces - Tricky Sum(模拟)
- CodeForces 754B(模拟)
- codeforces 839B(模拟)
- codeforces 591C (模拟)
- 【模拟】CodeForces
- 【模拟】CodeForces
- 【模拟】CodeForces
- [编程题] 保卫方案
- CentOS7系统之间设置共享文件夹
- iOS开发之特征变量(Use Trait Variations)
- AFNetworking之UIKit扩展与缓存实现
- spring boot 输出简单的hello world(没用分层结构)
- Codeforces 845 Driving Test(模拟)
- Problem 2253 Salty Fish
- 地址总线、字长和内存空间的关系
- 关于PCB布线的顺序到底是怎样才合理?
- HDU 6053 TrickGCD(莫比乌斯反演+前缀和)
- 8张图理解Java
- SQL性能优化
- Google算法题:翻转游戏
- iOS跳转QQ聊天应用