题解:P11601 『Fwb』狼人の杀戮

· · 题解

思路

这是一道细节多的大模拟。

因为没有什么思维含量,所以接下来我会讲解一些实现细节。

角色技能输入有误判定

其他细节

  1. 女巫复活猎人时,要将猎人已经使用过技能的标记修改为未使用。
  2. 记得将上一轮的游戏状态存档,一定不要忘记一开始要将存档的数组初始化。
  3. 最后统计哪些玩家死亡,如果死亡的是猎人,一定要判断一些死亡的猎人是否使用过技能,没有使用过技能则角色技能输入有误。

代码

#include<bits/stdc++.h>
using namespace std;
#define P(i, a, b) for(int i = a; i <= b; i++)
const int N = 25;
int t, n, m, T, _, $;
struct Player{
    int id, type, ti;
    bool use[N], si, du, jie; 
}p[N], lst[N];
signed main(){
    cin.tie(0)->sync_with_stdio(0);
    cin >> t >> n;
    P(i, 1, n) 
     cin >> p[i].type, p[i].id = i, p[i].ti = 0, lst[i] = p[i];
    P(i, 1, t){
        cin >> m;
        bool Wr = 0;
        vector<int> list;
        while(m --){
            cin >> T >> _ >> $;
            if(!(_ >= 1 && _ <= n) || !($ >= 1 && $ <= n) || p[_].type == 2) Wr = 1;
            if(!Wr)
             if(T == 0)
              if(p[_].use[i] || _ == $ || p[_].si || p[$].si || p[_].type != 1){ Wr = 1; continue; }
              else p[_].use[i] = 1, p[$].si = 1, p[$].ti = i;
             else if(T == 1)
              if(p[_].use[i] || p[_].du || _ == $ || p[_].si || p[$].si || p[_].type != 4){ Wr = 1; continue; }
              else p[_].use[i] = 1, p[_].du = 1, p[$].si = 1, p[$].ti = i;
             else if(T == 2)
              if(p[_].use[i] || p[_].jie || !p[$].si || p[$].ti != i || p[_].type != 4 || (_ != $ && p[_].si)){ Wr = 1; continue; }
               else{ p[_].jie = 1, p[_].use[i] = 1, p[$].si = 0, p[$].ti = 0;
                     if(p[$].type == 3) p[$].use[i] = 0; }
               else if(p[$].si || !p[_].si || p[_].ti != i || _ == $ || p[_].type != 3 || p[_].use[i]){ Wr = 1; continue; }
             else p[$].si = 1, p[$].ti = i, p[_].use[i] = 1;
        }
        P(j, 1, n)
         if(p[j].si && p[j].ti == i){
            list.push_back(j);
            if(p[j].type == 3 && !p[j].use[i]){ Wr = 1; break; }
         }
        if(Wr) cout << "Wrong\n";
        else if(!list.size()) cout << "Safe\n";
        else{ cout << list.size() << " ";
              for(int j = 0; j < list.size(); j ++) 
               cout << list[j] << " ";
              cout << "\n"; }
        if(Wr) P(j, 1, n) p[j] = lst[j];
        else P(j, 1, n) lst[j] = p[j];
    }
}