結果

問題 No.1121 Social Distancing in Cinema
ユーザー catuppercatupper
提出日時 2020-07-22 22:03:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,235 bytes
コンパイル時間 2,114 ms
コンパイル使用メモリ 103,808 KB
実行使用メモリ 26,644 KB
最終ジャッジ日時 2023-09-04 20:28:28
合計ジャッジ時間 8,734 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;
typedef pair<P, Int> T;

Int n;
priority_queue<P, vector<P>, greater<P>> pq;
int ind[550][550];
int deg[550][550];
set<Int> edge[260000];
Int x[260000], y[260000];
vector<int> ans;
bool done[260000];
int main(){
    cin >> n;
    for(int i = 1;i <= n;i++){
        cin >> x[i] >> y[i];
        ind[x[i]][y[i]] = i;
    }
    for(int i = 0;i <= 500;i++){
        for(int j = 0;j <= 500;j++){
            if(ind[i][j] == 0)continue;
            for(int x = max(i-10,0);x <= min(i+10, 500);x++){
                for(int y = max(j-10,0);y <= min(j+10, 500);y++){
                    if((x-i)*(x-i)+(y-j)*(y-j) < 100 && ind[x][y] != 0){
                        edge[ind[i][j]].insert(ind[x][y]);
                        edge[ind[x][y]].insert(ind[i][j]);
                    }
                }
            }
            pq.push({edge[ind[i][j]].size(),ind[i][j]});
        }
    }
    while(!pq.empty()){
        auto tmp = pq.top();pq.pop();      
        int index = tmp.second;
        int deg = tmp.first;
        if(done[index])continue;
        if(edge[index].size() < deg)continue;
        done[index] = true;
        ans.push_back(index);
        set<int> changed;
        for(auto neighb: edge[index]){
            done[neighb] = true;
            for(auto nn: edge[neighb]){
                if(nn == neighb)continue;
                if(edge[nn].count(neighb)){
                    edge[nn].erase(neighb);
                    changed.insert(nn);
                }
            }
            edge[neighb].clear();
        }
        for(auto x:changed){
            if(!done[x])
            pq.push({edge[x].size(),x});
        }
        edge[index].clear();
    }
    cout << ans.size() << endl;    
    for(auto ind:ans)cout << ind << " ";cout << endl;
    return 0;
}
0