QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#54610#4190. Grid DeliveryUsername#WA 4ms5728kbC++231.3kb2022-10-09 20:41:352022-10-09 20:41:36

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-09 20:41:36]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:5728kb
  • [2022-10-09 20:41:35]
  • 提交

answer

#include <bits/stdc++.h>

#define el '\n'
#define ll long long
#define ld long double

#define Beevo ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int N = 2e3 + 5;

int cnt;
int h, w;
char g[N][N];
int cntRow[N];
bool vis[N][N];

void solve() {
    for (int i = 0, j = 0; i < h; i++) {
        bool enter = 0;

        while (j < w && !vis[i][j])
            vis[i][j] = 1, cnt -= (g[i][j] == 'C'), cntRow[i] -= (g[i][j] == 'C'), j++, enter = 1;

        if (!cntRow[i]) {
            for (int k = 0; k < w && !vis[i][k]; k++)
                vis[i][k] = 1;
        }

        if (enter)
            j--;
    }
}

void testCase() {
    cin >> h >> w;

    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++)
            cin >> g[i][j], cnt += (g[i][j] == 'C'), cntRow[i] += (g[i][j] == 'C');
    }

    for (int i = 0; i < h; i++) {
        for (int j = w - 1; j >= 0; j--) {
            if (g[i][j] == 'C')
                break;

            vis[i][j] = 1;
        }
    }

    int sol = 0;
    while (cnt)
        solve(), sol++;

    cout << sol;
}

signed main() {
    Beevo

    int T = 1;
//    cin >> T;

    while (T--)
        testCase();

    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 5520kb

input:

4 4
__C_
C_C_
_C_C
_CCC

output:

2

result:

ok single line: '2'

Test #2:

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

input:

4 6
CC____
_CCC__
___C_C
C__CCC

output:

2

result:

ok single line: '2'

Test #3:

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

input:

3 5
CC__C
_C_CC
CCCCC

output:

3

result:

ok single line: '3'

Test #4:

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

input:

4 4
__C_
CCCC
___C
_C_C

output:

2

result:

ok single line: '2'

Test #5:

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

input:

1 1
_

output:

0

result:

ok single line: '0'

Test #6:

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

input:

1 1
C

output:

1

result:

ok single line: '1'

Test #7:

score: 0
Accepted
time: 4ms
memory: 5696kb

input:

10 10
__________
__________
__________
__________
__________
__________
__________
__________
__________
__________

output:

0

result:

ok single line: '0'

Test #8:

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

input:

10 10
_________C
_________C
_C__C_____
__________
____C_____
_________C
_______C__
__________
______C___
_______C__

output:

3

result:

ok single line: '3'

Test #9:

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

input:

10 10
C_C__C____
___C__C_CC
_CCC___C__
__C_CCC__C
__C_____CC
_CCCCC_CCC
C_C_CC_CCC
____C_C___
CC____CCCC
C___C___C_

output:

8

result:

wrong answer 1st lines differ - expected: '7', found: '8'