QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#661564#7733. Cool, It’s Yesterday Four Times Morewdbl857WA 0ms3904kbC++202.7kb2024-10-20 16:51:262024-10-20 16:51:27

Judging History

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

  • [2024-10-20 16:51:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3904kb
  • [2024-10-20 16:51:26]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define ios ios::sync_with_stdio(0), cin.tie(0)
#define ll long long
#define int128 __int128
#define ull unsigned long long
#define endl "\n"
#define pi acos(-1)
#define pii pair<int, int>
const double eps = 1e-6;
const int N = 1e6 + 10, M = 1010, INF = 0x3f3f3f3f;
const int mod = 998244353;
char a[M][M];
int sd[M][M];
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
void solve()
{
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            a[i][j] = '.';
            // cin >> a[i][j];
            sd[i][j] = 0;
        }
    }
    map<pii, set<pii>> mp;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (a[i][j] == '.')
            {
                vector<pii> v;
                queue<pii> q;
                q.push({i, j});
                sd[i][j] = 1;
                while (q.size())
                {
                    auto [x, y] = q.front();
                    //   cout << x << ' ' << y << '-' << endl;
                    q.pop();
                    mp[{i, j}].insert({x - i, y - j});
                    v.push_back({x, y});
                    sd[x][y] = 1;
                    for (int i = 0; i < 4; i++)
                    {
                        int xx = x + dx[i], yy = y + dy[i];
                        if (sd[xx][yy] || xx < 1 || xx > n || yy < 1 || yy > m || a[xx][yy] == 'O')
                            continue;
                        q.push({xx, yy});
                        sd[xx][yy] = 1;
                    }
                }
                for (auto [x, y] : v)
                {
                    sd[x][y] = 0;
                }
            }
        }
    }
    // for (auto [x, y] : mp[{1, 1}])
    // {
    //     cout << x << ' ' << y << endl;
    // }
    int ans = 0;
    for (auto [x, y] : mp)
    {
        int f = 1;
        for (auto [u, v] : mp)
        {
            if (x.first == u.first && x.second == u.second)
                continue;
            int ff = 1;
            for (auto [xx, yy] : y)
            {
                if (!v.count({xx, yy}))
                {
                    ff = 0;
                    break;
                }
            }
            if (ff == 1)
            {
                f = 0;
                break;
            }
        }
        ans += f;
    }
    cout << ans << endl;
}
signed main()
{
    ios;
    int T = 1;
    cin >> T;
    // cout << fixed << setprecision(8);
    for (int i = 1; i <= T; i++)
    {
        // cout << "Case " << i << ": ";
        solve();
    }

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3904kb

input:

4
2 5
.OO..
O..O.
1 3
O.O
1 3
.O.
2 3
OOO
OOO

output:

10
0
0
0

result:

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