1 solutions

  • 0
    @ 2025-9-18 13:23:15
    #include <iostream>
    #include <vector>
    #include <unordered_set>
    #include <string>
    #include <climits>
    
    using namespace std;
    
    int main() {
        // 玩家顺序(顺时针)
        vector<string> players = {"IGOR", "LEA", "MARINO", "SONJA", "VIKTOR"};
        
        int n;
        cin >> n;
        
        // 记录所有已打出的(颜色+数字)组合
        unordered_set<string> used;
        
        // 记录每个玩家被禁用的颜色,初始都为空
        vector<unordered_set<char>> forbidden(5);
        
        // 第一场的第一个出牌者是Sonja(索引3)
        int first_player = 3;
        
        // 记录所有谬误
        vector<pair<int, string>> paradoxes;
        
        for (int round = 1; round <= n; ++round) {
            // 读取本场五张牌
            vector<string> cards(5);
            for (int i = 0; i < 5; ++i) {
                cin >> cards[i];
            }
            
            // 确定出牌顺序:从first_player开始顺时针
            vector<int> order(5);
            for (int i = 0; i < 5; ++i) {
                order[i] = (first_player + i) % 5;
            }
            
            // 处理本场出牌,先收集有效出牌
            vector<pair<int, string>> valid_plays; // 玩家索引和牌
            char wind = ' '; // 场风
            
            for (int i = 0; i < 5; ++i) {
                int player_idx = order[i];
                string card = cards[i];
                char color = card[0];
                char num = card[1];
                
                // 检查是否为谬误
                bool is_paradox = false;
                
                // 检查1:是否使用了被禁用的颜色
                if (forbidden[player_idx].count(color)) {
                    is_paradox = true;
                }
                
                // 检查2:(颜色+数字)组合是否已被使用
                if (used.count(card)) {
                    is_paradox = true;
                }
                
                // 如果是谬误,记录并继续处理下一张牌
                if (is_paradox) {
                    paradoxes.push_back({round, players[player_idx]});
                    continue;
                }
                
                // 有效出牌,记录使用过的组合
                used.insert(card);
                valid_plays.push_back({player_idx, card});
                
                // 确定场风(第一个有效出牌的颜色)
                if (wind == ' ') {
                    wind = color;
                }
                
                // 检查是否没有打场风,若是则禁用该玩家未来使用场风的权利
                if (color != wind) {
                    forbidden[player_idx].insert(wind);
                }
            }
            
            // 确定本场胜者
            int winner = -1;
            int max_num = -1;
            bool has_red = false;
            
            // 先检查是否有红牌(C)
            for (auto& play : valid_plays) {
                if (play.second[0] == 'C') {
                    has_red = true;
                    break;
                }
            }
            
            // 寻找胜者
            if (has_red) {
                // 有红牌,取红牌中数字最大的
                for (auto& play : valid_plays) {
                    if (play.second[0] == 'C') {
                        int num = play.second[1] - '0';
                        if (num > max_num) {
                            max_num = num;
                            winner = play.first;
                        }
                    }
                }
            } else {
                // 没有红牌,取场风颜色中数字最大的
                for (auto& play : valid_plays) {
                    if (play.second[0] == wind) {
                        int num = play.second[1] - '0';
                        if (num > max_num) {
                            max_num = num;
                            winner = play.first;
                        }
                    }
                }
            }
            
            // 更新下一场的第一个出牌者为本次胜者
            first_player = winner;
        }
        
        // 输出结果
        cout << paradoxes.size() << endl;
        for (auto& p : paradoxes) {
            cout << p.first << " " << p.second << endl;
        }
        
        return 0;
    }
        
    
    • 1

    Information

    ID
    11171
    Time
    1000ms
    Memory
    500MiB
    Difficulty
    2
    Tags
    # Submissions
    3
    Accepted
    1
    Uploaded By