QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#440019#7733. Cool, It’s Yesterday Four Times MoreAlphagoccWA 1ms3752kbC++2313.5kb2024-06-12 23:20:502024-06-12 23:20:53

Judging History

你现在查看的是最新测评结果

  • [2024-06-12 23:20:53]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3752kb
  • [2024-06-12 23:20:50]
  • 提交

answer

/*学习古代文章,诗词
醉翁亭记 北宋·欧阳修

环滁皆山也。其西南诸峰,林壑尤美。望之蔚然而深秀者,琅琊也。山行六七里,渐闻水声潺潺,而泻出于两峰之间者,让泉也。峰回路转,有亭翼然临于泉上者,醉翁亭也。作亭者谁?山之僧曰智仙也。名之者谁?太守自谓也。太守与客来饮于此,饮少辄醉,而年又最高,故自号曰醉翁也。醉翁之意不在酒,在乎山水之间也。山水之乐,得之心而寓之酒也。

若夫日出而林霏开,云归而岩穴暝,晦明变化者,山间之朝暮也。野芳发而幽香,佳木秀而繁阴,风霜高洁,水落而石出者,山间之四时也。朝而往,暮而归,四时之景不同,而乐亦无穷也。

至于负者歌于途,行者休于树,前者呼,后者应,伛偻提携,往来而不绝者,滁人游也。临谿而渔,谿深而鱼肥;酿泉为酒,泉香而酒洌;山肴野蔌,杂然而前陈者,太守宴也。宴酣之乐,非丝非竹,射者中,弈者胜,觥筹交错,起坐而喧哗者,众宾欢也;苍颜白发,颓然乎其间者,太守醉也。

已而夕阳在山,人影散乱,太守归而宾客从也。树林阴翳,鸣声上下,游人去而禽鸟乐也。然而禽鸟知山林之乐,而不知人之乐;人知从太守游而乐,而不知太守之乐其乐也。醉能同其乐,醒能述以文者,太守也。太守谓谁?庐陵欧阳修也。

岳阳楼记 北宋·范仲淹

庆历四年春,滕子京谪守巴陵郡。越明年,政通人和,百废具兴,乃重修岳阳楼,增其旧制,刻唐贤今人诗赋于其上;属予作文以记之。

予观夫巴陵胜状,在洞庭一湖。衔远山,吞长江,浩浩汤汤,横无际涯;朝晖夕阴,气象万千;此则岳阳楼之大观也,前人之述备矣。然则北通巫峡,南极潇湘,迁客骚人,多会于此,览物之情,得无异乎?

若夫霪雨霏霏,连月不开;阴风怒号,浊浪排空;日星隐曜,山岳潜形;商旅不行,樯倾楫摧;薄暮冥冥,虎啸猿啼。登斯楼也,则有去国怀乡,忧谗畏讥,满目萧然,感极而悲者矣。

至若春和景明,波澜不惊,上下天光,一碧万顷;沙鸥翔集,锦鳞游泳,岸芷汀兰,郁郁青青。而或长烟一空,皓月千里,浮光跃金,静影沉璧,渔歌互答,此乐何极。登斯楼也,则有心旷神怡,宠辱皆忘,把酒临风,其喜洋洋者矣。

嗟夫!予尝求古仁人之心,或异二者之为,何哉?不以物喜,不以己悲。居庙堂之高,则忧其民;处江湖之远,则忧其君。是进亦忧,退亦忧;然则何时而乐耶?其必曰:“先天下之忧而忧,后天下之乐而乐”欤!噫!微斯人,吾谁与归?

马说 唐·韩愈

世有伯乐,然后有千里马。千里马常有,而伯乐不常有。故虽有名马,祗辱于奴隶人之手,骈死于槽枥之间,不以千里称也。

马之千里者,一食或尽粟一石。食马者不知其能千里而食也。是马也,虽有千里之能,食不饱,力不足,才美不外见,且欲与常马等不可得,安求其能千里也?

策之不以其道,食之不能尽其材,鸣之而不能通其意,执策而临之,曰:“天下无马!”呜呼!其真无马邪?其真不知马也!
*/
//Generated at 2024-06-12 23:20:39 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<1234>> 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 < 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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3616kb

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: 1ms
memory: 3752kb

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
9
3
0
6
2
2
2
0
4
6
6
3
5
2
5
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:

wrong answer 39th lines differ - expected: '7', found: '9'