QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#640673#6259. Gluttonous Goopdohoon#WA 4ms7796kbC++171.6kb2024-10-14 15:09:502024-10-14 15:09:50

Judging History

This is the latest submission verdict.

  • [2024-10-14 15:09:50]
  • Judged
  • Verdict: WA
  • Time: 4ms
  • Memory: 7796kb
  • [2024-10-14 15:09:50]
  • Submitted

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MXN = 2000;
using pii = pair<int,int>;
char A[MXN][MXN];
signed main() {
    cin.tie(0)->sync_with_stdio(0);
    int n, m, k; cin >> n >> m >> k;
    vector<pii> Q;
    for(int i=0;i<2000-1;i++){
        for(int j=0;j<2000-1;j++) A[i][j] = '.';
    }
    for(int i=1000;i<1000+n;i++){
        for(int j=1000;j<1000+m;j++){
            cin >> A[i][j];
            if(A[i][j]=='#')
            Q.push_back({i,j});
        }
    }
    for(int d=0;d<min(k,100LL);d++){
        vector<pii> nq;
        for(auto &[x,y] : Q) {
            for(int dx=-1;dx<2;dx++) for(int dy=-1;dy<2;dy++){
                int ax = x+dx, ay = y+dy;
                if(A[ax][ay]=='.') {
                    A[ax][ay] = '#';
                    nq.push_back({ax,ay});
                }
            }
        }
        swap(Q,nq);
    }
    k = max(0LL,k-100);
    int ans = 0;
    for(int i=0;i<2000;i++) for(int j=0;j<2000;j++)
        ans += (A[i][j]=='#');
    if(k) {
        int x=-1, y=-1;
        for(int i=0;i<2000;i++) {
            for(int j=0;j<2000;j++) if(A[i][j]=='#'){
                x=i,y=j;
                break;
            }
            if(x!=-1) break;
        }
        if(x==-1 && y==-1) {
            cout << 0;
            return 0;
        }
        int ex = x, ey = y;
        while(A[ex][y]=='#') ex++;
        while(A[x][ey]=='#') ey++;
        int lx = ex-x, ly = ey-y;
        lx += 2*k, ly += 2*k;
        
        cout << lx*ly;
    }
    else {
        cout << ans;
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

81

result:

ok single line: '81'

Test #2:

score: 0
Accepted
time: 2ms
memory: 7536kb

input:

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

output:

19

result:

ok single line: '19'

Test #3:

score: 0
Accepted
time: 2ms
memory: 7548kb

input:

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

output:

96

result:

ok single line: '96'

Test #4:

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

input:

1 1 1000000
#

output:

4000004000001

result:

ok single line: '4000004000001'

Test #5:

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

input:

2 2 91011
.#
.#

output:

33132554552

result:

ok single line: '33132554552'

Test #6:

score: 0
Accepted
time: 3ms
memory: 7528kb

input:

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

output:

4000080000400

result:

ok single line: '4000080000400'

Test #7:

score: -100
Wrong Answer
time: 4ms
memory: 7796kb

input:

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

output:

1588802267529

result:

wrong answer 1st lines differ - expected: '1588840081630', found: '1588802267529'