QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#456832 | #7733. Cool, It’s Yesterday Four Times More | JinTianHao | WA | 0ms | 5828kb | C++17 | 1.7kb | 2024-06-28 14:59:58 | 2024-06-28 14:59:58 |
Judging History
answer
#include <bits/stdc++.h>
#define inf 1000000007
#define mod 1000000007
// #define int long long
// #pragma GCC optimize("Ofast","inline","-ffast-math")
// #pragma GCC target("avx,sse2,sse3,sse4,mmx")
using namespace std;
template <typename T> void read(T &x){
x=0;char ch=getchar();int fh=1;
while (ch<'0'||ch>'9'){if (ch=='-')fh=-1;ch=getchar();}
while (ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
x*=fh;
}
template <typename T> void write(T x) {
if (x<0) x=-x,putchar('-');
if (x>9) write(x/10);
putchar(x%10+'0');
}
template <typename T> void writeln(T x) {
write(x);
puts("");
}
const int dx[]={-1,0,1,0},dy[]={0,-1,0,1};
int n,m;
char mp[1005][1010];
int mem[1005][1005];
bool vis[1005][1005];
bool dfs(int x,int y,int u,int v)
{
if(u<1||u>n||v<1||v>m) return 1;
if(mp[u][v]=='O') return 1;
int &r=mem[(x-1)*m+y][(u-1)*m+v];
if(~r) return r;
vis[x][y]=1;
for(int d=0;d<4;++d)
{
int xx=x+dx[d],yy=y+dy[d],uu=u+dx[d],vv=v+dy[d];
if(xx<1||xx>n||yy<1||yy>m||mp[xx][yy]=='O'||vis[xx][yy]) continue;
if(dfs(xx,yy,uu,vv)) return vis[x][y]=0,r=1;
}
vis[x][y]=0;
return r=0;
}
signed main()
{
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
int tc;read(tc);
while(tc--)
{
read(n);read(m);
for(int i=1;i<=n;++i)
scanf("%s",mp[i]+1);
for(int i=1;i<=n*m;++i)
for(int j=1;j<=n*m;++j)
mem[i][j]=-1;
int ans=0;
for(int i=1;i<=n;++i)
for(int j=1;j<=m;++j)
if(mp[i][j]=='.')
{
bool flag=1;
for(int u=1;u<=n&&flag;++u)
for(int v=1;v<=m&&flag;++v)
if(mp[u][v]=='.'&&(i!=u||j!=v))
if(!dfs(i,j,u,v)) flag=0;
if(flag) ++ans;
}
writeln(ans);
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 5828kb
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: 5804kb
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 7 9 4 4 0 4 5 2 0 1 6 3 4 2 0 0 5 3 3 1 4 1 0 7 5 2 3 7 3 0 6 2 2 2 0 4 6 6 3 3 2 3 5 2 1 0 3 3 4 4 2 2 0 7 5 4 7 5 3 2 4 2 1 2 1 4 0 0 2 5 1 3 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 3 3 8 3 0 3 5 2 5 1 3 3 4 0 2 11 2 2 4 0 4 4 5 2 1 2 3 0 5 0 14 3 3 2 5 0 8 3 3 1...
result:
wrong answer 17th lines differ - expected: '6', found: '4'