QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#271106#7733. Cool, It’s Yesterday Four Times MoreThe_Owls#WA 1ms3496kbC++141.3kb2023-12-01 23:21:252023-12-01 23:21:26

Judging History

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

  • [2023-12-01 23:21:26]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3496kb
  • [2023-12-01 23:21:25]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long int
#define loop(i,o,n,step) for(auto i{o}; i < n; i += step)
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;

int n, m;
vector<vector<int>> grid;

void dfs(int i, int j, string &s, char c){
    if(i < 0 || i >= n || j < 0 || j >= m || grid[i][j] == 0)
        return;
    grid[i][j] = 0;
    s += c;
    dfs(i + 1, j, s, 'D');
    dfs(i - 1, j, s, 'U');
    dfs(i, j + 1, s, 'R');
    dfs(i, j + 1, s, 'L');
}

void solve(){
    cin >> n >> m;
    grid.clear();
    grid.assign(n, vector<int>(m, 0));
    loop(i,0,n,1){
        string s;
        cin >> s;
        loop(j,0,m,1){
            grid[i][j] = (s[j] == '.');
        }
    }
    map<string, int> mp;
    loop(i,0,n,1) loop(j,0,m,1){
        if(grid[i][j] == 0) continue;
        string s;
        dfs(i, j, s, 'X');
        string tmp;
        loop(c,0,s.size(),1){
            tmp += s[c];
            mp[tmp]++;
        }

    }
    ll ans{0};
    for(auto i: mp)
        if(i.second == 1){
            ans += i.first.size();
            // cout << i.first << "\n";
        }
    cout << ans << "\n";
}

int main(){
    FAST
    int t;
    cin >> t;
    while(t--){
        solve();
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 1ms
memory: 3424kb

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:

2
0
0
3
1
1
7
0
0
1
0
6
45
9
5
0
3
15
2
0
1
14
7
11
3
0
0
14
5
6
1
10
1
0
6
15
3
6
29
6
0
21
2
2
2
0
10
14
21
0
7
2
7
7
2
1
0
2
6
5
10
2
2
0
25
14
10
15
9
5
3
14
2
1
3
1
10
0
0
3
15
1
7
21
12
1
20
3
2
5
9
9
3
1
0
1
45
5
9
66
0
5
3
1
0
0
10
6
1
0
6
16
5
0
5
6
3
7
1
6
5
10
0
2
66
3
2
9
0
10
4
8
3
1
3
...

result:

wrong answer 1st lines differ - expected: '3', found: '2'