Submission #217750

# Submission time Handle Problem Language Result Execution time Memory
217750 2020-03-30T15:38:20 Z TheLorax Hamburg Steak (JOI20_hamburg) C++11
15 / 100
1404 ms 70264 KB
#include <bits/stdc++.h>

//#pragma GCC optimize ("O3")
//#pragma GCC optimize ("Ofast")

#define F first
#define S second
#define MT make_tuple
#define MP make_pair
#define SZ(a) ((int)(a).size())
#define PB push_back
#define LBS 20
#define MOD ((long long)1e9+7) //1e9+9
#define LEFT(i) (2*(i))
#define RIGHT(i) (2*(i)+1)
#define PAR(i) ((i)/2)
#define ALL(a) (a).begin(), (a).end()
#define END(s) {cout << s;return;}

using namespace std;

typedef long long ll;
typedef double rat;
typedef long long bi;
typedef pair<ll, ll> ii;
typedef std::vector<ii> vii;
typedef std::map<ll, ll> mii;
typedef bitset<LBS> bis;
typedef std::vector<bis> vbs;
typedef priority_queue<ii, std::vector<ii>, greater<ii> > minpq;
typedef priority_queue<ii, std::vector<ii>, less<ii> > maxpq;
typedef priority_queue<ii> pq;
struct ham{
  ll l, d, r, u;
};

template<class T>
void in(T &a){
  for(auto &x: a)
    cin >> x;
}

template<class T>
void out(T &a, string sep=" "){
  for(auto x: a)
    cout << x<<sep;
  cout << '\n';
}

template<class T>
void err(T &a, string sep=" "){
  for(auto x: a)
    cerr << x <<sep;
  cerr << '\n';
}

std::vector<ham> h;
std::vector<int> ma;
std::vector<ii> ou;
int n, k;

void end(){
  for(auto &x: ou)
    cout << x.F<<" "<<x.S<<"\n";
  exit(0);
}

template<class T>
void pop(T &pq){
  while (!pq.empty() && ma[pq.top().S])
    pq.pop();
  if(pq.empty())
    end();
}

void rek(minpq pqxi, maxpq pqxa, minpq pqyi, maxpq pqya, int idx=0){
  pop(pqxi);
  pop(pqxa);
  pop(pqyi);
  pop(pqya);
  if(idx==k)
    return;
  ll xmi=pqxi.top().F;
  ll xma=pqxa.top().F;
  ll ymi=pqyi.top().F;
  ll yma=pqya.top().F;
  for(auto &c: {MP(xmi,ymi),MP(xmi,yma),MP(xma,ymi),MP(xma,yma)}){
    ou[idx]=c;
    for(int i=0; i<n; i++)
      if(h[i].l<=c.F && c.F<=h[i].r && h[i].d<=c.S && c.S<=h[i].u)
        ma[i]++;
    rek(pqxi, pqxa, pqyi, pqya, idx+1);
    for(int i=0; i<n; i++)
      if(h[i].l<=c.F && c.F<=h[i].r && h[i].d<=c.S && c.S<=h[i].u)
        ma[i]--;
  }
  if(idx==0 && k==4){
    ii vxa={0,1000000000}, vxi={0,1000000000}, vya={0,1000000000}, vyi={0,1000000000};
    for(int i=0; i<n; i++){
      if(h[i].l<=xma){
        vxa.F=max(vxa.F,h[i].d);
        vxa.S=min(vxa.S,h[i].u);
      } else if(h[i].r>=xmi){
        vxi.F=max(vxi.F,h[i].d);
        vxi.S=min(vxi.S,h[i].u);
      } else if(h[i].d<=yma){
        vya.F=max(vya.F,h[i].l);
        vya.S=min(vya.S,h[i].r);
      } else if(h[i].l<=ymi){
        vyi.F=max(vyi.F,h[i].l);
        vyi.S=min(vyi.S,h[i].r);
      }
    }
    if(vxa.F>vxa.S || vxi.F>vxi.S || vya.F>vya.S || vyi.F>vyi.S){
      for(unsigned int i=1; i<0; i++)
        i++;
    }
    ou[0]=MP(xma,vxa.F);
    ou[1]=MP(xmi,vxi.F);
    ou[2]=MP(yma,vya.F);
    ou[3]=MP(ymi,vyi.F);
    end();
  }
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  minpq pqxi, pqyi;
  maxpq pqxa, pqya;
  h.resize(n);
  ou.resize(k);
  ma.resize(n,0);
  for(int i=0; i<n; i++){
    cin >> h[i].l>>h[i].d>>h[i].r>>h[i].u;
    pqxi.emplace(h[i].r,i);
    pqxa.emplace(h[i].l,i);
    pqyi.emplace(h[i].u,i);
    pqya.emplace(h[i].d,i);
  }
  rek(pqxi, pqxa, pqyi, pqya);
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 768 KB Output is correct
2 Correct 2 ms 768 KB Output is correct
3 Correct 2 ms 768 KB Output is correct
4 Correct 3 ms 768 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 896 KB Output is correct
2 Correct 3 ms 900 KB Output is correct
3 Correct 2 ms 896 KB Output is correct
4 Correct 3 ms 912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1024 KB Output is correct
2 Correct 2 ms 1024 KB Output is correct
3 Correct 2 ms 1024 KB Output is correct
4 Correct 2 ms 1024 KB Output is correct
5 Correct 2 ms 1024 KB Output is correct
6 Correct 3 ms 1024 KB Output is correct
7 Correct 2 ms 1024 KB Output is correct
8 Correct 3 ms 1048 KB Output is correct
9 Correct 7 ms 1112 KB Output is correct
10 Correct 6 ms 1100 KB Output is correct
11 Correct 3 ms 1036 KB Output is correct
12 Correct 4 ms 1064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1152 KB Output is correct
2 Correct 3 ms 1152 KB Output is correct
3 Correct 2 ms 1160 KB Output is correct
4 Correct 3 ms 1152 KB Output is correct
5 Correct 2 ms 1152 KB Output is correct
6 Correct 2 ms 1152 KB Output is correct
7 Correct 3 ms 1152 KB Output is correct
8 Correct 4 ms 1152 KB Output is correct
9 Correct 7 ms 1204 KB Output is correct
10 Correct 5 ms 1200 KB Output is correct
11 Correct 4 ms 1184 KB Output is correct
12 Correct 3 ms 1164 KB Output is correct
13 Correct 22 ms 1184 KB Output is correct
14 Incorrect 24 ms 1240 KB Integer parameter [name=y_2] equals to 0, violates the range [1, 10^9]
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 768 KB Output is correct
2 Correct 2 ms 768 KB Output is correct
3 Correct 2 ms 768 KB Output is correct
4 Correct 3 ms 768 KB Output is correct
5 Correct 181 ms 45060 KB Output is correct
6 Correct 199 ms 45176 KB Output is correct
7 Correct 203 ms 45196 KB Output is correct
8 Correct 194 ms 45216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 896 KB Output is correct
2 Correct 3 ms 900 KB Output is correct
3 Correct 2 ms 896 KB Output is correct
4 Correct 3 ms 912 KB Output is correct
5 Correct 212 ms 54812 KB Output is correct
6 Correct 284 ms 57628 KB Output is correct
7 Correct 235 ms 56092 KB Output is correct
8 Correct 341 ms 57688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1024 KB Output is correct
2 Correct 2 ms 1024 KB Output is correct
3 Correct 2 ms 1024 KB Output is correct
4 Correct 2 ms 1024 KB Output is correct
5 Correct 2 ms 1024 KB Output is correct
6 Correct 3 ms 1024 KB Output is correct
7 Correct 2 ms 1024 KB Output is correct
8 Correct 3 ms 1048 KB Output is correct
9 Correct 7 ms 1112 KB Output is correct
10 Correct 6 ms 1100 KB Output is correct
11 Correct 3 ms 1036 KB Output is correct
12 Correct 4 ms 1064 KB Output is correct
13 Correct 216 ms 67612 KB Output is correct
14 Correct 245 ms 67736 KB Output is correct
15 Correct 235 ms 67356 KB Output is correct
16 Correct 222 ms 68632 KB Output is correct
17 Correct 203 ms 67996 KB Output is correct
18 Correct 237 ms 69020 KB Output is correct
19 Correct 260 ms 66076 KB Output is correct
20 Correct 337 ms 69684 KB Output is correct
21 Correct 1404 ms 70256 KB Output is correct
22 Correct 833 ms 70216 KB Output is correct
23 Correct 556 ms 70264 KB Output is correct
24 Correct 678 ms 70156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1152 KB Output is correct
2 Correct 3 ms 1152 KB Output is correct
3 Correct 2 ms 1160 KB Output is correct
4 Correct 3 ms 1152 KB Output is correct
5 Correct 2 ms 1152 KB Output is correct
6 Correct 2 ms 1152 KB Output is correct
7 Correct 3 ms 1152 KB Output is correct
8 Correct 4 ms 1152 KB Output is correct
9 Correct 7 ms 1204 KB Output is correct
10 Correct 5 ms 1200 KB Output is correct
11 Correct 4 ms 1184 KB Output is correct
12 Correct 3 ms 1164 KB Output is correct
13 Correct 22 ms 1184 KB Output is correct
14 Incorrect 24 ms 1240 KB Integer parameter [name=y_2] equals to 0, violates the range [1, 10^9]
15 Halted 0 ms 0 KB -