제출 #234678

#제출 시각아이디문제언어결과실행 시간메모리
234678AlexLuchianov함박 스테이크 (JOI20_hamburg)C++14
21 / 100
3052 ms13128 KiB
#include <iostream>
#include <vector>
#include <cmath>
#include <cassert>
#include <random>
#include <algorithm>
#include <chrono>

using namespace std;

using ll = long long;
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) < (b)) ? (b) : (a))

int const nmax = 200000;
int const inf = 1000000000;

int const sigma = 4;

class Rect{
public:
  int x;
  int y;
  int x2;
  int y2;
  Rect operator + (Rect a) {
    return {max(x, a.x), max(y, a.y), min(x2, a.x2), min(y2, a.y2)};
  }
  bool valid(){
    return (x <= x2) && (y <= y2);
  }
  ll area(){
    return 1LL * (x2 - x + 1) * (y2 - y + 1);
  }
} v[1 + nmax];

int main()
{
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

  ios::sync_with_stdio(0);
  cin.tie(0);

  int n, k;
  cin >> n >> k;
  vector<Rect> basic, high;
  for(int i = 1;i <= n; i++) {
    cin >> v[i].x >> v[i].y >> v[i].x2 >> v[i].y2;
    basic.push_back(v[i]);
  }

  Rect base[1 + sigma];

  while(true){
    vector<Rect> ord;
    ord.insert(ord.end(), high.begin(), high.end());
    ord.insert(ord.end(), basic.begin(), basic.end());
    high.clear();
    basic.clear();

    for(int j = 1;j <= k; j++)
      base[j] = {1, 1, inf, inf};

    for(int i = 0; i < ord.size(); i++){
      Rect &curr = ord[i];
      bool found = 0;
      for(int j = 1;j <= k; j++){
        Rect newp = curr + base[j];
        if(newp.valid()) {
          found = 1;
          base[j] = base[j] + curr;
          basic.push_back(curr);
          break;
        }
      }
      if(found == 0)
        high.push_back(curr);
    }

    if(0 == high.size()){
      for(int j = 1;j <= k; j++)
        cout << base[j].x << " " << base[j].y << '\n';
      return 0;
    }
    shuffle(basic.begin(), basic.end(), rng);
  }
  return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

hamburg.cpp: In function 'int main()':
hamburg.cpp:64:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<Rect>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |     for(int i = 0; i < ord.size(); i++){
      |                    ~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...