20分求条玄关
  • 板块学术版
  • 楼主LiQiRong__juruo
  • 当前回复0
  • 已保存回复0
  • 发布时间2025/1/20 22:45
  • 上次更新2025/1/21 10:16:05
查看原帖
20分求条玄关
1385113
LiQiRong__juruo楼主2025/1/20 22:45

20分代码:

#include <bits/stdc++.h>
using namespace std;
struct name{
    int s; // 角色
    bool die = 0; // 是否死亡
    int j = 1,d = 1; // 解药和毒药
    int bi = 1; // 狼人使用次数
    int lier = 1; // 猎人使用次数
    //后面加零的是上一轮的
    bool die0 = 0;
    int j0 = 1,d0 = 1;
    int bi0 = 1;
    int lier0 = 1; 
}a[21];
int t,n;
void Wrong(){
    cout << "Wrong\n";
    for(int i = 1;i <= n;i++){
        a[i].die = a[i].die0;
        a[i].j = a[i].j0;
        a[i].d = a[i].d0;
        a[i].bi = a[i].bi0;
        a[i].lier = a[i].lier0;
    }
}
int main(){
    
    cin >> t>>n;
    for(int i = 1;i <= n;i++){
        cin >> a[i].s;
    }
    while(t--){
        int m;
        cin >> m;
        int f = 1;
        for(int i = 1;i <= m;i++){
            int op,idx1,idx2;
            cin >> op>>idx1>>idx2;
            if(idx1 < 1 || idx1 > n ||idx2 < 1||idx2 > n){
                Wrong();
                f = 0;
                break;
            }
            if(a[idx1].s == 2){
                Wrong();
                f = 0;
                break;
            }
            if(op != 2 && a[idx2].die == 1){
                Wrong();
                f = 0;
                break;
            }
            if(op == 0){
                if(idx1 == idx2){
                    Wrong();
                    f = 0;
                    break;
                }
                if(a[idx1].die == 1){
                    Wrong();
                    f = 0;
                    break;
                }
                if(a[idx1].s == 1 && a[idx1].bi == 1){
                    a[idx2].die = 1;
                    a[idx1].bi = 0;
                }else{
                    Wrong();
                    f = 0;
                    break;
                }
            }else if(op == 1){
                if(a[idx1].s == 4 && a[idx1].d == 1){
                    if(idx1 == idx2){
                        Wrong();
                        f = 0;
                        break;
                    }else{
                        a[idx2].die = 1;
                        a[idx1].d = 0;
                    }
                }else{
                    Wrong();
                    f = 0;
                    break;
                }
            }else if(op == 2){
                if(a[idx1].s == 4 && a[idx1].j == 1){
                    if(a[idx2].die != 1 || (a[idx2].die == 1 && a[idx2].die0 == 1)){
                        Wrong();
                        f = 0;
                        break;
                    }else{
                        a[idx2].die = 0;
                        a[idx1].j = 0;
                    }
                }else{
                    Wrong();
                    f = 0;
                    break;
                }
            }else if(op == 3){
                if(a[idx1].die == 0 || a[idx1].lier == 0){
                    Wrong();
                    f = 0;
                    break;
                }else{
                    a[idx2].die = 1;
                    a[idx1].lier = 0;
                }
            }
        }
        for(int i = 1;i <= n;i++){
            if(a[i].s == 3){
                if(a[i].die == 1){
                    if(a[i].lier == 1){
                        Wrong();
                        f = 0;
                        break;
                    }
                }
            }
        }
        
        if(f){
            int sum = 0;
            for(int i = 1;i <= n;i++){
                if(a[i].die == 1 && a[i].die0 == 0){
                    sum++;
                }
            }
            if(sum == 0){
                cout << "Safe";
            }else{
                cout << sum<<' ';
                for(int i = 1;i <= n;i++){
                    if(a[i].die == 1 && a[i].die0 == 0){
                        cout <<i<< ' ';
                    }
                }
            }
            cout << '\n';
            
        }
        for(int i = 1;i <= n;i++){
            a[i].die0 = a[i].die;
            a[i].j0 = a[i].j;
            a[i].d0 = a[i].d;
            a[i].bi0 = a[i].bi = 1;
            a[i].lier0 = a[i].lier;
        }
    }
}

U513409 『Fwb』狼人の杀戮

2025/1/20 22:45
加载中...