QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#440026 | #7733. Cool, It’s Yesterday Four Times More | Alphagocc | WA | 18ms | 3832kb | C++23 | 12.1kb | 2024-06-12 23:26:35 | 2024-06-12 23:26:35 |
Judging History
answer
/*学习古代文章,诗词
壬戌之秋,七月既望,苏子与客泛舟游于赤壁之下。
清风徐来,水波不兴。
举酒属客,诵明月之诗,歌窈窕之章。
少焉,月出于东山之上,徘徊于斗牛之间。
白露横江,水光接天。
纵一苇之所如,凌万顷之茫然。
浩浩乎如冯虚御风,而不知其所止;
飘飘乎如遗世独立,羽化而登仙。
于是饮酒乐甚,扣舷而歌之。
歌曰:“桂棹兮兰桨,击空明兮溯流光。
渺渺兮予怀,望美人兮天一方。
”客有吹洞箫者,倚歌而和之。
其声呜呜然,如怨如慕,如泣如诉;余音袅袅,不绝如缕。
舞幽壑之潜蛟,泣孤舟之嫠妇。
苏子愀然,正襟危坐,而问客曰:“何为其然也?”
客曰:“‘月明星稀,乌鹊南飞。’此非曹孟德之诗乎?
西望夏口,东望武昌,山川相缪,郁乎苍苍,此非孟德之困于周郎者乎?
方其破荆州,下江陵,顺流而东也,舳舻千里,旌旗蔽空,酾酒临江,横槊赋诗,固一世之雄也,而今安在哉?
况吾与子渔樵于江渚之上,侣鱼虾而友麋鹿,驾一叶之扁舟,举匏尊以相属。
寄蜉蝣于天地,渺沧海之一粟。
哀吾生之须臾,羡长江之无穷。
挟飞仙以遨游,抱明月而长终。
知不可乎骤得,托遗响于悲风。”
苏子曰:“客亦知夫水与月乎?逝者如斯,而未尝往也;盈虚者如彼,而卒莫消长也。
盖将自其变者而观之,则天地曾不能以一瞬;
自其不变者而观之,则物与我皆无尽也,而又何羡乎!
且夫天地之间,物各有主,苟非吾之所有,虽一毫而莫取。
惟江上之清风,与山间之明月,耳得之而为声,目遇之而成色,取之无禁,用之不竭。
是造物者之无尽藏也,而吾与子之所共适。”
客喜而笑,洗盏更酌。
肴核既尽,杯盘狼籍。
相与枕藉乎舟中,不知东方之既白。
*/
//Generated at 2024-06-12 23:26:24 UTC+8
//Created by Alphagocc
#ifndef TYPE_HPP
#define TYPE_HPP
#include <type_traits>
#ifndef __cpp_lib_void_t
namespace std
{
template <typename...> using void_t = void;
}
#endif
template <typename T, typename _ = void> struct is_container : std::false_type
{};
template <typename... Ts> struct is_container_helper
{};
template <typename T>
struct is_container<T,
typename std::conditional<false,
is_container_helper<decltype(std::declval<T>().size()),
decltype(std::declval<T>().begin()),
decltype(std::declval<T>().end())>,
void>::type> : public std::true_type
{};
#endif
#include <cstdio>
#include <string>
#include <utility>
#include <vector>
#define FI __inline__ __attribute__((always_inline))
class IO
{
static const int bufSize = 1 << 20;
char inBuf[bufSize], outBuf[bufSize];
char *ip1 = inBuf, *ip2 = inBuf;
int goodReadBit = 1, op1 = -1, op2 = bufSize - 1;
template <typename T> FI void __RI(T &x)
{
int ch = gc(), neg = 1;
x = 0;
for (; !(isdigit(ch) || ch == '-' || ch == EOF); ch = gc()) {}
if (ch == EOF) [[unlikely]]
return;
if (ch == '-') neg = -1, ch = gc();
for (; isdigit(ch); ch = gc()) x = x * 10 + (ch - 48) * neg;
}
template <typename T> FI void __RC(T &x)
{
int ch;
while (isspace(ch = gc())) {}
if (ch == EOF) return;
x = ch;
}
FI void __RS(std::string &x)
{
int ch;
x.clear();
for (ch = gc(); isspace(ch); ch = gc()) {}
if (ch == EOF) return;
for (; !isspace(ch) && ch != EOF; ch = gc()) x.push_back(ch);
}
public:
FI int gc()
{
return ip1 == ip2 && (ip2 = (ip1 = inBuf) + fread(inBuf, 1, bufSize, stdin), ip1 == ip2)
? (goodReadBit = 0, EOF)
: *ip1++;
}
FI IO &R(char &x) { return __RC(x), (*this); }
FI IO &R(unsigned char &x) { return __RC(x), (*this); }
FI IO &R(std::string &x) { return __RS(x), (*this); }
template <typename T1, typename T2> FI IO &R(std::pair<T1, T2> &x)
{
return R(x.first, x.second), (*this);
}
template <typename T, typename... Args> FI IO &RA(T *a, int n)
{
for (int i = 0; i < n; ++i) R(a[i]);
return (*this);
}
template <typename T, typename... Args> FI IO &R(T &x, Args &...args)
{
return R(x), R(args...), (*this);
}
template <typename T, typename... Args> FI IO &RA(T *a, int n, Args... args)
{
for (int i = 0; i < n; ++i) RA(a[i], args...);
return (*this);
}
template <typename T> FI typename std::enable_if<std::is_integral<T>::value, IO>::type &R(T &x)
{
return __RI(x), (*this);
}
template <typename T> FI typename std::enable_if<is_container<T>::value, IO>::type &R(T &x)
{
for (auto &i : x) R(i);
return (*this);
}
template <typename T>
FI typename std::enable_if<std::is_void<std::void_t<decltype(std::declval<T>().read())>>::value,
IO>::type &
R(T &x)
{
return x.read(), (*this);
}
private:
const char space = ' ';
template <typename T> FI void __WI(T _x)
{
typename std::make_unsigned<T>::type x = _x;
if (_x < 0) pc('-'), x = ~x + 1;
static char buf[sizeof(T) * 16 / 5];
static int len = -1;
static constexpr char digits[201] = "0001020304050607080910111213141516171819"
"2021222324252627282930313233343536373839"
"4041424344454647484950515253545556575859"
"6061626364656667686970717273747576777879"
"8081828384858687888990919293949596979899";
while (x >= 100) {
auto num = (x % 100) * 2;
x /= 100;
buf[++len] = digits[num + 1];
buf[++len] = digits[num];
}
if (x >= 10) {
auto num = (x % 100) * 2;
buf[++len] = digits[num + 1];
buf[++len] = digits[num];
} else {
buf[++len] = '0' + x;
}
while (len >= 0) { pc(buf[len]), --len; }
}
public:
FI void pc(const char &x)
{
if (op1 == op2) flush();
outBuf[++op1] = x;
}
FI void flush() { fwrite(outBuf, 1, op1 + 1, stdout), op1 = -1; }
FI IO &W() { return (*this); }
FI IO &W(const char &x) { return pc(x), (*this); }
FI IO &W(const char *x)
{
while (*x != '\0') pc(*(x++));
return (*this);
}
FI IO &W(const std::string &x) { return W(x.c_str()), (*this); }
template <typename T1, typename T2> FI IO &W(const std::pair<T1, T2> &x)
{
W(x.first, x.second);
return (*this);
}
FI IO &WL() { return W('\n'), (*this); }
FI IO &WS() { return W(space), (*this); }
template <typename T> FI IO &WA(T *a, int n)
{
for (int i = 0; i < n; i++) WS(a[i]);
WL();
return (*this);
}
template <typename T, typename... Args> FI IO &W(const T &x, const Args &...args)
{
W(x), W(space), W(args...);
return (*this);
}
template <typename... Args> FI IO &WS(const Args &...args)
{
return W(args...), W(space), (*this);
}
template <typename... Args> FI IO &WL(const Args &...args)
{
return W(args...), W('\n'), (*this);
}
template <typename T, typename... Args> FI IO &WA(T *a, int n, Args... args)
{
for (int i = 0; i < n; i++) WA(a[i], args...);
return (*this);
}
template <typename T>
FI typename std::enable_if<std::is_integral<T>::value, IO>::type &W(const T &x)
{
return __WI(x), (*this);
}
template <typename T>
FI typename std::enable_if<is_container<T>::value, IO>::type &W(const T &x)
{
for (auto &i : x) { is_container<decltype(i)>::value ? W(i) : WS(i); }
WL();
return (*this);
}
template <typename T>
FI typename std::enable_if<
std::is_void<std::void_t<decltype(std::declval<T>().write())>>::value, IO>::type &
W(const T &x)
{
return x.write(), (*this);
}
template <typename T> FI IO &operator>>(T &x)
{
R(x);
return (*this);
}
template <typename T> FI IO &operator<<(const T &x)
{
W(x);
return (*this);
}
int good() { return goodReadBit; }
IO() {}
~IO() { flush(); }
} io;
#undef FI
#ifndef UTIL_HPP
#define UTIL_HPP
#include <bits/stdc++.h>
#include <cstdint>
#define var auto
#define ALL(x) x.begin(), x.end()
#define If(x, y, z) ((x) ? (y) : (z))
using i128 = __int128_t;
using i64 = int64_t;
using i32 = int32_t;
using i16 = int16_t;
using u128 = __uint128_t;
using u64 = uint64_t;
using u32 = uint32_t;
using u16 = uint16_t;
constexpr i32 INF = 0x3f3f3f3f;
constexpr i64 INFL = 0x3f3f3f3f3f3f3f3f;
#define FILEIO(x) \
do { \
freopen(#x ".in", "r", stdin); \
freopen(#x ".out", "w", stdout); \
} while (0)
#endif
#ifndef MULTIVECTOR_HPP
#define MULTIVECTOR_HPP
#include <vector>
template <typename T, int Dimension>
struct MultiVector : public std::vector<MultiVector<T, Dimension - 1>>
{
MultiVector(std::size_t n = 0)
: std::vector<MultiVector<T, Dimension - 1>>(
n, MultiVector<T, Dimension - 1>())
{}
template <typename... Args>
MultiVector(std::size_t n, const Args &...args)
: std::vector<MultiVector<T, Dimension - 1>>(
n, MultiVector<T, Dimension - 1>(args...))
{}
template <typename... Args> void resize(std::size_t n, const Args &...args)
{
std::vector<MultiVector<T, Dimension - 1>>::resize(n);
for (auto &i : (*this)) i.resize(args...);
}
void resize() {}
template <typename... Args> void assign(std::size_t n, const Args &...args)
{
std::vector<MultiVector<T, Dimension - 1>>::resize(n);
for (auto &i : (*this)) i.assign(args...);
}
};
template <typename T> struct MultiVector<T, 1> : public std::vector<T>
{
MultiVector(std::size_t n = 0)
: std::vector<T>(n)
{}
MultiVector(std::size_t n, const T &x)
: std::vector<T>(n, x)
{}
void resize(std::size_t n = 0) { std::vector<T>::resize(n); }
void resize(std::size_t n, const T &x) { std::vector<T>::resize(n, x); }
};
#endif
using namespace std;
const int dir[4][2] = { { 0, 1 }, { -1, 0 }, { 0, -1 }, { 1, 0 } };
void solve()
{
int n, m;
io >> n >> m;
MultiVector<char, 2> a(n, m);
io >> a;
vector<bitset<4234>> b;
auto dfs = [&](auto &dfs, int x, int y, int tx, int ty) {
if (x >= n || y >= m || x < 0 || y < 0) return;
if (a[x][y] == 'O') return;
b.back()[tx * m + ty] = 1;
a[x][y] = 'O';
for (const auto &[dx, dy] : dir) { dfs(dfs, x + dx, y + dy, tx + dx, ty + dy); }
};
for (int i = 0; i < n; i++)
for (int j = 0; j < m; j++) {
if (a[i][j] == '.') {
b.push_back({});
dfs(dfs, i, j, 1, 0);
}
}
auto in = [](auto i, auto j) { return ((i | j) == j); };
int ans = 0;
for (int i = 0; i < b.size(); i++) {
bool ok = 1;
for (int j = 0; j < b.size(); j++) {
if (i == j) continue;
for (int k = 0; k < n * m; k++)
if (in(b[i] << k, b[j])) {
ok = 0;
break;
}
}
if (ok) ans += b[i].count();
}
io.WL(ans);
}
int main()
{
int T;
io >> T;
while (T--) { solve(); }
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3600kb
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: 0
Accepted
time: 0ms
memory: 3788kb
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 0 1 0 7 9 4 4 0 6 5 2 0 1 6 4 5 2 0 0 5 3 3 1 4 1 0 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 0 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 0 2 11 2 2 4 0 4 4 6 2 1 2 3 0 5 0 16 4 3 2 6 0 8 3 3 1...
result:
ok 200 lines
Test #3:
score: -100
Wrong Answer
time: 18ms
memory: 3832kb
input:
50 10 9 OOOO.O... O...O.OOO .....O... ..OO..O.O ...O..O.O ..OOO..O. ..OOO...O .OO.O..OO .O.O.OO.. .O..O.O.O 10 10 .O.OOO.OO. ...OOOOOOO ...O.O..O. .O.O..O... .O.O.OO..O ..OO.O..OO O....O..OO OO...OOOOO OO.OO.O..O .O.O.OOOOO 10 8 O..OOO.O O.OOOO.. O..OO.OO OO..OO.. .OOO..O. .OO.OO.O OOO..OO. ..O..OO....
output:
31 40 13 25 40 37 27 29 20 26 25 29 21 29 21 31 32 31 33 34 25 31 18 25 41 28 20 38 20 29 18 21 27 28 35 13 20 17 32 29 28 23 23 23 24 18 28 17 35 24
result:
wrong answer 28th lines differ - expected: '45', found: '38'