QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#150622 | #5509. Kooky Tic-Tac-Toe | ahsoltan | WA | 0ms | 3436kb | C++17 | 2.0kb | 2023-08-25 22:15:23 | 2023-08-25 22:15:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 2137
#endif
const int DX[4] = {-1, 0, 1, 1};
const int DY[4] = {1, 1, 1, 0};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int tt;
cin >> tt;
while (tt--) {
int n, k;
cin >> n >> k;
vector<string> g(n);
for (int i = 0; i < n; i++) {
cin >> g[i];
}
bool ok = true;
vector<pair<int, int>> x, o;
vector<pair<int, int>> win;
bool xw = false;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (g[i][j] == '.') {
continue;
}
(g[i][j] == 'x' ? x : o).push_back({i, j});
for (int d = 0; d < 4; d++) {
vector<pair<int, int>> v;
int p = i;
int q = j;
for (int l = 0; l < k; l++) {
if (p >= n || q >= n || p < 0 || q < 0 || g[p][q] != g[i][j]) {
break;
}
v.push_back({p, q});
p += DX[d];
q += DY[d];
}
if ((int)v.size() == k) {
ok &= win.empty();
win = v;
xw = g[i][j] == 'x';
}
}
}
}
int xs = x.size();
int os = o.size();
if (win.empty()) {
ok &= xs + os == n * n && abs(xs - os) == n % 2;
} else {
ok &= xs == os || (abs(xs - os) == 1 && max(xs, os) == (xw ? xs : os));
}
if (!ok) {
cout << "NIE\n";
} else {
cout << "TAK\n";
for (auto p : win) {
auto& v = xw ? x : o;
v.erase(find(v.begin(), v.end(), p));
v.push_back(p);
}
int i = 0;
int j = 0;
while (i + j < xs + os) {
pair<int, int> p;
if (i == j) {
p = (xs > os ? x[i++] : o[j++]);
} else {
p = (i < j ? x[i++] : o[j++]);
}
cout << p.first + 1 << ' ' << p.second + 1 << '\n';
}
}
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3436kb
input:
7 3 3 x.o xxx o.o 4 3 xx.x ...o ..o. .o.. 3 3 xoo oxx xoo 3 2 xoo oxx xoo 3 3 xox .o. xox 3 2 xo. ..x xo. 3 3 x.. .x. ..x
output:
TAK 1 1 1 3 2 1 3 1 2 2 3 3 2 3 TAK 4 2 1 1 3 3 1 2 2 4 1 4 TAK 1 2 1 1 1 3 2 2 2 1 2 3 3 2 3 1 3 3 NIE NIE NIE NIE
result:
wrong answer Contestant's solution makes an incorrect last move (test case 2)