#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;

    // 定义一个数组,存储每个时刻演奏的乐器
    vector<string> instruments(60 * 60 * 10 + 1, 'None');

    // 读取朋友们提供的信息
    for (int i = 0; i < n; ++i) {
        string start, end, instrument;
        cin >> start >> end >> instrument;

        // 将时间字符串转换为秒数
        int startTime = stoi(start.substr(0, 2)) * 3600 + stoi(start.substr(3, 2)) * 60 + stoi(start.substr(6, 2));
        int endTime = stoi(end.substr(0, 2)) * 3600 + stoi(end.substr(3, 2)) * 60 + stoi(end.substr(6, 2));

        // 更新对应时间段的演奏乐器
        for (int j = startTime; j <= endTime; ++j) {
            if (instruments[j] == 'None') {
                instruments[j] = instrument;
            } else if (instruments[j].find(instrument) == string::npos) {
                instruments[j] += instrument;
            }
        }
    }

    // 对每个时刻的乐器演奏顺序进行排序
    for (int i = 0; i <= 60 * 60 * 10; ++i) {
        sort(instruments[i].begin(), instruments[i].end(), [](char a, char b) {
            string order = 'PVCDB';
            return order.find(a) < order.find(b);
        });
    }

    // 读取需要查询的时刻数量
    int m;
    cin >> m;

    // 输出每个时刻的演奏乐器
    for (int i = 0; i < m; ++i) {
        string time;
        cin >> time;

        // 将时间字符串转换为秒数
        int currentTime = stoi(time.substr(0, 2)) * 3600 + stoi(time.substr(3, 2)) * 60 + stoi(time.substr(6, 2));

        cout << instruments[currentTime] << endl;
    }

    return 0;
}

原文地址: https://www.cveoy.top/t/topic/UjZ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录