結果

問題 No.1121 Social Distancing in Cinema
ユーザー Shun_PIShun_PI
提出日時 2020-07-22 22:13:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,297 bytes
コンパイル時間 1,974 ms
コンパイル使用メモリ 174,224 KB
実行使用メモリ 7,620 KB
最終ジャッジ日時 2023-09-04 21:07:07
合計ジャッジ時間 6,618 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,612 KB
testcase_01 AC 5 ms
7,392 KB
testcase_02 AC 5 ms
7,376 KB
testcase_03 AC 5 ms
7,344 KB
testcase_04 AC 5 ms
7,396 KB
testcase_05 AC 5 ms
7,364 KB
testcase_06 AC 5 ms
7,336 KB
testcase_07 AC 5 ms
7,376 KB
testcase_08 AC 5 ms
7,408 KB
testcase_09 AC 5 ms
7,364 KB
testcase_10 AC 5 ms
7,336 KB
testcase_11 AC 5 ms
7,368 KB
testcase_12 AC 5 ms
7,352 KB
testcase_13 AC 5 ms
7,468 KB
testcase_14 AC 5 ms
7,356 KB
testcase_15 AC 6 ms
7,420 KB
testcase_16 AC 8 ms
7,352 KB
testcase_17 AC 20 ms
7,388 KB
testcase_18 AC 33 ms
7,424 KB
testcase_19 AC 37 ms
7,612 KB
testcase_20 AC 6 ms
7,580 KB
testcase_21 AC 5 ms
7,400 KB
testcase_22 AC 5 ms
7,352 KB
testcase_23 AC 6 ms
7,384 KB
testcase_24 AC 5 ms
7,348 KB
testcase_25 AC 14 ms
7,428 KB
testcase_26 AC 17 ms
7,424 KB
testcase_27 AC 6 ms
7,404 KB
testcase_28 AC 34 ms
7,408 KB
testcase_29 AC 16 ms
7,384 KB
testcase_30 AC 13 ms
7,444 KB
testcase_31 AC 38 ms
7,360 KB
testcase_32 AC 30 ms
7,396 KB
testcase_33 AC 16 ms
7,420 KB
testcase_34 AC 15 ms
7,404 KB
testcase_35 AC 31 ms
7,544 KB
testcase_36 AC 36 ms
7,384 KB
testcase_37 AC 13 ms
7,396 KB
testcase_38 AC 18 ms
7,412 KB
testcase_39 AC 34 ms
7,552 KB
testcase_40 AC 11 ms
7,372 KB
testcase_41 AC 6 ms
7,328 KB
testcase_42 AC 37 ms
7,552 KB
testcase_43 AC 37 ms
7,620 KB
testcase_44 AC 38 ms
7,440 KB
testcase_45 AC 37 ms
7,556 KB
testcase_46 WA -
testcase_47 AC 5 ms
7,400 KB
testcase_48 AC 5 ms
7,372 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<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();
    IREP(i, 500) REP(j, 500) {
      if(b3[i][j] > 0) {
        ans.push_back(b3[i][j]);
        REP(k, 10) REP(l, delsize[k]) if(i-k >= 0 && j+l < 500) b3[i-k][j+l] = 0;
        REP(k, 10) REP(l, delsize[k]) if(i-k >= 0 && j-l >= 0) b3[i-k][j-l] = 0;
      }
    }
  }

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

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