QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#643468#7733. Cool, It’s Yesterday Four Times More1820357523WA 1ms3792kbC++203.2kb2024-10-15 21:18:452024-10-15 21:18:46

Judging History

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

  • [2024-10-15 21:18:46]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3792kb
  • [2024-10-15 21:18:45]
  • 提交

answer

#include <bits/stdc++.h>

#define ll long long
#define endl "\n"
#define __count __builtin_popcountll
#define yes cout<<"Yes\n";
#define no cout<<"No\n";
using namespace std;
ll fe, cnt;

void solve() {
    ll n, m;
    cin >> n >> m;

    std::vector<std::string> s(n);
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    if (fe == 50) {
        if (++cnt == 28) {
            cout << n << " " << m << endl;
            for (int i = 0; i < n; ++i) {
                cout << s[i] << endl;
            }
        } else return;
    }

    ll dx[] = {0, 0, 1, -1};
    ll dy[] = {1, -1, 0, 0};

    std::vector vis(n, std::vector<ll>(m));

    std::vector<std::vector<ll>> e;
    auto f = e;
    std::map<std::vector<ll>, ll> mp;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (s[i][j] == 79 || vis[i][j]) continue;
            std::vector<ll> a;

            auto dfs = [&](auto &&self, ll X, ll Y) -> void {
                vis[X][Y] = 1;
                a.push_back(X * m + Y);
                for (int i = 0; i < 4; ++i) {
                    ll x = dx[i] + X;
                    ll y = dy[i] + Y;
                    if (x < 0 || x >= n || y < 0 || y >= m || s[x][y] == 79 || vis[x][y]) {
                        continue;
                    }
                    self(self, x, y);
                }
            };
            dfs(dfs, i, j);

            sort(a.begin(), a.end());
//            cerr << "now " << i << " " << j << endl;
//            for (auto x: a) cerr << x << " \n"[x == a.back()];
//            for (auto x: a) cerr << x / m + 1 << " " << x % m + 1 << endl;
//            cerr << endl;
            ll old = a[0];
            for (auto &x: a) x -= old;
//            for (auto x: a) cerr << x << " \n"[x == a.back()];
//            for (auto x: a) cerr << x / m + 1 << " " << x % m + 1 << endl;
            mp[a]++;
//            cerr << endl;
            e.push_back(a);
        }
    }

    for (auto x: e) {
        if (mp[x] <= 1) f.push_back(x);
    }
    e = f;

    sort(e.begin(), e.end(), [&](std::vector<ll> a, std::vector<ll> b) {
        return a.size() < b.size();
    });
//    for (auto now: e) for (auto x: now) cerr << x << " \n"[x == now.back()];
//    for (auto now: e) for (auto x: now) cerr << x / m + 1 << " " << x % m + 1 << endl;


    ll ans = 0;
    for (int i = 0; i < e.size(); ++i) {
        ll flag = 0, tot = 0;
        auto &now = e[i];
        for (int j = i + 1; j < e.size(); ++j) {
            for (int k = 0; k < e[j].size(); ++k) {
                tot = 0;
                for (int l = k; l < e[j].size(); ++l) {
                    if (e[j][l] - now[tot] == e[j][k] - now[0]) {
                        tot++;
                        if (tot == now.size()) {
                            flag = 1;
                            break;
                        }
                    }
                }
            }
        }

        if (flag == 0) ans += e[i].size();
    }

    cout << ans << endl;
}

signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);

    ll t = 1;
    cin >> t;
    fe = t;
    while (t--)
        solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3536kb

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

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: 0ms
memory: 3792kb

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:

10 9
OOO....O.
..O..OO.O
.OO.OOO.O
...O.O.OO
...O..O..
O.OOO..OO
OO.O.....
..O.OO...
O..O....O
.....OO..
38

result:

wrong answer 1st lines differ - expected: '31', found: '10 9'