【解题报告】Educational Codeforces Round 12
来源:互联网 发布:ios swift 项目源码 编辑:程序博客网 时间:2024/04/29 17:39
题目链接
A.Buses Between Cities(Codeforces 665A)
思路
假设主角的车在
(另外,因为数据规模较小,用模拟的方法貌似也可以做)
代码
#include <cstdio>const int first = 5 * 60, final = 23 * 60 + 59;int fa, ta, fb, tb, h, m, s, t, x, y;int main() { scanf("%d%d%d%d%d:%d", &fa, &ta, &fb, &tb, &h, &m); s = 60 * h + m - first; t = s + ta; if(t <= final - first) { x = t / fb + (t % fb != 0); } else { x = (final - first) / fb + 1; } y = s < tb ? 0 : (s - tb) / fb + 1; printf("%d\n", x - y); return 0;}
B. Shopping(Codeforces 665B)
思路
因为数据规模比较小,所以可以直接模拟(数组或双端队列)。
代码
#include <bits/stdc++.h>using namespace std;int n, m, k, item, ans;deque <int> :: iterator it;deque <int> d;int main() { cin >> n >> m >> k; while(k--) { cin >> item; d.push_back(item); } ans = 0; for(int i = 0; i < n * m; i++) { cin >> item; for(it = d.begin(); it != d.end(); it++) { ans++; if(*it != item) { continue; } d.erase(it); break; } d.push_front(item); } cout << ans << endl; return 0;}
C. Simple Strings(Codeforces 655C)
思路
首先从题目给的数据量来看,题目给的时间似乎只够设计
代码
#include <bits/stdc++.h>using namespace std;const int maxn = 2e5 + 10;char s[maxn];int n;int main() { scanf("%s", s); n = strlen(s); for(int i = 1; i < n; i++) { if(s[i] == s[i-1]) { s[i] = (s[i] - 'a' + 1) % 26 + 'a'; if(i + 1 < n && s[i] == s[i+1]) { s[i] = (s[i] - 'a' + 1) % 26 + 'a'; } } } printf("%s\n", s); return 0;}
(其它题目略)
- 【解题报告】Educational Codeforces Round 12
- Educational Codeforces Round 6 解题报告
- 【解题报告】Educational Codeforces Round 9
- 【解题报告】Educational Codeforces Round 13
- 【解题报告】Educational Codeforces Round 15
- 【解题报告】Educational Codeforces Round 16
- 【解题报告】Educational Codeforces Round 14
- 【解题报告】 Educational Codeforces Round 19
- 【解题报告】Educational Codeforces Round 20
- [Updating] Educational Codeforces Round 20 解题报告
- 【解题报告】Educational Codeforces Round 21
- 解题报告: Educational Codeforces Round 24 A,B,C
- 解题报告:Educational Codeforces Round 24 D,E,F
- Codeforces Educational Round 34划水报告
- CodeForces Round#35解题报告
- Codeforces Round #277.5 解题报告
- Codeforces-Round #340 解题报告
- codeforces round 207 解题报告
- Android源码解析(二十)-->Dialog取消绘制流程
- javascript设计模式——单例模式
- 字符数组
- 用两个栈实现的队列
- 关系型数据库与非关系型数据库
- 【解题报告】Educational Codeforces Round 12
- [JAVA]关于classpath的补充
- 控制反转(IoC)与依赖注入(DI)——自己的理解
- 希尔排序
- Cross-Validation: Estimating Prediction Error
- SVN服务器搭建和使用(二)
- 定制类
- Linux设置动态及静态IP地址
- osg中漫游器的原理——osgGA::CameraManipulator(二)