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 ...
随机推荐
- STL set容器的一点总结
整理了一下set常用语句,参看这篇http://www.cnblogs.com/BeyondAnyTime/archive/2012/08/13/2636375.html -------------- ...
- [转载]initwithcoder和 initwithframe
大前提是UIViewController有一个UIView.同时,需要厘清两个概念,创建一个类和实例化一个类.在XCode中创建一个类和实例化一个类很容易区分,但是在IB(Interface Buil ...
- 8个必备的PHP功能开发 (转)
做过PHP开发的程序员应该清楚,PHP中有很多内置的功能,掌握了它们,可以帮助你在做PHP开发时更加得心应手,本文将分享8个开发必备的PHP功能,个个都非常实用,希望各位PHP开发者能够掌握. 1.传 ...
- ORA-00257错误
Archiver error,connect internal only,until freed 表示归档日志目录已满,用户不能再连接数据库,现有用户可继续查询数据库,但是不能执行DML语句 插删 ...
- s:iterator标签的使用
1.在说明s:iterator标签的使用前,先了解下struts2中的Value Stack. 这里参考了webwork中对Value Stack的描述,由于struts2是在webwork的基础上进 ...
- centos下安装python
下载网址:http://ftp.gnu.org/gnu/gdb/ 1.编译python必须安装开发工具 # yum groupinstall "Development tools" ...
- yii中设置提示成功信息,错误提示信息,警告信息
方法一: <?phpYii::app()->user->setFlash(‘success’,”Data saved!”); 设置键值名为success的临时信息.在getFlash ...
- Learning Vector
题意: 给出n组x,y增量,从(0,0)开始以x,y坐标增加后等到的终点坐标,可以构成一个面积,再以这个终点为起点再增加,以此类推,使用增量顺序不同,得到的面积不,求用k组增量能得到的最大的面积. 分 ...
- Raspberry Pi3 ~ 安装samba服务
文章转载自此博文 1. sudo apt-get install samba 如果出现错误提示,则需要先执行sudo apt-get update,再重新执行sudo apt-get install ...
- 图Graph
存储结构: 1.邻接矩阵存储 typedef struct { char vex[MAXVEX];//顶点数 int arc[MAXVEX][MAXVEX];//邻接矩阵 int numVextexe ...