QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#618598 | #7733. Cool, It’s Yesterday Four Times More | Iron_gainer | WA | 0ms | 3564kb | C++20 | 2.8kb | 2024-10-07 00:14:28 | 2024-10-07 00:14:28 |
Judging History
answer
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<bitset>
#include<cmath>
#include<queue>
typedef long long ll;
using namespace std;
typedef pair<int, int>pii;
void speed()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
}
int xx[4] = { 0,0,-1,1 };
int yy[4] = { 1,-1,0,0 };
int n, m;
int tsum;
bool a[1005][1005];
bool vis[1005][1005];
pii que[1005];
bool check(int x, int y)
{
if (x <= n && x >= 1 && y <= m && y >= 1&&a[x][y])
return 1;
else
return 0;
}
void dfs(int x, int y)
{
if (vis[x][y]) return;
vis[x][y] = 1;
que[++tsum] = { x,y };
for (int i = 0; i < 4; i++)
{
if (check(xx[i] + x, yy[i] + y)&&!vis[xx[i]+x][yy[i]+y])
{
dfs(xx[i] + x, yy[i] + y);
}
}
}
int main()
{
speed();
int t;
cin >> t;
while (t--)
{
cin >> n >> m;
for (int i = 1; i <= n; i++)
{
string s;
cin >> s;
for (int j = 1; j <= m; j++)
{
if (s[j - 1] == '.')
a[i][j] = 1;
}
}
int ans = 0;
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
tsum = 0;
if (!vis[i][j]&&a[i][j])
{
dfs(i, j);
bool tis = 1;
for (int k = 1; k <= n; k++)
{
for (int l = 1; l <= m; l++)
{
if (!tis)
break;
if (i == k && j == l) continue;
int disx = k - i;
int disy = l - j;
int is = 0;
for (int o = 1; o <= tsum; o++)
{
if (!a[que[o].first + disx ][que[o].second + disy])
{
is = 1;
break;
}
}
if (!is)
{
tis = 0;
}
}
}
if (tis)
{
ans = tsum;
}
}
}
}
cout << ans << '\n';
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
vis[i][j] = 0;
a[i][j] = 0;
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3564kb
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: 3560kb
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 3 9 4 4 0 6 5 2 0 1 6 4 5 2 0 0 5 3 3 1 4 1 0 3 5 2 3 7 3 0 6 2 2 2 0 4 6 6 3 3 2 3 2 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 3 2 2 1 3 3 4 0 2 11 2 2 4 0 4 2 3 2 1 2 3 0 5 0 16 4 3 2 6 0 8 3 3 1...
result:
wrong answer 12th lines differ - expected: '7', found: '3'