QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#689006#7733. Cool, It’s Yesterday Four Times Morei_love_qingyu#WA 2ms7784kbC++202.5kb2024-10-30 14:49:452024-10-30 14:49:46

Judging History

你现在查看的是最新测评结果

  • [2024-10-30 14:49:46]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:7784kb
  • [2024-10-30 14:49:45]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int a[1001][1001],book[1001][1001],n,m;
int tg[4][2]={0,1,1,0,0,-1,-1,0};
struct node{
    int l,r,w,d;
}b[1001][1001];
struct node dfs(int x,int y){
    struct node t,f;
    f.l=f.r=y;
    f.w=f.d=x;
    for(int i=0;i<4;i++){
        int x1=x+tg[i][0];
        int y1=y+tg[i][1];
        if(x1>0&&x1<=n&&y1>0&&y1<=m&&a[x1][y1]&&(book[x1][y1]==0)){
            book[x1][y1]=1;
            t=dfs(x1,y1);
            f.l=min(t.l,f.l);
            f.r=max(t.r,f.r);
            f.d=min(f.d,t.d);
            f.w=max(f.w,t.w);
        }
    }
    return f;
    
}
void dfs2(int x,int y,int X,int Y){
    b[x][y]=b[X][Y];
    for(int i=0;i<4;i++){
        int x1=x+tg[i][0];
        int y1=y+tg[i][1];
        if(x1>0&&x1<=n&&y1>0&&y1<=m&&a[x1][y1]&&book[x1][y1]){
            book[x1][y1]=0;
            dfs2(x1,y1,X,Y);
        }
    }
}
int main()
{
    int t;
    cin>>t;
    while(t--){
        int ans=0;
        char s;
        cin>>n>>m;
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++){
                cin>>s;
                if(s=='.')a[i][j]=1;
                else a[i][j]=0;
                book[i][j]=0;
            }
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
                if(!book[i][j]&&a[i][j]){
                    book[i][j]=1;
                    struct node f=dfs(i,j);
                    b[i][j].l=f.l;
                    b[i][j].r=f.r;
                    b[i][j].d=f.d;
                    b[i][j].w=f.w;
                }
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
                if(book[i][j]&&a[i][j]){
                    book[i][j]=0;
                    dfs2(i,j,i,j);
                }
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++){
                b[i][j].l=j-b[i][j].l;
                b[i][j].r-=j;
                b[i][j].d=i-b[i][j].d;
                b[i][j].w-=i;
            }
        for(int i=1;i<=n;i++)
            for(int j=1;j<=m;j++)
                if(a[i][j]){
                    int p=1;
                    for(int x=1;x<=n&&p;x++)
                        for(int y=1;y<=m&&p;y++)
                            if(!(x==i&&y==j))
                                if(b[x][y].l>=b[i][j].l&&b[x][y].r>=b[i][j].r&&b[x][y].d>=b[i][j].d&&b[x][y].w>=b[i][j].w)
                                    p=0;
                    if(p)ans++;
                }
        cout<<ans<<'\n';
    }
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 7784kb

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: 2ms
memory: 7680kb

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
2
3
1
4
1
0
4
5
2
3
7
2
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
6
4
8
5
3
2
5
2
1
2
1
4
0
0
2
5
0
4
6
6
1
6
0
2
3
4
5
1
1
0
1
9
2
4
11
0
3
2
1
0
0
4
3
1
4
3
8
3
0
3
6
2
5
1
3
3
4
0
2
11
2
0
4
0
4
4
6
2
1
2
3
0
5
0
16
2
3
1
6
0
8
1
3
1...

result:

wrong answer 12th lines differ - expected: '7', found: '4'