cdqz2017-test11-占卜的准备

#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

#define N 201

pair<int,int>p[N];
char s[N];

int ans[N],cnt;

bool vis[N];

int start;
int tmp[N];

void read(int &x)
{
    x=0; char c=getchar();
    while(!isdigit(c)) c=getchar();
    while(isdigit(c)) { x=x*10+c-'0'; c=getchar(); } 
}

pair<int,int> operator - (pair<int,int> a,pair<int,int> b) { return make_pair(a.first-b.first,a.second-b.second); }

int Cross(pair<int,int> a,pair<int,int> b) { return a.first*b.second-a.second*b.first; }

bool cmp(int a,int b)
{
    return Cross(p[a]-p[start],p[b]-p[start])>0;
}

int main()
{
    freopen("divination.in","r",stdin);
    freopen("divination.out","w",stdout);
    int n;
    read(n);
    for(int i=1;i<=n;++i) read(p[i].first),read(p[i].second);
    scanf("%s",s+1);
    start=1;
    for(int i=2;i<=n;++i) 
        if(p[i]<p[start]) start=i;
    ans[++cnt]=start; 
    vis[start]=true;
    int m;
    for(int i=1;i<=n-2;++i)
    {
        m=0;
        for(int j=1;j<=n;++j)
            if(!vis[j]) tmp[++m]=j; 
        sort(tmp+1,tmp+m+1,cmp);
        if(s[i]=='L') start=tmp[1];
        else start=tmp[m];
        ans[++cnt]=start;
        vis[start]=true;
    }
    for(int i=1;i<n;++i) printf("%d ",ans[i]);
    for(int i=1;i<=n;++i) if(!vis[i]) printf("%d",i);
}

 

posted @ 2018-04-03 18:49  TRTTG  阅读(247)  评论(0编辑  收藏  举报