QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#527562 | #7733. Cool, It’s Yesterday Four Times More | Stelor | WA | 3ms | 3628kb | C++20 | 1.6kb | 2024-08-22 17:01:11 | 2024-08-22 17:01:12 |
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];
// cout<<nx<<" "<<ny<<" "<<ni<<" "<<nj<<endl;
if(fail(nx,ny)) continue;
if(fail(ni,nj))
{
mp[{{x,y},{i,j}}]=2;
mp[{{nx,ny},{ni,nj}}]=2;
continue;
}
// cout<<nx<<" "<<ny<<" "<<ni<<" "<<nj<<endl;
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;
}
}
}
}
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
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: 3616kb
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 2 0 0 1 0 5 7 3 4 0 3 2 2 0 1 6 2 4 2 0 0 4 3 3 1 2 1 0 5 2 2 2 4 2 0 5 2 2 2 0 3 6 3 3 2 2 2 4 2 1 0 3 3 3 3 2 2 0 6 5 2 5 4 3 2 3 2 1 2 1 2 0 0 2 3 1 2 4 6 1 4 2 2 2 4 3 2 1 0 1 5 3 3 10 0 2 2 1 0 0 2 2 1 3 2 6 3 0 3 4 2 4 1 2 3 2 0 2 9 2 2 3 0 2 4 3 2 1 2 2 0 3 0 13 3 3 2 4 0 7 2 3 1 ...
result:
wrong answer 7th lines differ - expected: '3', found: '2'