Submission #1267173

#TimeUsernameProblemLanguageResultExecution timeMemory
1267173ngunguoi45Bob (COCI14_bob)C11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int maxn = (int)1e3+5;
int n, m;
int a[maxn][maxn];

namespace sub1 {
    ll ans = 0;
    int prv = -1;
    bool check () {
        return (n <= 50 && m <= 50);
    }
    void solve () {
        for (int top = 1; top <= n; top++) {
            for (int bot = top; bot <= n; bot++) {
                for (int lft = 1; lft <= m; lft++) {
                    prv = -1;
                    for (int rht = lft; rht <= m; rht++) {
                        bool ok = 1;
                        for (int s = top; s <= bot; s++) {
                            if (a[s][rht] != prv && prv != -1) {
                                ok = 0;
                                break;
                            }
                            else if (prv == -1) {
                                prv = a[s][rht];
                            }
                        }
                        ans += ok;
                        if (!ok) break;
                    }
                }
            }
        }
        cout << ans << "\n";
    }
}

namespace sub2 {
    ll ans = 0;
    bitset<505> valid[505][505];
    bool check () {
        return (n <= 500 && m <= 500);
    }
    void solve () {
        for (int col = 1; col <= m; col++) {
            for (int top = 1; top <= n; top++) {
                valid[col][top][top] = 1;
                for (int bot = top+1; bot <= n; bot++) {
                    if (a[bot][col] != a[bot-1][col]) break;
                    valid[col][top][bot] = 1;
                }
            }
        }
        for (int top = 1; top <= n; top++) {
            for (int bot = top; bot <= n; bot++) {
                ll tmp = 0;
                for (int rht = 1; rht <= m; rht++) {
                    if (!valid[rht][top][bot]) {
                        tmp = 0;
                    }
                    else if (valid[rht][top][bot] && rht > 1 && a[bot][rht] != a[bot][rht-1]) {
                        tmp = 1;
                        ans += tmp;
                    }
                    else {
                        tmp++;
                        ans += tmp;
                    }
                }
            }
        }
        cout << ans << "\n";
    }
}

namespace sub3 {
    void solve () {
        cout << "Chua nghi ra\n";
    }
}

void read_and_prep() {
    cin >> n >> m;
    for (int i = 1;i <= n; i++) {
        for (int j = 1;j <= m; j++) cin >> a[i][j];
    }
}

int main () {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    read_and_prep();
    if (sub1::check()) sub1::solve();
    else if (sub2::check()) sub2::solve();
    else sub3::solve();
    return 0;
}

Compilation message (stderr)

bob.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.