QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#54661#4190. Grid DeliveryAs3b_team_f_masr#TL 864ms96424kbC++1.2kb2022-10-10 02:46:542022-10-10 02:46:55

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:46:55]
  • 评测
  • 测评结果:TL
  • 用时:864ms
  • 内存:96424kb
  • [2022-10-10 02:46:54]
  • 提交

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;
set<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].insert(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].begin();
                break;
            }
        }
        for (int i = x; i <= n; i++) {
            auto it = s[i].lower_bound(y);
            while (it != s[i].end()) {
                y = *it;
                tot--;
                s[i].erase(it);
                it = s[i].lower_bound(y);
            }
        }
    }
    cout << ans;
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 4
__C_
C_C_
_C_C
_CCC

output:

2

result:

ok single line: '2'

Test #2:

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

input:

4 6
CC____
_CCC__
___C_C
C__CCC

output:

2

result:

ok single line: '2'

Test #3:

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

input:

3 5
CC__C
_C_CC
CCCCC

output:

3

result:

ok single line: '3'

Test #4:

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

input:

4 4
__C_
CCCC
___C
_C_C

output:

2

result:

ok single line: '2'

Test #5:

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

input:

1 1
_

output:

0

result:

ok single line: '0'

Test #6:

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

input:

1 1
C

output:

1

result:

ok single line: '1'

Test #7:

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

input:

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

output:

0

result:

ok single line: '0'

Test #8:

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

input:

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

output:

3

result:

ok single line: '3'

Test #9:

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

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:

7

result:

ok single line: '7'

Test #10:

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

input:

10 10
CCCCCCCCCC
CCC_CC__CC
CCCCCC_CCC
_CCCCCC_CC
CCCCCCCCCC
C__CCCCCCC
CCCCCCCC_C
C_CCCCCCCC
_CCCCCCCCC
CCCCCCCCCC

output:

10

result:

ok single line: '10'

Test #11:

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

input:

10 10
CCCCCCCCCC
CCCCCCCCCC
CCCCCCCCCC
CCCCCCCCCC
CCCCCCCCC_
CCCCCCCCCC
CCCCCCCCCC
CCCCCCCCCC
CCCCCCCCCC
CCCCCCCCCC

output:

10

result:

ok single line: '10'

Test #12:

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

input:

100 100
____________________________________________________________________________________________________
____________________________________________________________________________________________________
__________________________________________________________________________________________...

output:

0

result:

ok single line: '0'

Test #13:

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

input:

100 100
__C_____________________C__________________C____C____________________________C______________________
______________C__________C__C_C____C___CC___C_C_C__________C_____C____C____C________________CC____C_
____C____________C_____________C_____C_C_________C____________________C_______C___________...

output:

44

result:

ok single line: '44'

Test #14:

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

input:

100 100
C_C_CCCC_C_CCC__C_CC_CC_C____CCC__CCCC__CCC_C__CC_CC_CCC__C___CCC_CCCC_CCC_________CCCCCCC_CC____C_C
CC_C__CCC_CCC_CC_____CCC___C_CC____C_C__CC_C___C_CC___CCCC_C_C________C___C___CC_CC__CCC________C___
___C_C_CC___CCC_______C_C___CCC_C_____C__CC_____CC_____C__CCC_C__CC_C_C_C_CC_C__C__C__C_CC...

output:

81

result:

ok single line: '81'

Test #15:

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

input:

100 100
CCCCC_CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC__CCCCCCCCC_CCCCCCCCCC_CCC_CCC_CCCCCCCCCCCCCCC_CCC_CCCC_CCCCCC
CCCCCCCCCCCC_CCCCCCCCCCCCCCC_CCCCCCCCCCCC_CCCCCCCCCCCCCCCCCCCC__C__CCCCC_C__CCCCCCCC_CCC_CCCCCC_CCCC
CCCCCCCCCCCCCCCC_CCC_CCC_CCCCCCC_CCCCC_CCCCC_CCCCC__CCCCCCCCCCCCCCCCCCCCCCCCC_CCCC_CC_CCCC...

output:

95

result:

ok single line: '95'

Test #16:

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

input:

100 100
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC_CCCCCCCCCCCCCCCCCCC_CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC_CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC...

output:

100

result:

ok single line: '100'

Test #17:

score: 0
Accepted
time: 136ms
memory: 3536kb

input:

2000 2000
__________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________...

output:

0

result:

ok single line: '0'

Test #18:

score: 0
Accepted
time: 282ms
memory: 22256kb

input:

2000 2000
___________CC________C__________C___C________C______C____________________________C___________C____C______C_C__________CC___C________________________________C____C_______________C___C__________C_C_______C_______C____C_C________C__C______________________C________C________________C________C__...

output:

945

result:

ok single line: '945'

Test #19:

score: 0
Accepted
time: 864ms
memory: 96424kb

input:

2000 2000
C_CC_____C_C_C_CC__C_C_CC_CCCCC___CC_CCC_CC__C____CCCC__CCC_C_CCC__CC__CC___CCC____C____C__CCC___CC_CCC___CCC___CC_C_C__C_C_CC__CC_C__C___C_C_CC__CC_CC___CC_CCCC__CCCC_C________C_C_C_C__C_C__C_____C__C_CCCCCC_CCCCC_CC__CCC_CCC__C______C_C_C_CC__CC___C__CCC__CC__CC___C__C_CC_C_C__CC_CCCC__C...

output:

1641

result:

ok single line: '1641'

Test #20:

score: -100
Time Limit Exceeded

input:

2000 2000
CC_CCCCCCCCC_CCCCCCCCCC__C_CCCCCCCCCCCCCCC_CCCCCCCCC__C_CCCC_CCCC_CCCCCCC_CCC_CCCCCC_C_C__CCCC___CCCCCCCC_CCCC_CC__CCC_CCC_CC_C_CCCCC_CCCCCCCC__CCCCCCCCCC_CCCCCCCCCCCCCCCCCCCCCC_CCCCCCCCCCCCCCC_CCCCCCCCC_CCCC__CCCCCCC_CCCCCC__CCCCCCCCCC_CCCCCCCCCC_CCCCCCCCCCCCCCCCCC_CCC_CCCCCCCCCCC_CCCCCCC...

output:


result: