QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#674122#8742. 黑白app1eDog#WA 22ms11272kbC++202.5kb2024-10-25 14:05:522024-10-25 14:05:53

Judging History

你现在查看的是最新测评结果

  • [2024-10-25 14:05:53]
  • 评测
  • 测评结果:WA
  • 用时:22ms
  • 内存:11272kb
  • [2024-10-25 14:05:52]
  • 提交

answer

// created on Lucian Xu's Laptop

#include <bits/stdc++.h>

// using namespace std;

#define typet typename T
#define typeu typename U
#define types typename... Ts
#define tempt template <typet>
#define tempu template <typeu>
#define temps template <types>
#define tandu template <typet, typeu>

using UI = unsigned int;
using ULL = unsigned long long;
using LL = long long;
using ULL = unsigned long long;
using i128 = __int128;
using PII = std::pair<int, int>;
using PIL = std::pair<int, LL>;
using PLI = std::pair<LL, int>;
using PLL = std::pair<LL, LL>;
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using vl = std::vector<LL>;
using vvl = std::vector<vl>;
using vpi = std::vector<PII>;

#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) \
    do {           \
    } while (false)
#endif

constexpr int mod = 998244353;
constexpr int inv2 = (mod + 1) / 2;
constexpr int inf = 0x3f3f3f3f;
constexpr LL INF = 1e18;
constexpr double pi = 3.141592653589793;
constexpr double eps = 1e-6;

constexpr int lowbit(int x) { return x & -x; }
tandu bool Max(T& x, const U& y) { return x < y ? x = y, true : false; }
tandu bool Min(T& x, const U& y) { return x > y ? x = y, true : false; }

void solut() {
    int n, m;
    std::cin >> n >> m;
    vvi col(n + 1, vi(m + 1)), vis(n + 1, vi(m + 1));
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        std::string s;
        std::cin >> s;
        for (int j = 1; j <= m; j++) {
            col[i][j] = s[j - 1] == 'W';
            cnt += col[i][j];
        }
    }
    if (!col[1][1] or !col[n][m]) {
        std::cout << "J" << '\n';
        return;
    }
    std::queue<PII> q;
    q.emplace(1, 1);
    vis[1][1] = 1;
    vpi d = {{1, 1}, {1, -1}, {-1, 1}, {-1, -1}};
    while (!q.empty()) {
        auto [x, y] = q.front();
        q.pop();
        for (const auto& [dx, dy] : d) {
            int xx = x + dx, yy = y + dy;
            if (xx < 1 or xx > n or yy < 1 or yy > m or vis[xx][yy]) continue;
            vis[xx][yy] = 1;
            q.emplace(xx, yy);
        }
    }
    if (!vis[n][m]) {
        std::cout << "J" << '\n';
    }
    std::cout << ((cnt - n - m + 1) & 1 ? "I" : "J") << '\n';
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    std::cout.tie(0);

    int t = 1;
    std::cin >> t;
    while (t--) {
        solut();
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 22ms
memory: 11272kb

input:

100
2 6
WWBBWW
WWWWWB
3 8
WWWBBBBB
WWWBWWWB
BBWWWBWW
5 2
WB
BB
BB
BW
BB
6 4
WWBW
WBWB
WWWW
WWWB
BBWW
BWBW
2 3
WWW
WBW
124 125
BWWWWWWWWWWWWWWWWWWWWWWWWWWBWWWWBWWWWWWWWBWWWWWWWWWWWBBBBWWWWWWWWWWWWWWWWWBWWWWWWWWWBWWWWWWWWWWBWWWWWWWWBBWWWWWWWWWWWWWWWWWWB
WWWWWWWBWWBWWWWWWWWWWWBWWBWWBWWWWBWWWWWWWWWBWBWB...

output:

J
J
J
J
I
J
I
J
J
I
J
I
J
I
J
I
J
J
J
J
J
J
J
I
I
I
I
J
J
J
I
I
J
I
J
J
J
J
I
J
J
J
J
J
J
I
J
J
J
J
J
J
J
I
J
J
I
I
J
I
J
J
I
J
J
J
J
I
J
J
J
I
J
J
J
J
J
J
I
I
J
J
J
J
J
J
I
J
J
J
I
J
I
J
I
I
J
J
J
J
I
J
J
J
I
J
I
J
J
J
I
J
J
J
J
J
I
J
J
J
J
I
J
I
J
J
J
I
I
J
J
J
J
J
J
I

result:

wrong answer 4th lines differ - expected: 'I', found: 'J'