QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#527586 | #7733. Cool, It’s Yesterday Four Times More | Stelor | WA | 3ms | 3732kb | C++20 | 1.6kb | 2024-08-22 17:22:04 | 2024-08-22 17:22:04 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define PII pair<int,int>
#define PIIII pair<PII,PII>
const int N=1e3+100;
int n,m,ans,dx[]={0,0,1,-1},dy[]={1,-1,0,0};
char s[N][N];
map<PIIII,int> mp;
bool fail(int x,int y)
{
if(x>n||x<1||y>m||y<1||s[x][y]!='.') return true;
return false;
}
void dfs(int x,int y,int i,int j)
{
mp[{{x,y},{i,j}}]=1;
for(int t=0;t<4;++t)
{
int nx=x+dx[t],ny=y+dy[t];
int ni=i+dx[t],nj=j+dy[t];
if(fail(nx,ny)) continue;
if(fail(ni,nj))
{
mp[{{x,y},{i,j}}]=2;
mp[{{nx,ny},{ni,nj}}]=2;
continue;
}
if(!mp.count({{nx,ny},{ni,nj}}))
{
dfs(nx,ny,ni,nj);
if(mp[{{nx,ny},{ni,nj}}]==2)
{
mp[{{x,y},{i,j}}]=2;
}
}else
{
if(mp[{{nx,ny},{ni,nj}}]==2)
mp[{{x,y},{i,j}}]=2;
}
}
}
void work(int x,int y)
{
int now=0;
for(int i=1;i<=n;++i)
{
for(int j=1;j<=m;++j)
{
if(i==x&&y==j) continue;
if(s[i][j]=='.')
{
if(mp.count({{x,y},{i,j}}))
{
if(mp[{{x,y},{i,j}}]==2)
now++;
else return;
}
else
{
dfs(x,y,i,j);
if(mp[{{x,y},{i,j}}]==2) now++;
else return;
}
}
}
}
++ans;
}
void solve()
{
ans=0;
mp.clear();
cin>>n>>m;
for(int i=1;i<=n;++i)
{
for(int j=1;j<=m;++j)
{
cin>>s[i][j];
}
}
for(int i=1;i<=n;++i)
{
for(int j=1;j<=m;++j)
{
if(s[i][j]=='.') work(i,j);
}
}
cout<<ans<<endl;
}
int main()
{
ios::sync_with_stdio(0),cin.tie(0);
int _;cin>>_;
while(_--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3732kb
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: 3ms
memory: 3708kb
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 6 7 3 4 0 4 2 2 0 1 6 3 5 2 0 0 4 3 3 1 2 1 0 6 2 2 2 6 2 0 6 2 2 2 0 3 6 3 3 2 2 2 4 2 1 0 3 3 3 4 2 2 0 6 6 2 6 4 3 2 5 2 1 2 1 2 0 0 2 3 1 3 4 6 1 6 2 2 3 4 4 2 1 0 1 6 3 4 11 0 2 2 1 0 0 2 2 1 4 2 7 3 0 3 5 2 4 1 2 3 2 0 2 10 2 2 4 0 2 4 4 2 1 2 2 0 4 0 14 4 3 2 5 0 7 2 3 1...
result:
wrong answer 12th lines differ - expected: '7', found: '6'