結果

問題 No.1121 Social Distancing in Cinema
ユーザー auauaauaua
提出日時 2020-07-22 23:14:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 8,353 bytes
コンパイル時間 1,962 ms
コンパイル使用メモリ 187,172 KB
実行使用メモリ 7,808 KB
最終ジャッジ日時 2024-06-23 00:52:14
合計ジャッジ時間 6,898 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
7,424 KB
testcase_01 AC 9 ms
7,424 KB
testcase_02 AC 10 ms
7,424 KB
testcase_03 AC 10 ms
7,424 KB
testcase_04 AC 10 ms
7,424 KB
testcase_05 AC 10 ms
7,424 KB
testcase_06 AC 9 ms
7,424 KB
testcase_07 AC 10 ms
7,552 KB
testcase_08 AC 11 ms
7,552 KB
testcase_09 AC 10 ms
7,424 KB
testcase_10 AC 10 ms
7,424 KB
testcase_11 AC 10 ms
7,424 KB
testcase_12 AC 10 ms
7,424 KB
testcase_13 AC 10 ms
7,424 KB
testcase_14 AC 11 ms
7,296 KB
testcase_15 AC 14 ms
7,424 KB
testcase_16 AC 26 ms
7,424 KB
testcase_17 AC 68 ms
7,552 KB
testcase_18 AC 120 ms
7,680 KB
testcase_19 AC 142 ms
7,680 KB
testcase_20 AC 17 ms
7,424 KB
testcase_21 AC 15 ms
7,424 KB
testcase_22 AC 14 ms
7,424 KB
testcase_23 AC 13 ms
7,424 KB
testcase_24 AC 13 ms
7,424 KB
testcase_25 AC 82 ms
7,680 KB
testcase_26 AC 92 ms
7,808 KB
testcase_27 AC 58 ms
7,552 KB
testcase_28 AC 137 ms
7,680 KB
testcase_29 AC 87 ms
7,680 KB
testcase_30 AC 42 ms
7,424 KB
testcase_31 AC 135 ms
7,680 KB
testcase_32 AC 105 ms
7,552 KB
testcase_33 AC 53 ms
7,424 KB
testcase_34 AC 58 ms
7,424 KB
testcase_35 AC 112 ms
7,680 KB
testcase_36 AC 131 ms
7,680 KB
testcase_37 AC 44 ms
7,424 KB
testcase_38 AC 63 ms
7,424 KB
testcase_39 AC 135 ms
7,680 KB
testcase_40 AC 54 ms
7,424 KB
testcase_41 AC 23 ms
7,424 KB
testcase_42 AC 134 ms
7,680 KB
testcase_43 AC 135 ms
7,552 KB
testcase_44 AC 134 ms
7,808 KB
testcase_45 AC 136 ms
7,680 KB
testcase_46 WA -
testcase_47 AC 11 ms
7,424 KB
testcase_48 AC 10 ms
7,424 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:296:20: warning: division by zero [-Wdiv-by-zero]
  296 |             cout<<1/0<<endl;
      |                   ~^~

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
signed main(){
    ll n;cin>>n;
    vector<vector<ll> >a(500,vector<ll>(500));
    rep(i,n){
        ll x,y;cin>>x>>y;
        x--;y--;
        a[x][y]=i+1;
    }
    vector<vector<ll> >used(500,vector<ll>(500));
    vector<ll>ans1(0);
    vector<ll>ans2(0);
    vector<ll>ans3(0);
    vector<ll>ans4(0);
    ll s=(n-1)/90+1;
    rep(i,500){
        rep(j,500){
            if(used[i][j])continue;
            if(a[i][j]==0)continue;
            ans1.pb(a[i][j]);
            used[i][j]=1;
            queue<pll>q;
            q.push(mp(i,j));
            while(!q.empty()){
                pll k=q.front();
                q.pop();
                ll x=k.first;
                ll y=k.second;
                rep(l,4){
                    ll nx=x+dx[l];
                    ll ny=y+dy[l];
                    if(nx<0||nx>=500||ny<0||ny>=500)continue;
                    if((nx-i)*(nx-i)+(ny-j)*(ny-j)>=100)continue;
                    if(used[nx][ny])continue;
                    q.push(mp(nx,ny));
                    used[nx][ny]=1;
                }
            }
        }
    }
    rep(i,500){
        rep(j,500)used[i][j]=0;
    }
    rep(j,500){
        rep(i,500){
            if(used[i][j])continue;
            if(a[i][j]==0)continue;
            ans2.pb(a[i][j]);
            used[i][j]=1;
            queue<pll>q;
            q.push(mp(i,j));
            while(!q.empty()){
                pll k=q.front();
                q.pop();
                ll x=k.first;
                ll y=k.second;
                rep(l,4){
                    ll nx=x+dx[l];
                    ll ny=y+dy[l];
                    if(nx<0||nx>=500||ny<0||ny>=500)continue;
                    if((nx-i)*(nx-i)+(ny-j)*(ny-j)>=100)continue;
                    if(used[nx][ny])continue;
                    q.push(mp(nx,ny));
                    used[nx][ny]=1;
                }
            }
        }
    }
    rep(i,500){
        rep(j,500)used[i][j]=0;
    }
    for(int i=499;i>=0;i--){
        for(int j=499;j>=0;j--){
            if(used[i][j])continue;
            if(a[i][j]==0)continue;
            ans3.pb(a[i][j]);
            used[i][j]=1;
            queue<pll>q;
            q.push(mp(i,j));
            while(!q.empty()){
                pll k=q.front();
                q.pop();
                ll x=k.first;
                ll y=k.second;
                rep(l,4){
                    ll nx=x+dx[l];
                    ll ny=y+dy[l];
                    if(nx<0||nx>=500||ny<0||ny>=500)continue;
                    if((nx-i)*(nx-i)+(ny-j)*(ny-j)>=100)continue;
                    if(used[nx][ny])continue;
                    q.push(mp(nx,ny));
                    used[nx][ny]=1;
                }
            }
        }
    }
    rep(i,500){
        rep(j,500)used[i][j]=0;
    }
    for(int j=499;j>=0;j--){
        for(int i=499;i>=0;i--){
            if(used[i][j])continue;
            if(a[i][j]==0)continue;
            ans4.pb(a[i][j]);
            used[i][j]=1;
            queue<pll>q;
            q.push(mp(i,j));
            while(!q.empty()){
                pll k=q.front();
                q.pop();
                ll x=k.first;
                ll y=k.second;
                rep(l,4){
                    ll nx=x+dx[l];
                    ll ny=y+dy[l];
                    if(nx<0||nx>=500||ny<0||ny>=500)continue;
                    if((nx-i)*(nx-i)+(ny-j)*(ny-j)>=100)continue;
                    if(used[nx][ny])continue;
                    q.push(mp(nx,ny));
                    used[nx][ny]=1;
                }
            }
        }
    }
    vector<ll>ans11(0);
    vector<ll>ans21(0);
    vector<ll>ans31(0);
    vector<ll>ans41(0);
    rep(i,500){
        rep(j,500)used[i][j]=0;
    }
    rep(i,500){
        for(int j=499;j>=0;j--){
            if(used[i][j])continue;
            if(a[i][j]==0)continue;
            ans11.pb(a[i][j]);
            used[i][j]=1;
            queue<pll>q;
            q.push(mp(i,j));
            while(!q.empty()){
                pll k=q.front();
                q.pop();
                ll x=k.first;
                ll y=k.second;
                rep(l,4){
                    ll nx=x+dx[l];
                    ll ny=y+dy[l];
                    if(nx<0||nx>=500||ny<0||ny>=500)continue;
                    if((nx-i)*(nx-i)+(ny-j)*(ny-j)>=100)continue;
                    if(used[nx][ny])continue;
                    q.push(mp(nx,ny));
                    used[nx][ny]=1;
                }
            }
        }
    }
    rep(i,500){
        rep(j,500)used[i][j]=0;
    }
    rep(j,500){
        for(int i=499;i>=0;i--){
            if(used[i][j])continue;
            if(a[i][j]==0)continue;
            ans21.pb(a[i][j]);
            used[i][j]=1;
            queue<pll>q;
            q.push(mp(i,j));
            while(!q.empty()){
                pll k=q.front();
                q.pop();
                ll x=k.first;
                ll y=k.second;
                rep(l,4){
                    ll nx=x+dx[l];
                    ll ny=y+dy[l];
                    if(nx<0||nx>=500||ny<0||ny>=500)continue;
                    if((nx-i)*(nx-i)+(ny-j)*(ny-j)>=100)continue;
                    if(used[nx][ny])continue;
                    q.push(mp(nx,ny));
                    used[nx][ny]=1;
                }
            }
        }
    }
    rep(i,500){
        rep(j,500)used[i][j]=0;
    }
    for(int i=499;i>=0;i--){
        rep(j,500){
            if(used[i][j])continue;
            if(a[i][j]==0)continue;
            ans31.pb(a[i][j]);
            used[i][j]=1;
            queue<pll>q;
            q.push(mp(i,j));
            while(!q.empty()){
                pll k=q.front();
                q.pop();
                ll x=k.first;
                ll y=k.second;
                rep(l,4){
                    ll nx=x+dx[l];
                    ll ny=y+dy[l];
                    if(nx<0||nx>=500||ny<0||ny>=500)continue;
                    if((nx-i)*(nx-i)+(ny-j)*(ny-j)>=100)continue;
                    if(used[nx][ny])continue;
                    q.push(mp(nx,ny));
                    used[nx][ny]=1;
                }
            }
        }
    }
    rep(i,500){
        rep(j,500)used[i][j]=0;
    }
    for(int j=499;j>=0;j--){
        rep(i,500){
            if(used[i][j])continue;
            if(a[i][j]==0)continue;
            ans41.pb(a[i][j]);
            used[i][j]=1;
            queue<pll>q;
            q.push(mp(i,j));
            while(!q.empty()){
                pll k=q.front();
                q.pop();
                ll x=k.first;
                ll y=k.second;
                rep(l,4){
                    ll nx=x+dx[l];
                    ll ny=y+dy[l];
                    if(nx<0||nx>=500||ny<0||ny>=500)continue;
                    if((nx-i)*(nx-i)+(ny-j)*(ny-j)>=100)continue;
                    if(used[nx][ny])continue;
                    q.push(mp(nx,ny));
                    used[nx][ny]=1;
                }
            }
        }
    }
    cout<<s<<endl;
    if(ans1.size()>=s){
        rep(i,s){
            cout<<ans1[i]<<' ';
        }
    }else if(ans2.size()>=s){
        rep(i,s){
            cout<<ans2[i]<<' ';
        }
    }else if(ans3.size()>=s){
        rep(i,s){
            cout<<ans3[i]<<' ';
        }
    }else if(ans4.size()>=s){
        rep(i,s){
            cout<<ans4[i]<<' ';
        }
    }else if(ans11.size()>=s){
        rep(i,s){
            cout<<ans11[i]<<' ';
        }
    }else if(ans21.size()>=s){
        rep(i,s){
            cout<<ans21[i]<<' ';
        }
    }else if(ans31.size()>=s){
        rep(i,s){
            cout<<ans31[i]<<' ';
        }
    }else if(ans41.size()>=s){
        rep(i,s){
            cout<<ans41[i]<<' ';
        }
    }else{
        if(n==500*500){
            cout<<1/0<<endl;
        }
    }
    cout<<endl;
}
0