QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#402093 | #7733. Cool, It’s Yesterday Four Times More | Asda111 | WA | 5ms | 4692kb | C++14 | 2.6kb | 2024-04-29 21:20:18 | 2024-04-29 21:20:18 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e3 + 10 + 10;
const int INF = 0x3f3f3f3f;
int t, idx, n, m;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, -1, 1};
char a[N][N];
bool st[N][N];
vector<set<pair<int, int>>> p(N);
void dfs(int x, int y, int k)
{
st[x][y] = true;
// cout<<x<<' '<<y<<endl;
p[k].insert({x, y});
for (int i = 0; i < 4; i++)
{
int tx = x + dx[i], ty = y + dy[i];
if (tx <= n && tx >= 1 && ty >= 1 && ty <= m && a[tx][ty] == '.' && !st[tx][ty])
dfs(tx, ty, k);
}
}
bool check(int l, int r)
{
vector<pair<int,int>>b;
pair<int,int>x{0,0};
for (auto k : p[l])
{
if(x.first==0&&x.second==0)
{
x=k;
}
else
{
b.push_back({x.first-k.first,x.second-k.second});
}
}
bool flag=true;
for(auto k:p[r])
{
for(auto y:b)
{
flag=true;
if(p[r].count({k.first+y.first,k.second+y.second})==0)
{
flag=false;
break;
}
}
}
return flag;
}
void solve()
{
cin >> n >> m;
idx = 0;
memset(st, 0, sizeof(st));
for (int i = 0; i < N; i++)
p[i].clear();
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
cin >> a[i][j];
}
}
for (int i = 1; i <= n; i++)
{
for (int j = 1; j <= m; j++)
{
if (a[i][j] == '.' && !st[i][j])
{
dfs(i, j, ++idx);
}
}
}
// for(int i=1;i<=3;i++)
// cout<<p[i].size()<<' ';
// cout<<endl;
int res = 0;
//cout<<" "<<idx<<endl;
for (int i = 1; i <= idx; i++)
{
bool flag = true;
//cout<<i<<endl;
for (int j = 1; j <= idx; j++)
{
if(i==j)
continue;
if (p[i].size() <= p[j].size())
{
flag = false;
break;
}
//cout<<"sss"<<i<<' '<<j<<endl;
if (check(i, j))
{
flag = false;
break;
}
}
if (flag == true)
res += p[i].size();
}
cout<<res<<endl;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
t = 1;
cin >> 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: 4688kb
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: 5ms
memory: 4692kb
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 4 9 4 4 0 6 5 2 0 1 6 4 5 2 0 0 5 3 3 1 4 1 0 4 5 2 3 7 3 0 6 2 2 2 0 4 6 6 3 3 2 3 3 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 0 2 3 1 3 3 4 0 2 11 2 2 4 0 4 0 0 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: '4'