题意:给定 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;
}

  

04-14 22:11