UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#195541#3419. 方格判定ChangeBox10095ms2400kbC++1.8kb2023-10-18 19:14:392023-10-18 22:19:34

answer

#include <bits/stdc++.h>

using namespace std;

vector<pair<int, int> > spaces;
const char conspace[10][10] = {"######", "##..##", "#....#", "#....#", "##..##", "######"};
char deplace[1010][1010];
bool visit[10100];
int n, m;

bool getspace(int pos_x, int pos_y)
{
    for(int i = 0; i < 6; i++){
        for(int j = 0; j < 6; j++)
        {
            if(deplace[i + pos_x][j + pos_y] != conspace[i][j])
            return false;
        }
    }
    return true;
}

inline int getpath(pair<int, int> pointa, pair<int, int> pointb)
{
    return abs(pointa.first - pointb.first) + abs(pointa.second - pointb.second);
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n>>m;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            cin>>deplace[i][j];
        }
    }
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            if(getspace(i, j))
            {
                spaces.push_back(pair<int, int>({i, j}));
            }
        }
    }
    int ctimes = 0, stimes = 0;
    const int Len = spaces.size();
    for(int i = 0; i < Len; i++){
        if(visit[i]) continue;
        bool is_c = false;
        for(int j = 0; j < Len; j++){
            if(visit[j] || i == j) continue;
            if(getpath(spaces[i], spaces[j]) == 7)
            {
                is_c = true;
                ctimes ++;
                visit[i] = true;
                visit[j] = true;
            }
        }
        if(!is_c)
        {
            stimes ++;
            visit[i] = true;
        }
    }
    cout<<ctimes<<" "<<stimes<<endl;
    // for(int i = 0; i < (int)spaces.size(); i++)
    // {
    //     cout<<spaces[i].first<<" "<<spaces[i].second<<endl;
    // }

    return 0;
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 0ms
memory: 1280kb

input:

17 17
......##########.
......##########.
......##########.
......####..####.
......###....###.
.......

output:

1 0

result:

ok single line: '1 0'

Test #2:

score: 10
Accepted
time: 0ms
memory: 1280kb

input:

17 17
...........###...
...........###...
...........###...
...........###...
....##########...
.......

output:

0 1

result:

ok single line: '0 1'

Test #3:

score: 10
Accepted
time: 0ms
memory: 1284kb

input:

17 17
.................
.................
.................
.................
.##############..
.###...

output:

0 1

result:

ok single line: '0 1'

Test #4:

score: 10
Accepted
time: 0ms
memory: 1312kb

input:

50 50
##########...................##############....###
##########...................##############...

output:

1 11

result:

ok single line: '1 11'

Test #5:

score: 10
Accepted
time: 0ms
memory: 1316kb

input:

50 50
......................###.........................
......................###.....................

output:

5 5

result:

ok single line: '5 5'

Test #6:

score: 10
Accepted
time: 0ms
memory: 1312kb

input:

50 50
......##########..................................
......##########.......####################...

output:

7 2

result:

ok single line: '7 2'

Test #7:

score: 10
Accepted
time: 65ms
memory: 2400kb

input:

1000 1000
##########..##########..##########..##########..##########..##########..##########..######...

output:

4316 0

result:

ok single line: '4316 0'

Test #8:

score: 10
Accepted
time: 12ms
memory: 2292kb

input:

1000 1000
.............................................................................................

output:

539 235

result:

ok single line: '539 235'

Test #9:

score: 10
Accepted
time: 7ms
memory: 2260kb

input:

1000 1000
.............................................................................................

output:

3 7

result:

ok single line: '3 7'

Test #10:

score: 10
Accepted
time: 11ms
memory: 2256kb

input:

1000 1000
.............................................................................................

output:

9 1

result:

ok single line: '9 1'

Extra Test:

score: 0
Extra Test Passed