Submission #1021463

# Submission time Handle Problem Language Result Execution time Memory
1021463 2024-07-12T18:33:05 Z vjudge1 Rectangles (IOI19_rect) C++17
0 / 100
129 ms 31448 KB
#include "rect.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector <ll>;
using vi = vector <int>;

const ll MAXN = 2.5E3+16;
bool vis[MAXN][MAXN];

ll count_rectangles (vector <vi> a) {
    ll n = a.size(), m = a[0].size();
    ll ans = 0;
    for (ll i = 1; i < n-1; i++) {
        for (ll j = 1; j < m-1; j++) {
            if (vis[i][j] || a[i][j] == 1) continue;
            ll minI = i, maxI = i;
            ll minJ = j, maxJ = j;
            queue <ll> q;
            ll cou = 0;
            q.push(i);
            q.push(j);
            while (q.size()) {
                ll i = q.front(); q.pop();
                ll j = q.front(); q.pop();
                if (a[i][j] == 1) continue;
                if (vis[i][j]) continue;
                vis[i][j] = true; cou++;
                minI = min(minI, i); maxI = max(maxI, i); minJ = min(minJ, j); maxJ = max(maxJ, j);
                if (i-1 >= 0) { q.push(i-1); q.push(j); }
                if (j-1 >= 0) { q.push(i); q.push(j-1); }
                if (i+1 < n) { q.push(i+1); q.push(j); }
                if (j+1 < m) { q.push(i); q.push(j+1); }
            }
            if (0 < maxI && maxI < n-1 && 0 < minJ && maxJ < m-1)
                ans += (cou == (maxI-minI+1)*(maxJ-minJ+1));
        }
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 129 ms 31448 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -