UVaLive 6805 Pantun Grader (恶心的模拟)
题意:给定 n 首诗,然后让你给他打分,有四种规则,第一种是按音节打,如果音节在8-12之间,就加10,第二种就是按押韵打,如果13,24一个押韵就加20分。
第三种按音节数打,13,24有一个一样的就加10分,第四种是扣分的,如果多于4段,扣10分。
析:按照他说的来,就好,这个输入就挺恶心的,好难处理,而且一种很变态的数据就是标点后面没有空格,你还得自己去判断。。。
代码如下:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cstring>
#include <set>
#include <queue>
#include <algorithm>
#include <vector>
#include <map>
#include <cctype>
#include <cmath>
#include <stack>
#include <sstream>
#define frer freopen("in.txt", "r", stdin)
#define frew freopen("out.txt", "w", stdout)
using namespace std; typedef long long LL;
typedef pair<int, int> P;
const int INF = 0x3f3f3f3f;
const double inf = 0x3f3f3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-8;
const int maxn = 1e2 + 5;
const int mod = 1e9 + 7;
const char *mark = "+-*";
const int dr[] = {-1, 0, 1, 0};
const int dc[] = {0, 1, 0, -1};
const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"};
int n, m;
const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
inline int Min(int a, int b){ return a < b ? a : b; }
inline int Max(int a, int b){ return a > b ? a : b; }
inline LL Min(LL a, LL b){ return a < b ? a : b; }
inline LL Max(LL a, LL b){ return a > b ? a : b; }
inline bool is_in(int r, int c){
return r >= 0 && r < n && c >= 0 && c < m;
}
int a[500];
bool b[500];
bool c[500];
vector<string> v[500];
int ans[10]; int main(){
int T; cin >> T;
for(int kase = 1; kase <= T; ++kase){
int cnt = 0;
string s;
for(int i = 0; i < 500; ++i) v[i].clear();
while(true){
cin >> s;
bool ok = false, ok1 = false;
if(s[s.size()-1] == ',') s.resize(s.size()-1), ok1 = true;
if(s[s.size()-1] == '.') ok = true, s.resize(s.size()-1);
for(int i = 0; i < s.size(); ++i) if(s[i] == ',') s[i] = ' ';
stringstream ss(s);
int x = 0;
while(ss >> s){
if(x) ++cnt; v[cnt].push_back(s);
++x;
}
if(ok1) ++cnt;
if(ok) break;
} memset(ans, 0, sizeof ans);
memset(a, 0, sizeof a);
for(int i = 0; i <= cnt; ++i){
a[i] = 0;
for(int j = 0; j < v[i].size(); ++j){
int len = v[i][j].size();
if(len == 6){
s = v[i][j];
bool ok = false;
for(int k = 0; k < s.size(); ++k){
if(k+1 < s.size() && s[k] == 'n' && s[k+1] == 'g'){ a[i] += 2; ok = true; break; }
else if(k+1 < s.size() && s[k] == 'n' && s[k+1] == 'y'){ a[i] += 2; ok = true; break; }
}
if(!ok) a[i] += 3;
}
else if(len > 6) a[i] += 3;
else if(len == 4 || len == 5) a[i] += 2;
else if(len == 3){
s = v[i][j];
if(towlower(s[0]) == 'a' || towlower(s[0]) == 'e' || towlower(s[0]) == 'o' || towlower(s[0]) == 'i' || towlower(s[0]) == 'u') a[i] += 2;
else ++a[i];
}
else ++a[i];
}
} for(int i = 0; i < 4; ++i)
if(a[i] >= 8 && a[i] <= 12) ans[1] += 10; if(cnt >= 3){
string s1 = v[0][v[0].size()-1], s2 = v[1][v[1].size()-1], s3 = v[2][v[2].size()-1], s4 = v[3][v[3].size()-1];
if(s1[s1.size()-2] == s3[s3.size()-2] && s1[s1.size()-1] == s3[s3.size()-1]) ans[2] += 20;
if(s2[s2.size()-2] == s4[s4.size()-2] && s2[s2.size()-1] == s4[s4.size()-1]) ans[2] += 20;
}
else if(cnt == 2){
string s1 = v[0][v[0].size()-1], s2 = v[1][v[1].size()-1], s3 = v[2][v[2].size()-1];
if(s1[s1.size()-2] == s3[s3.size()-2] && s1[s1.size()-1] == s3[s3.size()-1]) ans[2] += 20;
} if(a[2] && a[0] == a[2]) ans[3] += 10;
if(a[1] && a[3] && a[1] == a[3]) ans[3] += 10;
for(int i = 4; i <= cnt; ++i) ans[4] += 10;
ans[5] = ans[1] + ans[2] + ans[3] - ans[4];
printf("Case #%d: %d %d %d %d %d\n", kase, ans[1], ans[2], ans[3], ans[4], ans[5]);
}
return 0;
}
UVaLive 6805 Pantun Grader (恶心的模拟)的更多相关文章
- UVALive 4222 /HDU 2961 Dance 大模拟
Dance Problem Description For a dance to be proper in the Altered Culture of Machinema, it must abid ...
- UVALive 6269 Digital Clock --枚举,模拟
题意:说不清楚,自己看吧,太恶心. 这题真是SB了,当时看了一下以为乱搞就好了,于是开始动手拍,结果拍了好几个小时都没拍出来,而且越想越想不通,直接把自己绕进去了,结果gg了. 总结:甭管什么题,想清 ...
- UVALive 5880 Vigenère Cipher Encryption (模拟)
Stack Machine Executor 题目链接: http://acm.hust.edu.cn/vjudge/problem/26628 Description http://7xjob4.c ...
- UVALive 6884 GREAT + SWERC = PORTO dfs模拟
题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show ...
- UVALive 2517 Moving Object Recognition(模拟)
题目看上去很吓人,很高端,但其实很简单,不要被吓到,照搬题目的公式就可以了. 方法:用BFS求出最大块和重心,找出题目公式需要的未知量,然后套到题目公式里就可以求出答案了. 代码: #include& ...
- hdu 4964 恶心模拟
http://acm.hdu.edu.cn/showproblem.php?pid=4964 给定语句,按照语法翻译html并输出. 就是恶心的模拟,递归搞就行了 处理id和class时,在一个'&g ...
- 模拟赛1029d1
第二题[题目描述]给你两个日期,问这两个日期差了多少毫秒.[输入格式]两行,每行一个日期,日期格式保证为"YYYY-MM-DD hh:mm:ss"这种形式.第二个日期时间一定比第一 ...
- Hdu3640-I, zombie(模拟+二分)
The "endless" model in "I, zombie" of "Plants vs. Zombies" is my favou ...
- HUNNU11342:Chemistry(模拟)
http://acm.hunnu.edu.cn/online/?action=problem&type=show&id=11342 Problem description The ch ...
随机推荐
- UVa 11090 Going in Cycle!!【Bellman_Ford】
题意:给出n个点m条边的加权有向图,求平均值最小的回路 自己想的是用DFS找环(真是too young),在比较找到各个环的平均权值,可是代码实现不了,觉得又不太对 后来看书= =好巧妙的办法, 使用 ...
- tableView的设置
TableView的设置 1.设置table头部和底部的view // 底部(宽度固定是320) tableView.tableFooterView = footer; // 头部(宽度固定是320) ...
- IOS中tableView每组的头部控件、通过tableView的代理方法控制某一行的cell能否达到高亮选中状态
一.tableView每组的头部控件 1.控件宽度默认就是tableView的宽度 2.控件高度由下面的代理方法决定 - (CGFloat)tableView:(UITableView *)table ...
- 决策树之 CART
继上篇文章决策树之 ID3 与 C4.5,本文继续讨论另一种二分决策树 Classification And Regression Tree,CART 是 Breiman 等人在 1984 年提出的, ...
- 【转】Linux设备驱动之mmap设备操作
原文网址:http://www.cnblogs.com/geneil/archive/2011/12/08/2281222.html 1.mmap系统调用 void *mmap(void *addr, ...
- mysql 在大型应用中的架构演变
文正整理自:http://www.csdn.net/article/2014-06-10/2820160 可扩展性 架构的可扩展性往往和并发是息息相关,没有并发的增长,也就没有必要做高可扩展性的架构, ...
- Android 异常处理最佳实践
一个好的app 异常处理机制 我认为应该至少包含以下几个功能: 1.能把错误信息上传到服务器 让开发者可以持续改进app 2.错误信息至少应该包含 是否在主进程 是否在主线程 等可以帮助程序员定位的 ...
- git常用知识整理
分布式和集中版本控制的区别 分布式版本控制系统与集中式版本控制系统有何不同呢?首先,分布式版本控制系统根本没有“中央服务器”,每个人的电脑上都是一个完整的版本库,这样,你工作的时候,就不需要联网了,因 ...
- mac 下用 brew 安装mongodb
转自:mac 下用 brew 安装mongodb 经过这位仁兄的文章指导,终于连上了mongodb. 启动mongo数据库,就是打开一个终端sudo mongod,然后打开另一个终端sudo mong ...
- Jquery实现文本框输入提示
一些用户体验好的表单都会在文本框里设置输入提示,文本框获取焦点时,提示内容消息,如果未输入,失去焦点时又会出现提示. 网上找到一个比较好用的控件jquery.inputDefault.js 使用方法: ...