結果

問題 No.1121 Social Distancing in Cinema
ユーザー Shun_PIShun_PI
提出日時 2020-07-22 22:38:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 7,027 bytes
コンパイル時間 2,988 ms
コンパイル使用メモリ 190,080 KB
実行使用メモリ 15,624 KB
最終ジャッジ日時 2023-09-05 02:36:48
合計ジャッジ時間 7,978 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
15,548 KB
testcase_01 AC 11 ms
15,540 KB
testcase_02 AC 11 ms
15,400 KB
testcase_03 AC 11 ms
15,340 KB
testcase_04 AC 11 ms
15,464 KB
testcase_05 AC 11 ms
15,336 KB
testcase_06 AC 11 ms
15,324 KB
testcase_07 AC 11 ms
15,384 KB
testcase_08 AC 11 ms
15,352 KB
testcase_09 AC 11 ms
15,412 KB
testcase_10 AC 11 ms
15,388 KB
testcase_11 AC 12 ms
15,336 KB
testcase_12 AC 12 ms
15,320 KB
testcase_13 AC 11 ms
15,548 KB
testcase_14 AC 12 ms
15,388 KB
testcase_15 AC 12 ms
15,416 KB
testcase_16 AC 15 ms
15,364 KB
testcase_17 AC 26 ms
15,420 KB
testcase_18 AC 38 ms
15,372 KB
testcase_19 AC 44 ms
15,376 KB
testcase_20 AC 12 ms
15,340 KB
testcase_21 AC 12 ms
15,524 KB
testcase_22 AC 12 ms
15,624 KB
testcase_23 AC 12 ms
15,548 KB
testcase_24 AC 12 ms
15,552 KB
testcase_25 AC 21 ms
15,428 KB
testcase_26 AC 23 ms
15,372 KB
testcase_27 AC 12 ms
15,348 KB
testcase_28 AC 41 ms
15,424 KB
testcase_29 AC 22 ms
15,436 KB
testcase_30 AC 19 ms
15,364 KB
testcase_31 AC 44 ms
15,576 KB
testcase_32 AC 36 ms
15,440 KB
testcase_33 AC 21 ms
15,352 KB
testcase_34 AC 22 ms
15,352 KB
testcase_35 AC 37 ms
15,432 KB
testcase_36 AC 42 ms
15,444 KB
testcase_37 AC 19 ms
15,484 KB
testcase_38 AC 24 ms
15,376 KB
testcase_39 AC 39 ms
15,432 KB
testcase_40 AC 18 ms
15,424 KB
testcase_41 AC 13 ms
15,344 KB
testcase_42 AC 43 ms
15,552 KB
testcase_43 AC 42 ms
15,444 KB
testcase_44 AC 44 ms
15,588 KB
testcase_45 AC 41 ms
15,444 KB
testcase_46 WA -
testcase_47 AC 12 ms
15,536 KB
testcase_48 AC 11 ms
15,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<int, int>;
using PL = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {cout << (expr ? "Yes" : "No") << "\n";}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N;
  cin >> N;
  //N = 250000;
  int K = (N-1) / 90 + 1;
  vector<vector<int>> b(500, vector<int>(500));
  REP(i, N) {
    int X, Y;
    cin >> X >> Y;
    //X = i/500 + 1; Y = i%500 + 1;
    b[X-1][Y-1] = i+1;
  }
  vector<vector<int>> b2(b);
  vector<vector<int>> b3(b);
  vector<vector<int>> b4(b);
  vector<vector<int>> b5(b);
  vector<vector<int>> b6(b);
  vector<vector<int>> b7(b);
  vector<vector<int>> b8(b);
  vector<vector<int>> b9(b);
  vector<vector<int>> b10(b);
  vector<vector<int>> b11(b);
  vector<vector<int>> b12(b);

  vector<int> ans;
  vector<int> delsize = {10, 10, 10, 10, 10, 9, 8, 8, 6, 5};

  REP(i, 500) REP(j, 500) {
    if(b[i][j] > 0) {
      ans.push_back(b[i][j]);
      REP(k, 10) REP(l, delsize[k]) if(i+k < 500 && j+l < 500) b[i+k][j+l] = 0;
      REP(k, 10) REP(l, delsize[k]) if(i+k < 500 && j-l >= 0) b[i+k][j-l] = 0;
    }
  }

  //cout << K << "\n";
  if(ans.size() < K) {
    ans.clear();
    REP(j, 500) REP(i, 500) {
      if(b2[i][j] > 0) {
        ans.push_back(b2[i][j]);
        REP(k, 10) REP(l, delsize[k]) if(i+k < 500 && j+l < 500) b2[i+k][j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-k >= 0 && j+l < 500) b2[i-k][j+l] = 0;
      }
    }
  }

  if(ans.size() < K) {
    ans.clear();
    REP(i, 500) IREP(j, 500) {
      if(b7[i][j] > 0) {
        ans.push_back(b7[i][j]);
        REP(k, 10) REP(l, delsize[k]) if(i+k < 500 && j+l < 500) b7[i+k][j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i+k < 500 && j-l >= 0) b7[i+k][j-l] = 0;
      }
    }
  }

  if(ans.size() < K) {
    ans.clear();
    REP(j, 500) IREP(i, 500) {
      if(b8[i][j] > 0) {
        ans.push_back(b8[i][j]);
        REP(k, 10) REP(l, delsize[k]) if(i+k < 500 && j+l < 500) b8[i+k][j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-k >= 0 && j+l < 500) b8[i-k][j+l] = 0;
      }
    }
  }

  if(ans.size() < K) {
    ans.clear();
    REP(i, 1000) REP(j, 500) {
      if(i-j >= 500 || i-j < 0) continue;
      if(b3[i-j][j] > 0) {
        ans.push_back(b3[i-j][j]);
        REP(k, 10) REP(l, delsize[k]) if(i-j-k >= 0 && j+l < 500) b3[i-j-k][j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j-k >= 0 && j-l >= 0) b3[i-j-k][j-l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j+k < 500 && j+l < 500) b3[i-j+k][j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j+k < 500 && j-l >= 0) b3[i-j+k][j-l] = 0;
      }
    }
  }

  if(ans.size() < K) {
    ans.clear();
    REP(i, 1000) REP(j, 500) {
      if(i-j >= 500 || i-j < 0) continue;
      if(b4[i-j][500-j] > 0) {
        ans.push_back(b4[i-j][500-j]);
        REP(k, 10) REP(l, delsize[k]) if(i-j-k >= 0 && 500-j+l < 500) b4[i-j-k][500-j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j-k >= 0 && 500-j-l >= 0) b4[i-j-k][500-j-l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j+k < 500 && 500-j+l < 500) b4[i-j+k][500-j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j+k < 500 && 500-j-l >= 0) b4[i-j+k][500-j-l] = 0;
      }
    }
  }

  if(ans.size() < K) {
    ans.clear();
    IREP(i, 1000) REP(j, 500) {
      if(i-j >= 500 || i-j < 0) continue;
      if(b5[i-j][j] > 0) {
        ans.push_back(b5[i-j][j]);
        REP(k, 10) REP(l, delsize[k]) if(i-j-k >= 0 && j+l < 500) b5[i-j-k][j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j-k >= 0 && j-l >= 0) b5[i-j-k][j-l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j+k < 500 && j+l < 500) b5[i-j+k][j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j+k < 500 && j-l >= 0) b5[i-j+k][j-l] = 0;
      }
    }
  }

  if(ans.size() < K) {
    ans.clear();
    IREP(i, 1000) REP(j, 500) {
      if(i-j >= 500 || i-j < 0) continue;
      if(b6[i-j][500-j] > 0) {
        ans.push_back(b6[i-j][500-j]);
        REP(k, 10) REP(l, delsize[k]) if(i-j-k >= 0 && 500-j+l < 500) b6[i-j-k][500-j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j-k >= 0 && 500-j-l >= 0) b6[i-j-k][500-j-l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j+k < 500 && 500-j+l < 500) b6[i-j+k][500-j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j+k < 500 && 500-j-l >= 0) b6[i-j+k][500-j-l] = 0;
      }
    }
  }

  if(ans.size() < K) {
    ans.clear();
    REP(i, 1000) IREP(j, 500) {
      if(i-j >= 500 || i-j < 0) continue;
      if(b9[i-j][j] > 0) {
        ans.push_back(b9[i-j][j]);
        REP(k, 10) REP(l, delsize[k]) if(i-j-k >= 0 && j+l < 500) b9[i-j-k][j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j-k >= 0 && j-l >= 0) b9[i-j-k][j-l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j+k < 500 && j+l < 500) b9[i-j+k][j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j+k < 500 && j-l >= 0) b9[i-j+k][j-l] = 0;
      }
    }
  }

  if(ans.size() < K) {
    ans.clear();
    REP(i, 1000) IREP(j, 500) {
      if(i-j >= 500 || i-j < 0) continue;
      if(b10[i-j][500-j] > 0) {
        ans.push_back(b10[i-j][500-j]);
        REP(k, 10) REP(l, delsize[k]) if(i-j-k >= 0 && 500-j+l < 500) b10[i-j-k][500-j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j-k >= 0 && 500-j-l >= 0) b10[i-j-k][500-j-l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j+k < 500 && 500-j+l < 500) b10[i-j+k][500-j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j+k < 500 && 500-j-l >= 0) b10[i-j+k][500-j-l] = 0;
      }
    }
  }

  if(ans.size() < K) {
    ans.clear();
    IREP(i, 1000) IREP(j, 500) {
      if(i-j >= 500 || i-j < 0) continue;
      if(b11[i-j][j] > 0) {
        ans.push_back(b11[i-j][j]);
        REP(k, 10) REP(l, delsize[k]) if(i-j-k >= 0 && j+l < 500) b11[i-j-k][j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j-k >= 0 && j-l >= 0) b11[i-j-k][j-l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j+k < 500 && j+l < 500) b11[i-j+k][j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j+k < 500 && j-l >= 0) b11[i-j+k][j-l] = 0;
      }
    }
  }

  if(ans.size() < K) {
    ans.clear();
    IREP(i, 1000) IREP(j, 500) {
      if(i-j >= 500 || i-j < 0) continue;
      if(b12[i-j][500-j] > 0) {
        ans.push_back(b12[i-j][500-j]);
        REP(k, 10) REP(l, delsize[k]) if(i-j-k >= 0 && 500-j+l < 500) b12[i-j-k][500-j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j-k >= 0 && 500-j-l >= 0) b12[i-j-k][500-j-l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j+k < 500 && 500-j+l < 500) b12[i-j+k][500-j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-j+k < 500 && 500-j-l >= 0) b12[i-j+k][500-j-l] = 0;
      }
    }
  }

  cout << ans.size() << "\n";
  REP(i, ans.size()) cout << ans[i] << (i!=ans.size()-1 ? " " : "");
  cout << "\n";
}
0