Submission #250841

# Submission time Handle Problem Language Result Execution time Memory
250841 2020-07-19T09:27:58 Z NONAME Raspad (COI17_raspad) C++14
9 / 100
6000 ms 6088 KB
#include <bits/stdc++.h>
#define dbg(x) cerr << #x << " = " << x << "\n"
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie()
using namespace std;
using ll = long long;

int n, m;
char c[int(1e5) + 10][100];
bool mk[int(1e5) + 10][100];

int f(int l, int r) {
    int res = 0;
    queue <pair <int, int> > q;

    for (int i = l; i <= r; ++i)
    for (int j = 0; j < m; ++j)
        mk[i][j] = (c[i][j] == '0');

    for (int i = l; i <= r; ++i)
    for (int j = 0; j < m; ++j) {
        if (mk[i][j])
            continue;

        ++res;
        q.push(make_pair(i, j));
        while (!q.empty()) {
            int x = q.front().first, y = q.front().second;
            q.pop();

            for (int xx = -1; xx < 2; ++xx)
            for (int yy = -1; yy < 2; ++yy)
                if ((!xx || !yy) && (xx != yy)) {
                    int cx = x + xx;
                    int cy = y + yy;

                    if (cx >= l && cx <= r && cy >= 0 && cy < m && !mk[cx][cy]) {
                        mk[cx][cy] = 1;
                        q.push(make_pair(cx, cy));
                    }
                }
        }
    }

    return res;
}

int main() {
    fast_io;

    cin >> n >> m;
    for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
        cin >> c[i][j];

    int ans = 0;
    for (int i = 0; i < n; ++i)
    for (int j = i; j < n; ++j)
        ans += f(i, j);

    cout << ans << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 241 ms 384 KB Output is correct
3 Correct 144 ms 416 KB Output is correct
4 Correct 155 ms 384 KB Output is correct
5 Correct 151 ms 384 KB Output is correct
6 Correct 202 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 241 ms 384 KB Output is correct
3 Correct 144 ms 416 KB Output is correct
4 Correct 155 ms 384 KB Output is correct
5 Correct 151 ms 384 KB Output is correct
6 Correct 202 ms 504 KB Output is correct
7 Execution timed out 6076 ms 572 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 6050 ms 6088 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 6 ms 384 KB Output is correct
2 Correct 241 ms 384 KB Output is correct
3 Correct 144 ms 416 KB Output is correct
4 Correct 155 ms 384 KB Output is correct
5 Correct 151 ms 384 KB Output is correct
6 Correct 202 ms 504 KB Output is correct
7 Execution timed out 6076 ms 572 KB Time limit exceeded
8 Halted 0 ms 0 KB -