結果

問題 No.1121 Social Distancing in Cinema
ユーザー nebukuro09
提出日時 2020-07-22 23:00:04
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 1,798 bytes
コンパイル時間 2,686 ms
コンパイル使用メモリ 164,568 KB
実行使用メモリ 22,016 KB
最終ジャッジ日時 2024-10-15 14:38:58
合計ジャッジ時間 19,917 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 2
other AC * 44 TLE * 1 -- * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:34:5: warning: expression result unused [-Wunused-value]
   34 |     N; cin >> N;
      |     ^
1 warning generated.

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);i++)
#define REP2(i,m,n) for (int i=m;i<(n);i++)
typedef long long ll;

int N;
vector<int> A[500*500];

vector<int> solve2() {
    vector<int> ans;

    REP(i, N) {
        bool ok = true;
        for (auto a: ans) {
            if ((A[i][0] - A[a][0]) * (A[i][0] - A[a][0]) + (A[i][1] - A[a][1]) * (A[i][1] - A[a][1]) < 100) {
                ok = false;
                break;
            }
        }
        if (ok) {
            ans.push_back(A[i][2]);
        }
    }

    if ((int)ans.size() * 90 >= N) {
        return ans;
    } else {
        return vector<int>();
    }
}

void solve() {
    N; cin >> N;
    REP(i, N) {
        A[i] = vector<int>(3);
        cin >> A[i][0] >> A[i][1];
        A[i][2] = i;
    }

    vector<int> ans;

    sort(A, A+N);
    ans = solve2();
    if (!ans.empty()) {
        cout << ans.size() << endl;
        for (auto a: ans) cout << a + 1 << " ";
        cout << endl;
        return;
    }

    REP(i, N) A[i][0] *= -1;
    sort(A, A+N);
    ans = solve2();
    if (!ans.empty()) {
        cout << ans.size() << endl;
        for (auto a: ans) cout << a + 1 << " ";
        cout << endl;
        return;
    }
    REP(i, N) A[i][0] *= -1;


    REP(i, N) swap(A[i][0], A[i][1]);
    sort(A, A+N);
    ans = solve2();
    if (!ans.empty()) {
        cout << ans.size() << endl;
        for (auto a: ans) cout << a + 1 << " ";
        cout << endl;
        return;
    }

    REP(i, N) A[i][0] *= -1;
    sort(A, A+N);
    ans = solve2();
    if (!ans.empty()) {
        cout << ans.size() << endl;
        for (auto a: ans) cout << a + 1 << " ";
        cout << endl;
        return;
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}
0