QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#617844 | #7733. Cool, It’s Yesterday Four Times More | mcqueen1 | WA | 0ms | 6000kb | C++14 | 1.8kb | 2024-10-06 17:21:44 | 2024-10-06 17:21:45 |
Judging History
answer
#include<bits/stdc++.h>
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define ll long long
#define pb push_back
using namespace std;
int n,m;
char s[1005][1005];
int col[1005][1005],colc;
bool lose[1005];
vector<pii> point[1005];
const int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
void dfs(int x,int y)
{
col[x][y]=colc;
for(int i=0;i<4;++i)
{
int nx=x+dx[i],ny=y+dy[i];
if(nx<0||nx>=n||ny<0||ny>=m||col[nx][ny]>0||s[nx][ny]=='O')
continue;
dfs(nx,ny);
}
}
void work()
{
scanf("%d%d",&n,&m);
colc=0;
for(int i=0;i<n;++i)
for(int j=0;j<m;++j)
col[i][j]=0;
for(int i=0;i<n;++i)
scanf("%s",s[i]);
for(int i=0;i<n;++i)
for(int j=0;j<m;++j)
if(col[i][j]==0&&s[i][j]=='.')
{
++colc;
dfs(i,j);
}
for(int i=1;i<=colc;++i)point[i].clear();
for(int i=0;i<n;++i)
for(int j=0;j<m;++j)
if(col[i][j]>0)
{
point[col[i][j]].pb(mp(i,j));
}
for(int i=1;i<=colc;++i)
for(int j=1;j<=colc;++j)
if(i!=j)
{
pii p1=point[i][0];
bool Lose = 0;
for(auto e:point[j])
{
bool Win=0;
for(auto e2:point[i])
{
if(e2.fi-p1.fi+e.fi<0||e2.fi-p1.fi+e.fi>=n||e2.se-p1.se+e.se<0||e2.se-p1.se+e.se>=m||col[e2.fi-p1.fi+e.fi][e2.se-p1.se+e.se]!=col[e.fi][e.se])
{
Win = 1;
break;
}
}
if(!Win)
{
Lose = 1;
break;
}
}
if(Lose)
{
lose[i]=1;
break;
}
}
int ans=0;
for(int i=0;i<n;++i)
for(int j=0;j<m;++j)
if(s[i][j]=='.'&&!lose[col[i][j]])
++ans;
printf("%d\n",ans);
}
int main()
{
// mt19937_54 rng(chrono::steady_clock::now.time_since_epoch().count());
// for(int i=0;i<=1000;++i)
// for(int j=0;j<=1000;++j)
// Hash[i][j]=rng();
int T;
scanf("%d",&T);
while(T--)work();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 6000kb
input:
4 2 5 .OO.. O..O. 1 3 O.O 1 3 .O. 2 3 OOO OOO
output:
3 0 0 0
result:
wrong answer 2nd lines differ - expected: '1', found: '0'