QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#283833 | #7733. Cool, It’s Yesterday Four Times More | ckiseki# | WA | 0ms | 3752kb | C++20 | 2.4kb | 2023-12-15 16:16:28 | 2023-12-15 16:16:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define all(x) begin(x), end(x)
#ifdef CKISEKI
#define safe cerr << __PRETTY_FUNCTION__ << " line " << __LINE__ << " safe\n"
#define orange(a...) orange_(#a, a)
#define debug(a...) debug_(#a, a)
#include <experimental/iterator>
void debug_(auto s, auto ...a) {
cerr << "\e[1;32m(" << s << ") = (";
int f = 0;
(..., (cerr << (f++ ? ", " : "") << a));
cerr << ")\e[0m\n";
}
void orange_(auto s, auto L, auto R) {
cerr << "\e[1;33m[ " << s << " ] = [ ";
using namespace experimental;
copy(L, R, make_ostream_joiner(cerr, ", "));
cerr << " ]\e[0m\n";
}
#else
#define safe ((void)0)
#define debug(...) safe
#define orange(...) safe
#endif
int vis[1000], visc;
bitset<4096> ok[1000];
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int t;
cin >> t;
while (t--) {
int n, m;
cin >> n >> m;
vector<string> a(n);
for (auto &ai : a)
cin >> ai;
for (int i = 0; i < n * m; ++i)
ok[i].reset();
auto Enc = [m](int x, int y) {
return x * m + y;
};
auto EncV = [n, m](int dx, int dy) {
return (dx + n) * 2 * m + (dy + m);
};
for (int i = 0; i < n; ++i) {
for (int j = 0; j < m; ++j) {
if (a[i][j] == 'O')
continue;
visc += 1;
queue<pair<int, int>> bfs;
bfs.emplace(i, j);
vis[Enc(i, j)] = visc;
while (not bfs.empty()) {
auto [x, y] = bfs.front();
bfs.pop();
ok[Enc(i, j)][EncV(x - i, y - j)] = true;
constexpr int dx[] = {0, 0, 1, -1};
constexpr int dy[] = {1, -1, 0, 0};
for (int d = 0; d < 4; ++d) {
int nx = x + dx[d], ny = y + dy[d];
if (0 > nx or nx >= n)
continue;
if (0 > ny or ny >= m)
continue;
if (vis[Enc(nx, ny)] == visc)
continue;
if (a[nx][ny] == 'O')
continue;
vis[Enc(nx, ny)] = visc;
bfs.emplace(nx, ny);
}
}
}
}
int ans = 0;
for (int i = 0; i < n * m; ++i) {
bool win = true;
for (int j = 0; j < n * m; ++j) {
if (i == j)
continue;
// ok[i] \in ok[j] -> i lose
if ((ok[i] | ok[j]) == ok[j]) {
win = false;
break;
}
}
ans += win;
}
cout << ans << '\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3752kb
input:
4 2 5 .OO.. O..O. 1 3 O.O 1 3 .O. 2 3 OOO OOO
output:
3 1 0 0
result:
ok 4 lines
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3512kb
input:
200 2 4 OOO. OO.. 2 3 OOO .O. 3 3 O.O OOO OO. 4 1 . . O O 1 2 .O 1 1 . 2 5 .OO.. .O.O. 2 1 O O 1 1 O 1 3 .OO 5 1 O O . O . 5 2 O. .. O. .O .. 5 3 ... ... .OO ..O OOO 3 5 ..O.O .O.O. .OO.O 5 2 .O OO O. O. .. 2 1 O O 3 5 .O.OO O...O ..OO. 1 5 ..... 5 1 O . O . . 5 3 OOO OO. .OO OO. O.O 2 1 O . 5 2 O. ...
output:
3 0 0 2 1 1 3 0 1 1 0 7 9 4 4 0 6 5 2 0 1 6 4 5 2 0 0 5 3 3 1 4 1 1 7 5 2 3 7 3 0 6 2 2 2 0 4 6 6 3 3 2 3 5 2 1 0 3 3 4 4 2 2 0 7 6 4 8 5 3 2 5 2 1 2 1 4 1 0 2 5 1 4 6 6 1 6 2 2 3 4 5 2 1 0 1 9 3 4 11 0 3 2 1 0 0 4 3 1 4 3 8 3 0 3 6 2 5 1 3 3 4 1 2 11 2 2 4 0 4 4 6 2 1 2 3 1 5 0 16 4 3 2 6 0 8 3 3 1...
result:
wrong answer 9th lines differ - expected: '0', found: '1'