QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#263502 | #7733. Cool, It’s Yesterday Four Times More | ucup-team987# | WA | 1ms | 3440kb | C++23 | 3.1kb | 2023-11-24 21:57:22 | 2023-11-24 21:57:23 |
Judging History
answer
#if __INCLUDE_LEVEL__ == 0
#include __BASE_FILE__
namespace {
using B = bitset<4096>;
void solve() {
int h, w;
scan(h, w);
vector<string> s(h);
scan(s);
vector<B> f(h * w);
for (int si : rep(h)) {
for (int sj : rep(w)) {
auto id = [&](int i, int j) { return (i + (h - si - 1)) * (w * 2 - 1) + (j + (w - sj - 1)); };
if (s[si][sj] == '.') {
f[si * w + sj][id(si, sj)] = 1;
vector q{pair{si, sj}};
for (int qi = 0; qi < len(q); ++qi) {
auto [i, j] = q[qi];
for (auto [di, dj] : vector{pair{0, 1}, pair{0, -1}, pair{1, 0}, pair{-1, 0}}) {
int ni = i + di, nj = j + dj;
if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
if (s[ni][nj] != '.') continue;
if (f[si * w + sj][id(ni, nj)]) continue;
f[si * w + sj][id(ni, nj)] = 1;
q.emplace_back(ni, nj);
}
}
}
}
}
int ans = 0;
for (int i : rep(h * w)) {
bool ok = true;
for (int j : rep(h * w)) {
if (i != j) {
if ((f[i] & ~f[j]).none()) {
ok = false;
break;
}
}
}
ans += ok;
}
print(ans);
}
} // namespace
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t;
scan(t);
while (t--) {
solve();
}
}
#else // __INCLUDE_LEVEL__
#include <bits/stdc++.h>
using namespace std;
template <class T>
concept tuple_like = __is_tuple_like<T>::value && !ranges::range<T>;
template <class R>
concept nstr_range = ranges::range<R> && !convertible_to<R, string_view>;
namespace std {
istream& operator>>(istream& is, tuple_like auto&& t) {
return apply([&is](auto&... xs) -> istream& { return (is >> ... >> xs); }, t);
}
istream& operator>>(istream& is, nstr_range auto&& r) {
for (auto&& e : r) {
is >> e;
}
return is;
}
ostream& operator<<(ostream& os, tuple_like auto&& t) {
auto f = [&os](auto&... xs) -> ostream& {
[[maybe_unused]] auto sep = "";
((os << exchange(sep, " ") << xs), ...);
return os;
};
return apply(f, t);
}
ostream& operator<<(ostream& os, nstr_range auto&& r) {
auto sep = "";
for (auto&& e : r) {
os << exchange(sep, " ") << e;
}
return os;
}
#define DEF_INC_OR_DEC(op) \
auto& operator op(tuple_like auto&& t) { \
apply([](auto&... xs) { (op xs, ...); }, t); \
return t; \
} \
auto& operator op(nstr_range auto&& r) { \
for (auto&& e : r) { \
op e; \
} \
return r; \
}
DEF_INC_OR_DEC(++)
DEF_INC_OR_DEC(--)
#undef DEF_INC_OR_DEC
} // namespace std
void scan(auto&&... xs) { cin >> tie(xs...); }
void print(auto&&... xs) { cout << tie(xs...) << '\n'; }
using views::drop;
using views::take;
inline constexpr auto rev = views::reverse;
inline constexpr auto len = ranges::ssize;
inline auto rep(int l, int r) { return views::iota(min(l, r), r); }
inline auto rep(int n) { return rep(0, n); }
inline auto rep1(int l, int r) { return rep(l, r + 1); }
inline auto rep1(int n) { return rep(1, n + 1); }
#endif // __INCLUDE_LEVEL__
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3436kb
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: 3440kb
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'