放松の比赛 题解
T1 因为收了宇宙霹雳无敌旋转螺旋升天因特尔N元所以上课给宇宙霹雳无敌旋转螺旋升天因特尔打广告的吴老师
其实这道题是 HuaJunL 出的题,标题灵感来源于他的一个 QQ 好友
Update 2023-7-21 这人离上次改名正好一年,他之前名字是 iamnotsoNB,现在改了
Update 2023-7-20 今天作者被机房惨案了,可能被封号,所以这里贴上题目补档:
### 题目背景
由于作者~~爱学习~~被逼,他又来上吴老师的编程课了,但今天有那么一点不一样……
### 题目描述
因为吴老师收了宇宙霹雳无敌旋转螺旋升天因特尔N元,于是他上课就开始给宇宙霹雳无敌旋转螺旋升天因特尔打广告,但是他不愿意说收了多少元,又因为如果作者不知道他收了多少元的话就会冲破屏幕过来打你,所以请你求出吴老师收了多少元。
注:N的值为一个半径为**114514**厘米的圆的面积的一半,保留一位小数。
### 输入格式
没有输入
### 输出格式
输出吴老师收了多少元
### 提示
无其实很简单啊,直接计算 就行了,答案是 。这里不给出代码
T2 【哲♂学】Van Darkholme 的采访
这个真的不难,就是模拟
Code
#include <bits/stdc++.h>
using namespace std;
// 定义哲学语言列表
vector<string> words = {"slaves get your ass back here", "do you like what you see", "ah thats good", "boy next door", "take those souvenirs tight now", "deep dark fantasies"};
int main() {
string now;
string s;
int i = 0;
// 逐行读取输入
while (getline(cin, s)) {
if (s == "") {
break;
}
i++;
// 判断当前是采访者还是 Van Darkholme 回答
if (s.starts_with("Reporter:")) {
now = "Reporter";
}
if (s.starts_with("Van:")) {
now = "Van";
}
// 如果当前是 Van Darkholme 回答,则进行处理
if (now == "Van") {
string nospace; // 处理后的字符串
// 去除多余的空格,并将字符串转换为小写
for (int i = 0; i < s.size(); i++) {
if (i > 0 && s[i] == ' ' && s[i - 1] == ' ') {
continue;
}
nospace.push_back(tolower(s[i]));
}
// 检查是否包含哲学语言,如果包含则输出
for (string phrase : words) {
if (nospace.find(phrase) != string::npos) {
cout << phrase << ' ' << i << '\n';
}
}
}
}
return 0;
}需要 C++ 20 才可以编译通过(String.starts_with 为 C++ 20 的功能)
T3 交互当双押,_____
先排序
map<string, int> value;
// 排序函数
bool compareNotes(const Note& note1, const Note& note2) {
if (note1.time != note2.time) { // 先按照时间排序
return note1.time < note2.time;
}
return value[note1.state] < value[note2.state]; // 如果相同就比对优先级,小的优先
}其中优先级就是 Perfect 最小,Good 其次,Bad 后面,Miss 最大
排序后遍历,计算出 Perfect 和 Good 的数量还有 Max Combo,同时算出判定线变蓝、变白时间,然后算 Acc
注意这里 Acc 不能保留两位小数,要用精确值
Acc 算完算分数和 rks
算完再评级,没了啊
代码如下:
#include <bits/stdc++.h>
using namespace std;
struct Note {
int time;
string state;
};
int N, M; // 音符量、歌曲长度
map<string, int> value; // 判定情况与对应的数值
// 按时间和判定情况进行排序
bool compareNotes(const Note& note1, const Note& note2) {
if (note1.time != note2.time) {
return note1.time < note2.time;
}
return value[note1.state] < value[note2.state];
}
int main() {
// 初始化优先级
value["Perfect"] = 1;
value["Good"] = 2;
value["Bad"] = 3;
value["Miss"] = 4;
double Level; // 定数
cin >> N >> M >> Level;
vector<Note> notes(N); // 音符数组
for (int i = 0; i < N; i++) {
int time;
string state;
cin >> time >> state;
notes[i] = {time, state};
}
sort(notes.begin(), notes.end(), compareNotes); // 按时间和判定情况排序
int Score = 0; // 得分
double Acc = 0.0; // 准度
int blueTime = -1; // 判定线变蓝时间
int whiteTime = -1; // 判定线变白时间
int perfectCount = 0; // Perfect 数量
int goodCount = 0; // Good 数量
int maxCombo = 0; // 最大连击数
int combo = 0; // 当前连击数
for (int i = 0; i < N; i++) {
int time = notes[i].time;
string state = notes[i].state;
if (state == "Perfect") {
perfectCount++;
combo++;
} else if (state == "Good") {
goodCount++;
if (blueTime == -1) {
blueTime = time;
}
combo++;
} else if (state == "Bad" || state == "Miss") {
combo = 0; // 重置连击数
if (whiteTime == -1) { // 如果线没有白
if (blueTime == -1) { // 如果还没有蓝
blueTime = -2; // 设置为一个不是 -1 的值,这样线不会再蓝了(线已经白了,不可能蓝了)
}
whiteTime = time;
}
}
maxCombo = max(maxCombo, combo);
}
if (blueTime == -2) {
blueTime = -1; // 把这个临时的值设置回去
}
Acc = (perfectCount + 0.65 * goodCount) * 1.0 / N; // 计算准度
Score = (Acc * 9.0 * 1e5 + 1.0 * 1e5 * maxCombo / N); // 计算得分
double rks = 0; // rks
if (Acc >= 0.7) {
rks = pow((Acc * 100.0 - 55) / 45, 2) * Level; // 计算RankingScore
}
cout << fixed << setprecision(2);
cout << Score << " " << Acc * 100.0 << "% ";
cout << rks << " ";
// 评级
if (maxCombo == N && goodCount == 0) { // 全连并且没有 Good
cout << "Phi" << endl;
} else if (maxCombo == N) { // 全连
cout << "FC" << endl;
} else if (Score >= 920000) {
cout << "S" << endl;
} else if (Score >= 880000) {
cout << "A" << endl;
} else if (Score >= 820000) {
cout << "B" << endl;
} else if (Score >= 700000) {
cout << "C" << endl;
} else {
cout << "F" << endl;
}
cout << blueTime << endl;
cout << whiteTime << endl;
return 0;
}