QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#674122 | #8742. 黑白 | app1eDog# | WA | 22ms | 11272kb | C++20 | 2.5kb | 2024-10-25 14:05:52 | 2024-10-25 14:05:53 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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'