QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#57978#3892. Efficiently ElevatedBeevo#AC ✓73ms18648kbC++231.8kb2022-10-24 01:25:212022-10-24 01:25:23

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-24 01:25:23]
  • 评测
  • 测评结果:AC
  • 用时:73ms
  • 内存:18648kb
  • [2022-10-24 01:25:21]
  • 提交

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;

int h, w;
int dx[] = {0, 0, -1, 1};
int dy[] = {-1, 1, 0, 0};

bool valid(int x, int y) {
    return x >= 0 && x < h && y >= 0 && y < w;
}

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

    int g[h][w];
    map<int, vector<pair<int, int>>, greater<>> lvl;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> g[i][j];

            if (g[i][j] > 1)
                lvl[g[i][j]].emplace_back(i, j);
        }
    }

    bool b[h][w];
    memset(b, 0, sizeof b);

    int sol = 0;
    for (auto i: lvl) {
        priority_queue<pair<int, pair<int, int>>> pq;

        for (auto j: i.second) {
            int x = j.first, y = j.second;

            pq.push({b[x][y], {x, y}});

            for (int k = 0; k < 4; k++) {
                int newX = x + dx[k], newY = y + dy[k];

                if (valid(newX, newY) && g[newX][newY] < i.first)
                    b[newX][newY] = 1;
            }
        }

        while (pq.size()) {
            int x = pq.top().second.first;
            int y = pq.top().second.second;

            pq.pop();

            if (!b[x][y])
                sol++, b[x][y] = 1;

            for (int k = 0; k < 4; k++) {
                int newX = x + dx[k], newY = y + dy[k];

                if (valid(newX, newY) && g[newX][newY] == i.first && !b[newX][newY]) {
                    b[newX][newY] = 1;

                    pq.push({1, {newX, newY}});
                }
            }
        }
    }

    cout << sol;
}

