QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#640875#6259. Gluttonous Goopchanuuu#AC ✓1ms3908kbC++171.6kb2024-10-14 16:38:232024-10-14 16:38:25

Judging History

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

  • [2024-10-14 16:38:25]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3908kb
  • [2024-10-14 16:38:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

char mp[202][202];
const int dx[] = {-1,-1,-1,0,0,1,1,1}, dy[] = {-1,0,1,-1,1,-1,0,1};

struct st{
    int x, y, d;
};

int main(){
    cin.tie(nullptr)->sync_with_stdio(0);
    int n,m,k, c = 0;
    cin >> n >> m >> k;
    queue<st> q;
    memset(mp, '.', sizeof mp);
    for (int i = 81; i <= n+80; i++){
        for (int j = 81; j <= m+80; j++){
            cin >> mp[i][j];
            if (mp[i][j] == '#'){
                c++;
                q.push({j,i,0});
            }
        }
    }
    if (!c){
        cout << 0;
        return 0;
    }
    int bef = 0, aa = c;
    vector<int> diff;
    while (q.size() and q.front().d < 50){
        int x,y,d;
        x = q.front().x;
        y = q.front().y;
        d = q.front().d;
        q.pop();
        if (d != bef){
            diff.push_back(c - aa);
            // cout << aa << ' ' << c << ' ' << diff.back() << endl;
            bef = d;
            aa = c;
        }
        if (d == k){
            cout << c;
            return 0;
        }
        for (int i = 0; i < 8; i++){
            int nx = x + dx[i], ny = y + dy[i];
            if (mp[ny][nx] != '#'){
                mp[ny][nx] = '#';
                c++;
                q.push({nx, ny, d+1});
            }
        }
    }
    // cout << c << endl;
    // if (k == 50) {
    //     cout << c;
    //     return 0;
    // }
    ll cha = diff.back() - diff[diff.size()-2];
    // cout << c - aa << ' ' << cha <<endl;
    // assert(c - aa -  == cha)?;
    ll ccc = k - 50;
    cout << c + (c-aa)*ccc + (ccc+1)*ccc/2 * cha;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3608kb

input:

5 5 3
.....
.###.
.#.#.
.###.
.....

output:

81

result:

ok single line: '81'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

3 3 1
#..
.#.
..#

output:

19

result:

ok single line: '19'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3608kb

input:

4 6 3
..##..
.#..#.
.#..#.
..##..

output:

96

result:

ok single line: '96'

Test #4:

score: 0
Accepted
time: 1ms
memory: 3552kb

input:

1 1 1000000
#

output:

4000004000001

result:

ok single line: '4000004000001'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3608kb

input:

2 2 91011
.#
.#

output:

33132554552

result:

ok single line: '33132554552'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3676kb

input:

20 20 1000000
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
####################
#############...

output:

4000080000400

result:

ok single line: '4000080000400'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3908kb

input:

20 20 630238
....................
....................
....................
....................
....................
....................
....................
....................
#...................
....................
....................
....................
....................
.................

output:

1588840081630

result:

ok single line: '1588840081630'

Test #8:

score: 0
Accepted
time: 1ms
memory: 3836kb

input:

20 20 630238
#...................
.#..................
..#.................
...#................
....#...............
.....#..............
......#.............
.......#............
........#...........
.........#..........
..........#.........
...........#........
............#.......
.............#...

output:

1588850165636

result:

ok single line: '1588850165636'

Test #9:

score: 0
Accepted
time: 1ms
memory: 3668kb

input:

20 20 1000000
.........##.........
........####........
.......######.......
......########......
.....##########.....
....############....
...##############...
..################..
.##################.
####################
####################
.##################.
..################..
...##########...

output:

4000080000220

result:

ok single line: '4000080000220'

Test #10:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

5 5 1000000
.....
.....
.....
.....
.....

output:

0

result:

ok single line: '0'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

5 5 1
.....
.....
.....
.....
.....

output:

0

result:

ok single line: '0'

Test #12:

score: 0
Accepted
time: 1ms
memory: 3608kb

input:

20 20 93002
####################
#..................#
#..................#
#..................#
#..................#
#..................#
#..................#
#..................#
#..................#
#..................#
#..................#
#..................#
#..................#
#.................

output:

34604928576

result:

ok single line: '34604928576'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

20 20 3
####################
#..................#
#..................#
#..................#
#..................#
#..................#
#..................#
#..................#
#..................#
#..................#
#..................#
#..................#
#..................#
#.....................

output:

532

result:

ok single line: '532'

Test #14:

score: 0
Accepted
time: 1ms
memory: 3644kb

input:

10 12 173312
...#....##..
....#.#.....
............
##.#..#.....
...#...#..#.
#..##.....#.
#.##.#..#...
....#....#.#
.#.#..#.....
............

output:

120155476561

result:

ok single line: '120155476561'

Test #15:

score: 0
Accepted
time: 1ms
memory: 3640kb

input:

16 1 12123
.
.
#
.
.
.
#
.
.
.
.
.
.
.
.
.

output:

588013997

result:

ok single line: '588013997'

Test #16:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

20 11 78669
........#..
#..........
##...#.....
.##........
...........
.....#....#
....#......
#.##.......
.##...#.#..
...........
###.#......
...#...#...
.#.........
...........
..........#
.........##
..#...#....
....#.....#
##.........
....###.#..

output:

24760123916

result:

ok single line: '24760123916'

Test #17:

score: 0
Accepted
time: 0ms
memory: 3568kb

input:

3 20 935833
..#.#.....#...#.....
........#...........
.......#............

output:

3503163562228

result:

ok single line: '3503163562228'

Test #18:

score: 0
Accepted
time: 1ms
memory: 3892kb

input:

19 7 528014
.......
.....#.
#.#..#.
......#
.##...#
..#..#.
#..#...
.......
.#....#
.....#.
#......
#......
......#
..#....
...#.#.
.#..##.
....#.#
###..#.
...#...

output:

1115221537596

result:

ok single line: '1115221537596'

Test #19:

score: 0
Accepted
time: 1ms
memory: 3900kb

input:

15 15 139652
.............#.
...............
...............
...............
............#..
...............
.....#.........
.#........#...#
..#............
..##...........
...............
.#.............
.#.............
....#..........
...............

output:

78018544980

result:

ok single line: '78018544980'

Test #20:

score: 0
Accepted
time: 0ms
memory: 3612kb

input:

19 16 10
.#..............
.........#......
...#............
................
....#...#....#.#
.............#..
....#.........#.
.........#......
................
.....#..........
#..............#
......#.......#.
.......#........
........#....#..
.#......#.#.#...
#.........#.....
...#..........#.
.....

output:

1337

result:

ok single line: '1337'

Test #21:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

8 19 2
....#...........#..
....#.....##.......
.............#.....
#........###.......
............#......
........#.....#..#.
..#.....#..........
...................

output:

195

result:

ok single line: '195'

Test #22:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

15 1 1
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

output:

0

result:

ok single line: '0'

Test #23:

score: 0
Accepted
time: 0ms
memory: 3660kb

input:

18 9 1
.........
......#..
........#
.........
......#..
#........
...#.....
.#...#.##
......#..
........#
..#....#.
.........
.......#.
#........
.#......#
.........
.........
.........

output:

111

result:

ok single line: '111'

Test #24:

score: 0
Accepted
time: 0ms
memory: 3664kb

input:

19 13 4
.........#...
........#....
..........###
.......##...#
.........#...
.............
.............
..#..........
.............
.............
.............
.......#.....
.............
..#...#......
.............
.............
.....##......
.............
....#........

output:

374

result:

ok single line: '374'

Test #25:

score: 0
Accepted
time: 1ms
memory: 3864kb

input:

1 1 1000000
#

output:

4000004000001

result:

ok single line: '4000004000001'

Test #26:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

1 1 329048
.

output:

0

result:

ok single line: '0'

Test #27:

score: 0
Accepted
time: 1ms
memory: 3556kb

input:

20 20 12890
#..................#
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
..................

output:

665639639

result:

ok single line: '665639639'

Test #28:

score: 0
Accepted
time: 1ms
memory: 3608kb

input:

2 2 3901
.#
##

output:

60902415

result:

ok single line: '60902415'

Test #29:

score: 0
Accepted
time: 1ms
memory: 3676kb

input:

20 20 630238
#...................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.................

output:

1588850165294

result:

ok single line: '1588850165294'

Test #30:

score: 0
Accepted
time: 1ms
memory: 3608kb

input:

20 20 630238
#..................#
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.................

output:

1588826216592

result:

ok single line: '1588826216592'

Test #31:

score: 0
Accepted
time: 1ms
memory: 3648kb

input:

20 20 630238
...................#
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
....................
.................

output:

1588850165294

result:

ok single line: '1588850165294'

Test #32:

score: 0
Accepted
time: 0ms
memory: 3892kb

input:

8 8 2
........
........
.....#..
...##...
...#....
........
........
........

output:

44

result:

ok single line: '44'

Test #33:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

20 20 0
####################
##.#################
#########..###.#####
#########.#####.####
##.######.#.##.#####
######.##.##.#######
#############.######
######.#######.#####
##########.###..####
#####.##.#####.#####
#############.######
#####.###.##.#######
####################
##.##.####.....####...

output:

357

result:

ok single line: '357'