编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#5850 #1002. 发愿者的客厅 Accepted 100 3 ms 320 K C++ 17 / 1.6 K new_user_4 2023-09-24 23:37:10
显示原始代码
#include <bits/stdc++.h>
#define endl '\n'


using namespace std;

int n, m;

char mp[4][4];

int dx[8] = { 0, 0, 1, 1, 1, -1, -1, -1 };
int dy[8] = { 1, -1, 0, -1, 1, 0, 1, -1 };

vector<pair<int, int>> g, f;
vector<int> x, y;

int check() { return (x[1] - x[0]) * (y[2] - y[0]) - (y[1] - y[0]) * (x[2] - x[0]) == 0; }

void solve() {
    x.clear(), y.clear(), g.clear(), f.clear();
    for (int i = 1; i <= 3; i++)
        for (int j = 1; j <= 3; j++) {
            cin >> mp[i][j];
            if (mp[i][j] == 'W')
                g.push_back({ i, j });
            else if (mp[i][j] == 'B')
                f.push_back({ i, j });
        }

    for (auto p : f) {
        x.push_back(p.first);
        y.push_back(p.second);
    }

    if (check()) {
        cout << "Lose" << endl;
        return;
    }

    x.clear(), y.clear();

    for (auto p : g) {
        x.push_back(p.first);
        y.push_back(p.second);
    }

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 8; j++) {
            int x1 = x[i], y1 = y[i];

            x[i] = x1 + dx[j], y[i] = y1 + dy[j];

            if (x[i] <= 3 && y[i] <= 3 && x[i] >= 1 && y[i] >= 1 && mp[x[i]][y[i]] == '.') {
                if (check()) {
                    cout << "Win!" << endl;
                    return;
                }
            }

            x[i] = x1, y[i] = y1;
        }
    }
    cout << "Draw" << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int _ = 1;
    cin >> _;
    while (_--) {
        solve();
    }

    return 0;
}
子任务 #1
Accepted
得分:100
测试点 #1
Accepted
得分:100
用时:3 ms
内存:320 KiB

输入文件(1.in

7
W.W
.B.
BBW
WW.
B.W
.BB
BBB
..W
WW.
W.W
..B
BBW
W..
BWB
WB.
W.W
BBB
.W.
W.B
BW.
BW.


答案文件(1.out

Draw
Win!
Lose
Win!
Draw
Lose
Win!

用户输出

Draw
Win!
Lose
Win!
Draw
Lose
Win!

系统信息

Exited with return code 0