QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#666179#7733. Cool, It’s Yesterday Four Times MoretzwWA 0ms9760kbC++232.3kb2024-10-22 16:58:372024-10-22 16:58:40

Judging History

This is the latest submission verdict.

  • [2024-10-22 16:58:40]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 9760kb
  • [2024-10-22 16:58:37]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
char c[1010][1010];
int vis[1010][1010], n, m, ans, cnt, sum[1000010], b[4][2] = { { 1, 0 }, { 0, 1 }, { -1, 0 }, { 0, -1 } };
pair<int, int> pr[1000010];
void dfs(int x, int y)
{
    if (x < pr[cnt].first)
        pr[cnt] = { x, y };
    else if (x == pr[cnt].first && y < pr[cnt].second)
        pr[cnt] = { x, y };
    vis[x][y] = cnt;
    sum[cnt]++;
    for (int i = 0; i < 4; i++) {
        int ux = x + b[i][0], uy = y + b[i][1];
        if (ux > n || ux < 1 || uy > m || uy < 1)
            continue;
        if (!vis[ux][uy] && c[ux][uy] == '.')
            dfs(ux, uy);
    }
}
void solve()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> c[i][j];
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (!vis[i][j] && c[i][j] == '.') {
                cnt++;
                pr[cnt].first = i, pr[cnt].second = j;
                dfs(i, j);
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= cnt; i++) {
        bool flag1 = 1;
        for (int j = 1; j <= cnt; j++) {
            bool flag2 = 1;
            if (i == j)
                continue;
            for (int x1 = 1; x1 <= n; x1++) {
                for (int y1 = 1; y1 <= m; y1++) {
                    if (vis[x1][y1] == i) {
                        int x2 = x1 - pr[i].first + pr[j].first, y2 = y1 - pr[i].second + pr[j].second;
                        if (x2 > n || x2 < 1 || y2 > m || y2 < 1) {
                            flag2 = 0;
                            break;
                        } else if (vis[x2][y2] != j) {
                            flag2 = 0;
                            break;
                        }
                    }
                }
            }
            if (flag2)
                flag1 = 0;
        }
        if (flag1)
            ans += sum[i];
    }
    cout << ans << endl;

    for (int i = 1; i <= cnt; i++) {
        pr[i] = { 0, 0 };
        sum[i] = 0;
    }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            vis[i][j] = 0;
    cnt = 0;
    ans = 0;
}
int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 9760kb

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
5
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
9
1
6
2
2
5
4
5
2
1
0
1
9
3
4
11
0
3
2
1
0
0
4
3
1
4
3
10
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
...

result:

wrong answer 7th lines differ - expected: '3', found: '5'