Submission #1021442

# Submission time Handle Problem Language Result Execution time Memory
1021442 2024-07-12T18:19:08 Z vjudge1 Rectangles (IOI19_rect) C++17
13 / 100
268 ms 135252 KB
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target("popcnt")
#define endl '\n'
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fo(i,n) for(auto i =0 ; i < n;i++)
#define fore(i,l,r) for(auto i = l; i < r;i++)
#define forex(i,r,l) for(auto i = r; i >= l; i--)
#define ffo(i,n) forex(i,n-1,0)
#define all(x) x.begin(),x.end()
#define lsb(x) x&(-x)
#define sz(x) (int)x.size()
#define gcd(a,b) __gcd(a,b)
#define vii vector<ii>
#define pq_min(a) priority_queue<a, vector<a>, greater<a>>
#define fls cout.flush()
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using ii = pair<int,int>;
using mii = map<int,int>;
using lld = long double;
void valid(ll in){cout<<((in)?"YES\n":"NO\n");}
const int N = 2505;
int pf[N][N], jump[N][N],jump2[N][N];
int query(int r1, int c1, int r2, int c2){
    assert(min({r1,c1,r2,c2})>0);
    return pf[r2][c2] - pf[r1-1][c2] - pf[r2][c1-1] + pf[r1-1][c1-1];
}
ll count_rectangles(vector<vi> a){
    ll ans = 0;
    int n = sz(a), m= sz(a[0]);
    // cout << n << " " << m << endl; fls;
    fore(i,1,n+1) 
        fore(j,1,m+1)
            pf[i][j] = a[i-1][j-1] + pf[i-1][j] + pf[i][j-1] - pf[i-1][j-1];
    // cout << "DIE" << endl; fls;
    fore(i,1,n+1)
        forex(j,m,1){
            if(a[i-1][j-1])jump[i][j]=j;
            else jump[i][j] = jump[i][j+1];
        }
    // cout << "DIE" << endl; fls;
    fore(j,1,m+1)
        forex(i,n,1){
            if(a[i-1][j-1])jump2[i][j]=i;
            else jump2[i][j]=jump2[i+1][j];
        }
    // cout << "DIE" << endl; fls;
    fore(r1,2,n)
        fore(c1,2,m){
            if(a[r1-1][c1-1])continue;
            // cout << r1 << " " << c1 << endl; fls;
            int c2 = jump[r1][c1]-1;
            int r2 = jump2[r1][c1]-1;
            if(r2<r1||c2<c1)continue;
            if(c2>=m||r2>=n)continue;
            if(query(r1,c1,r2,c2)==0&&query(r1-1,c1,r1-1,c2)==c2-c1+1&&query(r2+1,c1,r2+1,c2)==c2-c1+1&&query(r1,c1-1,r2,c1-1)==r2-r1+1&&query(r1,c2+1,r2,c2+1)==r2-r1+1)
                ans++;
        }
    fo(i,n+2)
        fo(j,m+2)
            pf[i][j]=jump[i][j]=jump2[i][j]=0;
    return ans;
}

Compilation message

rect.cpp:4: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    4 | #pragma GCC optimization ("O3")
      | 
rect.cpp:5: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    5 | #pragma GCC optimization ("unroll-loops")
      |
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 600 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 119 ms 64772 KB Output is correct
3 Correct 262 ms 134480 KB Output is correct
4 Correct 268 ms 135112 KB Output is correct
5 Correct 262 ms 135252 KB Output is correct
6 Correct 82 ms 66972 KB Output is correct
7 Correct 171 ms 131508 KB Output is correct
8 Correct 172 ms 135188 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 860 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -