QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#54664#4190. Grid DeliveryAs3b_team_f_masr#WA 2ms3680kbC++1.2kb2022-10-10 02:54:472022-10-10 02:54:48

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-10 02:54:48]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:3680kb
  • [2022-10-10 02:54:47]
  • 提交

answer

#include <bits/stdc++.h>

typedef long double ld;
typedef long long ll;
using namespace std;
int di[] = {1, 0, -1, -1, 0, 1, -1, 1};
int dj[] = {1, 1, 0, -1, -1, 0, 1, -1};
const ll oo = 1e18, MOD = 998244353;
const int N = 2005, M = 350;
const ld PI = acos(-1.0), EPS = 1e-9;

int n, m, tot;
vector<int> s[N];

//#define endl '\n'
int main() {
    //ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //freopen("farm.in", "r", stdin);
    //memset(dp, -1, sizeof dp);
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            char c;
            cin >> c;
            if (c == 'C') s[i].push_back(j), tot++;
        }
    }
    int ans = 0;
    while (tot) {
        ans++;
        int x, y;
        for (int i = 1; i <= n; i++) {
            if (!s[i].empty()) {
                x = i, y = s[i].back();
                break;
            }
        }
        for (int i = x; i <= n; i++) {
            int prey = y;
            if (!s[i].empty() && s[i].back() >= y) {
                y = s[i].back();
                while (!s[i].empty() && s[i].back() >= prey) s[i].pop_back(), tot--;
            }
        }
    }
    cout << ans;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3600kb

input:

4 4
__C_
C_C_
_C_C
_CCC

output:

2

result:

ok single line: '2'

Test #2:

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

input:

4 6
CC____
_CCC__
___C_C
C__CCC

output:

2

result:

ok single line: '2'

Test #3:

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

input:

3 5
CC__C
_C_CC
CCCCC

output:

3

result:

ok single line: '3'

Test #4:

score: -100
Wrong Answer
time: 2ms
memory: 3680kb

input:

4 4
__C_
CCCC
___C
_C_C

output:

3

result:

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