Submission #4232913


Source Code Expand

#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=924844033;
#define N 1055050

ll n,m,k,l;
double d[210][210];
ll x[210],y[210];
double calc(vector<int> v){
    double ave=0.0,ave2=0.0;
    v.pb(v[0]);
    rep(i,n){
        ave+=d[v[i]][v[i+1]];
        ave2+=(d[v[i]][v[i+1]]*d[v[i]][v[i+1]]);
    }
    ave/=(double)n;
    ave2/=(double)n;
    return ave2-ave*ave;
}
vec make(double l,pii p){
    bool used[201]={};
    vec v={p.first,p.second};
    used[v[0]]=used[v[1]]=1;
    int now=v[1];
    rep(i,n-2){
        double dif=1000.0;
        int next;
        rep(j,n){
            if(used[j])continue;
            if(abs(d[now][j]-l)<dif){
                next=j;
                dif=abs(d[now][j]-l);
            }
        }
        v.pb(next);
        used[next]=1;
        now=next;
    }
    return v;
}
vector<pair<double,pii>> len;
double tempans=100000000.0;
vec ans;
main(){
    clock_t clo=clock();
    n=in();
    rep(i,n){x[i]=in(),y[i]=in();};
    rep(i,n)rep(j,n){
        d[i][j]=(double)(x[i]-x[j])*(double)(x[i]-x[j])+(double)(y[i]-y[j])*(double)(y[i]-y[j]);
        d[i][j]=sqrt(d[i][j]);
        if(i>j)
        len.pb({d[i][j],{i,j}});
    }
    /*方針1 長さ決め打ち
    長さの選び方20000通り
    ある長さ当たり200×200回計算
    →間にあう!
    */
    sort(ALL(len));
    rep2(i,1300,27000){
        double temp=len[i].first;
        vec now=make(temp,len[i].second);
        double ddd=calc(now);
        if(ddd<tempans){
            tempans=ddd;
            ans=now;
        }
    }
    rep(i,n){
        cout<<ans[i]<<endl;
    }
    return 0;
}   

Submission Info

Submission Time
Task A - Multiple Pieces
User noimi
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2826 Byte
Status RE
Exec Time 129 ms
Memory 384 KB

Compile Error

./Main.cpp: In function ‘int in()’:
./Main.cpp:41:31: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 int in() {int x;scanf("%d",&x);return x;}
                               ^
./Main.cpp: In function ‘long long int lin()’:
./Main.cpp:42:32: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 ll lin() {ll x;scanf("%lld",&x);return x;}
                                ^

Judge Result

Set Name test_01 test_02 test_03 test_04 test_05 test_06 test_07 test_08 test_09 test_10
Score / Max Score 0 / 1343058 0 / 1343058 0 / 1343058 0 / 1343058 0 / 1343058 0 / 1343058 0 / 1343058 0 / 1343058 0 / 1343058 0 / 1343058
Status
RE × 1
RE × 1
RE × 1
RE × 1
RE × 1
RE × 1
RE × 1
RE × 1
RE × 1
RE × 1
Set Name Test Cases
test_01 subtask_01_01.txt
test_02 subtask_01_02.txt
test_03 subtask_01_03.txt
test_04 subtask_01_04.txt
test_05 subtask_01_05.txt
test_06 subtask_01_06.txt
test_07 subtask_01_07.txt
test_08 subtask_01_08.txt
test_09 subtask_01_09.txt
test_10 subtask_01_10.txt
Case Name Status Exec Time Memory
subtask_01_01.txt RE 129 ms 384 KB
subtask_01_02.txt RE 99 ms 384 KB
subtask_01_03.txt RE 100 ms 384 KB
subtask_01_04.txt RE 100 ms 384 KB
subtask_01_05.txt RE 99 ms 384 KB
subtask_01_06.txt RE 98 ms 384 KB
subtask_01_07.txt RE 99 ms 384 KB
subtask_01_08.txt RE 99 ms 384 KB
subtask_01_09.txt RE 99 ms 384 KB
subtask_01_10.txt RE 99 ms 384 KB