結果

問題 No.1121 Social Distancing in Cinema
ユーザー IKyoproIKyopro
提出日時 2020-07-22 22:00:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,641 bytes
コンパイル時間 2,427 ms
コンパイル使用メモリ 206,676 KB
実行使用メモリ 5,676 KB
最終ジャッジ日時 2023-09-04 20:12:51
合計ジャッジ時間 7,739 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,208 KB
testcase_01 AC 6 ms
5,068 KB
testcase_02 AC 6 ms
5,144 KB
testcase_03 AC 5 ms
5,208 KB
testcase_04 AC 6 ms
4,960 KB
testcase_05 AC 6 ms
4,960 KB
testcase_06 AC 5 ms
4,960 KB
testcase_07 AC 6 ms
5,124 KB
testcase_08 AC 6 ms
5,136 KB
testcase_09 AC 6 ms
5,140 KB
testcase_10 AC 6 ms
5,100 KB
testcase_11 AC 6 ms
5,100 KB
testcase_12 AC 6 ms
5,072 KB
testcase_13 AC 5 ms
5,248 KB
testcase_14 AC 6 ms
4,984 KB
testcase_15 AC 7 ms
5,384 KB
testcase_16 AC 11 ms
5,360 KB
testcase_17 AC 27 ms
5,600 KB
testcase_18 AC 44 ms
5,404 KB
testcase_19 AC 51 ms
5,544 KB
testcase_20 AC 7 ms
5,352 KB
testcase_21 AC 7 ms
5,472 KB
testcase_22 AC 7 ms
5,380 KB
testcase_23 AC 6 ms
5,324 KB
testcase_24 AC 6 ms
5,376 KB
testcase_25 AC 28 ms
5,676 KB
testcase_26 AC 33 ms
5,412 KB
testcase_27 AC 11 ms
5,376 KB
testcase_28 AC 49 ms
5,540 KB
testcase_29 AC 32 ms
5,404 KB
testcase_30 AC 17 ms
5,396 KB
testcase_31 AC 51 ms
5,484 KB
testcase_32 AC 40 ms
5,488 KB
testcase_33 AC 21 ms
5,388 KB
testcase_34 AC 21 ms
5,504 KB
testcase_35 AC 41 ms
5,660 KB
testcase_36 AC 49 ms
5,396 KB
testcase_37 AC 16 ms
5,364 KB
testcase_38 AC 23 ms
5,600 KB
testcase_39 AC 45 ms
5,432 KB
testcase_40 AC 15 ms
5,428 KB
testcase_41 AC 9 ms
5,356 KB
testcase_42 AC 49 ms
5,452 KB
testcase_43 AC 50 ms
5,540 KB
testcase_44 WA -
testcase_45 WA -
testcase_46 WA -
testcase_47 AC 6 ms
5,212 KB
testcase_48 AC 6 ms
4,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int M = 500;
    vvec<int> id(M,vec<int>(M,-1));
    vvec<int> ok(M,vec<int>(M,1));
    int N;
    cin >> N;
    for(int i=0;i<N;i++){
        int x,y;
        cin >> x >> y;
        x--; y--;
        id[x][y] = i;
    }
    vec<int> ans;

    auto in = [&](int x,int y){
        return 0<=x && x<M && 0<=y && y<M;
    };

    auto update = [&](int x,int y){
        for(int dx=-10;dx<=10;dx++) for(int dy=-10;dy<=10;dy++){
            if(in(x+dx,y+dy) && dx*dx+dy*dy<100) ok[x+dx][y+dy] = 0;
        }
    };

    auto init = [&](){
        for(int i=0;i<M;i++) for(int j=0;j<M;j++) ok[i][j] = 1;
    };


    auto greedy = [&](int sx,int ex,int dx,int sy,int ey,int dy){
        init();
        vec<int> res;
        for(int i=sx;min(sx,ex)<=i && i<=max(sx,ex);i+=dx){
            for(int j=sy;min(sy,ey)<=j && j<=max(sy,ey);j+=dy) if(id[i][j]!=-1 && ok[i][j]){
                res.push_back(id[i][j]);
                update(i,j);
            }
        }
        return res;
    };

    ans = greedy(0,M-1,1,0,M-1,1);
    auto res = greedy(0,M-1,1,M-1,0,-1);
    if(ans.size()<res.size()){
        ans = res;
    }
    res = greedy(M-1,0,-1,M-1,0,-1);
    if(ans.size()<res.size()){
        ans = res;
    }
    res = greedy(M-1,0,-1,0,M-1,1);
    if(ans.size()<res.size()){
        ans = res;
    }

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