Submission #587350

# Submission time Handle Problem Language Result Execution time Memory
587350 2022-07-01T16:56:59 Z Omar_Elgedawy Quality Of Living (IOI10_quality) C++14
0 / 100
2 ms 340 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//#include "grader.cpp"
#include "quality.h"
using namespace std;
#define cin(vec)        for(auto& i : vec) cin >> i
#define cout(vec)       for(auto& i : vec) cout << i << " "; cout << "\n";
#define fast            ios::sync_with_stdio(0);cin.tie(0);
#define loop(i,a,b)     for (int i = a; i < b; i++)
#define F               first
#define S               second
#define pb(n)           push_back(n)
#define pf(n)           push_front(n)
#define dci(d)          fixed<<setprecision(d)
#define sp              ' '
#define el              '\n'
#define all(v)          v.begin(),v.end()
#define f               find_by_order
int rectangle(int n, int m, int r, int c, int a[3001][3001]) {
    ordered_set s;
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            s.insert(a[i][j]);
        }
    }
    int ans=*(s.f(s.size()/2));
    int op=1;
    for(int i=0;i<n-r;i++){
        if(op){
            for(int j=0;j<m-c;j++){
                for(int k=i;k<r+i;k++){
    //                cout<<k<<' '<<j+c<<el;
                    s.insert(a[k][j+c]);
                }
                for(int k=i;k<r+i;k++){
    //                cout<<k<<' '<<j<<el;
                    s.erase(a[k][j]);
                }
//                cout(s);
                ans=min(ans,*s.f(s.size()/2));
            }
            for(int j=m-c;j<m;j++){
                s.erase(a[i][j]);
            }
            for(int j=m-c;j<m;j++){
                s.erase(a[i+r][j]);
            }
        }
        else{
            for(int j=m-1;j>=c;j--){
                for(int k=i;k<r+i;k++){
//                    cout<<k<<' '<<j<<el;
                    s.erase(a[k][j]);
                }
                for(int k=i;k<r+i;k++){
    //                cout<<k<<' '<<j+c<<el;
                    s.insert(a[k][j-c]);
                }
//                cout(s);
                ans=min(ans,*s.f(s.size()/2));
            }
            for(int j=0;j<c;j++){
                s.erase(a[i][j]);
            }
            for(int j=0;j<c;j++){
                s.erase(a[i+r][j]);
            }
        }
        op^=1;
    }
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -