#include #include using namespace std;

const int MAXN = 1005;

char identity[MAXN]; // 存储每个人的身份,H为正直者,L为欺诈者 bool truth[MAXN][MAXN]; // truth[i][j]为true表示i指证j是正直者,为false表示i指证j是欺诈者

int main() { int n, q; cin >> n >> identity + 1 >> q;

// 处理指证关系
for (int i = 1; i <= q; i++)
{
    int x, y;
    cin >> x >> y;
    truth[x][y] = true;
}

// 枚举每个人,判断其身份是否合法
for (int i = 1; i <= n; i++)
{
    bool is_honest = true; // 假设当前人是正直者
    for (int j = 1; j <= n; j++)
    {
        if (truth[j][i]) // 如果有人指证当前人是正直者
        {
            if (identity[j] == 'L') is_honest = false; // 如果指证者是欺诈者,则当前人不可能是正直者
        }
        else // 如果有人指证当前人是欺诈者
        {
            if (identity[j] == 'H') is_honest = false; // 如果指证者是正直者,则当前人不可能是欺诈者
        }
    }
    cout << (is_honest ? "H" : "L") << endl; // 输出当前人的身份
}

return 0;

}


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

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