signed main() {
    Beevo

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

    while (T--)
        testCase();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3 3
1 2 3
0 0 4
7 6 5

output:

1

result:

ok single line: '1'

Test #2:

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

input:

6 7
0 0 0 0 0 0 0
0 1 2 3 2 1 0
0 1 2 3 2 1 0
0 0 0 0 0 0 0
0 1 0 5 0 0 0
0 0 0 0 0 0 0

output:

2

result:

ok single line: '2'

Test #3:

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

input:

4 4
1 1 2 1
2 2 1 2
1 2 2 1
2 1 2 2

output:

4

result:

ok single line: '4'

Test #4:

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

input:

50 25
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 5 0 0 0 0 10 10 0 10 10 0 10 11 0 10 10 0 0 0 0 0 0
0 0 0 4 0 0 0 0 10 0 0 0 10 0 10 0 0 0 11 0 0 0 0 0 0
0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
5 4 3 0 3 4 5 0 10 0 0 0 10 0 11 0 0 0 10 0 0 0 0 0 0
0 0 0 3 0 0 0 0 10 10 0 10 1...

output:

28

result:

ok single line: '28'

Test #5:

score: 0
Accepted
time: 66ms
memory: 10520kb

input:

500 500
999999999 1000000000 999999999 1000000000 999999999 1000000000 999999999 1000000000 999999999 1000000000 999999999 1000000000 999999999 1000000000 999999999 1000000000 999999999 1000000000 999999999 1000000000 999999999 1000000000 999999999 1000000000 999999999 1000000000 999999999 100000000...

output:

125000

result:

ok single line: '125000'

Test #6:

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

input:

15 15
0 2 0 2 0 2 0 2 0 2 0 2 0 2 0
2 0 2 0 2 0 2 0 2 0 2 0 2 0 2
0 2 0 2 0 2 0 2 0 2 0 2 0 2 0
2 0 2 0 2 0 2 0 2 0 2 0 2 0 2
0 2 0 2 0 2 0 2 0 2 0 2 0 2 0
2 0 2 0 2 0 2 0 2 0 2 0 2 0 2
0 2 0 2 0 2 0 2 0 2 0 2 0 2 0
2 0 2 0 2 0 2 0 2 0 2 0 2 0 2
0 2 0 2 0 2 0 2 0 2 0 2 0 2 0
2 0 2 0 2 0 2 0 2 0 2 0 ...

output:

112

result:

ok single line: '112'

Test #7:

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

input:

500 1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

output:

0

result:

ok single line: '0'

Test #8:

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

input:

1 500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

0

result:

ok single line: '0'

Test #9:

score: 0
Accepted
time: 6ms
memory: 4772kb

input:

500 500
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

0

result:

ok single line: '0'

Test #10:

score: 0
Accepted
time: 11ms
memory: 4772kb

input:

500 500
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

0

result:

ok single line: '0'

Test #11:

score: 0
Accepted
time: 73ms
memory: 13908kb

input:

500 500
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 100000...

output:

1

result:

ok single line: '1'

Test #12:

score: 0
Accepted
time: 65ms
memory: 12924kb

input:

500 500
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 ...

output:

1

result:

ok single line: '1'

Test #13:

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

input:

1 1
0

output:

0

result:

ok single line: '0'

Test #14:

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

input:

1 1
1

output:

0

result:

ok single line: '0'

Test #15:

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

input:

1 1
1000000000

output:

1

result:

ok single line: '1'

Test #16:

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

input:

10 9
0 0 1 0 2 0 1 0 0
0 0 1 0 2 0 1 0 0
1 1 1 0 2 1 1 1 1
0 0 0 0 2 0 0 0 0
2 2 2 2 2 0 0 0 0
0 0 0 0 3 0 0 0 0
3 4 0 0 3 0 0 0 0
4 3 0 0 3 3 3 3 3
0 0 0 0 0 0 3 0 0
0 0 0 0 0 0 3 0 0

output:

3

result:

ok single line: '3'

Test #17:

score: 0
Accepted
time: 43ms
memory: 11552kb

input:

203 347
916879845 937252694 391022453 89978003 634030332 101731698 199528945 450823909 524744922 774250323 39638192 517746918 830485529 452142636 741348119 555845267 107263418 722556774 795717747 567823766 825040544 169255395 517070719 223142167 923428116 423752899 166792882 158836574 927142878 8235...

output:

14176

result:

ok single line: '14176'

Test #18:

score: 0
Accepted
time: 41ms
memory: 11620kb

input:

205 340
726076542 181100235 920613657 864898375 676032496 496171094 482877205 939574823 762838372 416503168 606104252 378710090 238226335 461877359 942229157 14897166 304137670 506161531 49688420 917414359 506105765 605549799 909318331 964271911 995466513 743286187 446279959 435239713 615755979 9233...

output:

14016

result:

ok single line: '14016'

Test #19:

score: 0
Accepted
time: 35ms
memory: 12156kb

input:

297 255
253839767 967646098 397602969 942498651 529467712 953789754 864204377 754263600 444320 897881492 461791799 74498526 143334763 567761007 182366942 396881807 262116243 983155946 293871931 791570192 386677171 895578474 113311052 352249745 41054946 135884283 724596375 160820600 133021189 2772287...

output:

15142

result:

ok single line: '15142'

Test #20:

score: 0
Accepted
time: 51ms
memory: 11804kb

input:

231 312
520126674 157702860 923320499 660326482 668521669 580244095 951168333 498603330 735803102 430822254 669831190 474558460 906248258 198177524 163812924 101684810 896945102 765867146 856937335 987948886 922866560 998783457 145564692 721026445 820933487 167212611 450519836 19979372 664762039 714...

output:

14428

result:

ok single line: '14428'

Test #21:

score: 0
Accepted
time: 5ms
memory: 5064kb

input:

500 500
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

3

result:

ok single line: '3'

Test #22:

score: 0
Accepted
time: 10ms
memory: 4920kb

input:

500 500
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

3

result:

ok single line: '3'

Test #23:

score: 0
Accepted
time: 17ms
memory: 5044kb

input:

500 500
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

3

result:

ok single line: '3'

Test #24:

score: 0
Accepted
time: 13ms
memory: 5076kb

input:

500 500
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

3

result:

ok single line: '3'

Test #25:

score: 0
Accepted
time: 23ms
memory: 5116kb

input:

500 500
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

2

result:

ok single line: '2'

Test #26:

score: 0
Accepted
time: 22ms
memory: 5152kb

input:

500 500
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

5

result:

ok single line: '5'

Test #27:

score: 0
Accepted
time: 55ms
memory: 7000kb

input:

500 500
6 6 0 4 8 7 6 4 7 5 9 3 8 2 4 2 1 9 4 8 9 2 4 1 1 10 5 7 8 1 5 6 5 9 10 3 8 7 7 8 4 0 8 0 1 6 10 10 0 9 7 5 3 5 1 3 9 3 3 2 8 7 1 1 5 8 7 1 4 8 4 1 8 5 8 3 9 8 9 4 7 1 9 6 5 9 3 4 2 3 2 0 9 10 4 7 1 1 10 2 2 0 1 8 10 6 8 4 8 3 3 10 9 6 9 4 7 7 10 10 5 1 5 9 1 7 9 10 5 3 3 0 4 1 3 5 2 5 6 0 1...

output:

45595

result:

ok single line: '45595'

Test #28:

score: 0
Accepted
time: 56ms
memory: 7092kb

input:

500 500
2 9 1 4 1 7 7 7 10 6 3 1 7 0 6 6 9 0 7 4 3 9 1 5 0 0 0 10 8 0 6 10 3 6 0 8 3 7 7 8 3 5 3 10 3 7 4 0 6 8 10 1 2 10 4 1 5 8 6 8 10 3 4 4 9 7 8 6 9 0 7 3 6 6 10 2 5 8 10 5 1 7 10 8 1 2 8 6 5 7 0 7 0 4 9 9 9 6 10 2 2 8 3 0 3 8 8 3 6 8 5 9 5 7 4 10 8 9 0 6 8 2 8 8 3 6 0 7 5 9 8 3 8 6 7 5 6 5 0 8 ...

output:

45263

result:

ok single line: '45263'

Test #29:

score: 0
Accepted
time: 33ms
memory: 7952kb

input:

500 500
1 1 0 1 2 1 1 1 1 1 2 0 2 0 1 0 0 2 1 2 2 2 0 1 0 2 0 2 1 1 2 0 1 1 1 2 2 0 2 1 1 2 1 0 2 0 0 2 1 2 2 2 0 2 1 1 0 2 1 2 0 0 2 0 0 0 2 1 0 0 1 2 1 0 1 2 1 2 0 2 1 2 0 2 2 2 1 1 0 2 1 1 2 0 1 0 0 0 0 2 2 1 1 0 0 2 0 0 0 0 2 2 2 1 2 2 1 2 0 0 2 2 1 2 1 1 1 2 2 2 1 0 1 2 0 1 2 2 1 0 0 0 2 1 0 2 ...

output:

31316

result:

ok single line: '31316'

Test #30:

score: 0
Accepted
time: 41ms
memory: 7928kb

input:

500 500
0 2 0 1 0 1 1 1 2 1 0 0 1 0 1 1 2 0 2 1 1 2 0 2 0 1 0 0 0 2 2 0 1 2 0 1 2 0 2 0 1 1 2 0 1 0 2 0 1 1 0 1 2 2 0 0 2 2 1 0 2 1 2 2 2 1 2 2 0 1 1 2 1 2 1 2 0 1 0 2 1 1 2 0 1 2 2 2 2 1 0 1 2 2 0 0 2 1 1 1 2 0 1 0 1 2 2 2 2 1 2 0 0 2 0 0 0 2 2 0 1 2 1 2 1 1 1 2 2 2 2 0 1 2 2 0 2 2 0 1 0 1 1 2 2 0 ...

output:

30852

result:

ok single line: '30852'

Test #31:

score: 0
Accepted
time: 44ms
memory: 7612kb

input:

500 500
3 3 0 2 3 3 2 3 2 1 1 2 1 0 2 1 2 0 0 2 3 0 2 3 2 1 3 3 2 0 0 0 3 0 3 2 1 2 0 1 1 1 1 3 0 0 2 3 0 2 2 0 2 1 2 3 0 3 2 1 2 1 1 1 0 2 3 0 0 1 1 0 0 3 2 1 1 3 2 3 3 2 0 2 0 3 2 1 1 0 2 0 1 2 1 2 3 0 0 1 1 0 0 0 0 1 0 3 0 2 0 0 0 1 1 0 3 1 0 0 3 0 2 0 1 0 2 2 3 1 0 3 0 0 3 1 2 2 3 1 1 0 1 1 2 2 ...

output:

36989

result:

ok single line: '36989'

Test #32:

score: 0
Accepted
time: 40ms
memory: 7480kb

input:

500 500
3 3 0 2 4 3 3 2 3 2 4 1 4 1 2 1 0 4 2 4 4 1 2 0 0 2 3 4 0 2 3 2 4 1 4 3 3 4 2 0 4 0 0 3 0 4 3 2 1 2 0 1 4 1 1 1 4 3 0 0 2 4 3 0 2 4 2 0 4 2 4 1 4 4 4 2 3 0 4 3 2 4 1 2 1 1 1 0 4 2 3 0 0 1 1 0 0 4 3 4 2 4 1 1 4 3 4 2 3 3 2 0 2 4 0 3 4 2 1 1 0 2 0 1 2 1 2 3 0 0 1 1 0 4 4 4 0 0 0 1 4 4 0 3 0 2 ...

output:

39825

result:

ok single line: '39825'

Test #33:

score: 0
Accepted
time: 66ms
memory: 18648kb

input:

500 500
1 0 1995 1994 1993 1992 1991 1990 1989 1988 1987 1986 1985 1984 1983 1982 1981 1980 1979 1978 1977 1976 1975 1974 1973 1972 1971 1970 1969 1968 1967 1966 1965 1964 1963 1962 1961 1960 1959 1958 1957 1956 1955 1954 1953 1952 1951 1950 1949 1948 1947 1946 1945 1944 1943 1942 1941 1940 1939 193...

output:

1

result:

ok single line: '1'

Test #34:

score: 0
Accepted
time: 6ms
memory: 4612kb

input:

35 500
1 0 1065 1064 1063 1062 1061 1060 1059 1058 1057 1056 1055 1054 1053 1052 1051 1050 1049 1048 1047 1046 1045 1044 1043 1042 1041 1040 1039 1038 1037 1036 1035 1034 1033 1032 1031 1030 1029 1028 1027 1026 1025 1024 1023 1022 1021 1020 1019 1018 1017 1016 1015 1014 1013 1012 1011 1010 1009 1008...

output:

1

result:

ok single line: '1'

Test #35:

score: 0
Accepted
time: 45ms
memory: 8708kb

input:

500 500
7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 ...

output:

1

result:

ok single line: '1'

Test #36:

score: 0
Accepted
time: 41ms
memory: 8788kb

input:

500 500
7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 7 7 7 0 ...

output:

1

result:

ok single line: '1'