結果

問題 No.1121 Social Distancing in Cinema
ユーザー IKyoproIKyopro
提出日時 2020-07-22 21:59:29
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,625 bytes
コンパイル時間 2,209 ms
コンパイル使用メモリ 200,556 KB
最終ジャッジ日時 2025-01-12 02:42:32
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 44 WA * 3
権限があれば一括ダウンロードができます

ソースコード

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){
        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