QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#171391#7184. Transport Plusesucup-team198#WA 1ms3792kbC++233.5kb2023-09-09 16:54:422023-09-09 16:56:12

Judging History

你现在查看的是最新测评结果

  • [2023-09-09 16:56:12]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3792kb
  • [2023-09-09 16:54:42]
  • 提交

answer

#include<iostream>
#include<algorithm>
#include<string.h>
#include<vector>
#include<tuple>
#include<queue>
#include<cmath>
using namespace std;
// #define debug(x) cout<<"[debug]"#x<<"="<<x<<endl
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const ld eps=1e-8;
const int INF=0x3f3f3f3f,mod=998244353;
const ll INFF=0x3f3f3f3f3f3f3f3f;

// #define ONLINE_JUDGE
#ifndef ONLINE_JUDGE
#include <heltim7/debug>
#else
#define debug(...) 7
#endif

typedef tuple<int,int,int> tp;
const int N=155;
tuple<int,int,int> edg[N][N];
int n,t;
int x[N],y[N];
bool st[N];
int dist[N];
int pre[N];
int main()
{
    scanf("%d%d",&n,&t);
    scanf("%d%d",&x[0],&y[0]);
    scanf("%d%d",&x[n+1],&y[n+1]);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&x[i],&y[i]);
    }

    //<后继点,代价>
    /*传送门到传送门*/
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            edg[i][j]={x[i],y[j],t};
        }
    }

    /*传送门到点*/
    for(auto ty:vector<int>{0,n+1})
    {
        for(int i=1;i<=n;i++)
        {
            int xl=x[i],yl=y[i];
            int x2=x[ty],y2=y[ty];
            int disx=abs(x2-xl);
            int disy=abs(y2-yl);
            if(disx<disy) edg[i][ty]={x[ty],y[ty],disx};//y相同
            else edg[i][ty]={x[ty],y[ty],disy};//x相同
        }
    }
    /*点到传送门*/
    for(auto ty:vector<int>{0,n+1})
    {
        for(int i=1;i<=n;i++)
        {
            int xl=x[i],yl=y[i];
            int x2=x[ty],y2=y[ty];
            int disx=abs(x2-xl);
            int disy=abs(y2-yl);
            if(disx<disy) edg[ty][i]={x[i],y[ty],disx+t};//y相同
            else edg[ty][i]={x[ty],y[i],disy+t};//x相同
        }
    }
    // /*点到点*/
    // edg[0][n+1]={x[0],y[0],abs(x[0]-x[n+1])+abs(y[0]-y[n+1])};
    edg[0][n+1]=edg[n+1][0]={0,0,INF};
    priority_queue<tp,vector<tp>,greater<tp>> heap;
    memset(dist,0x3f,sizeof dist);
    dist[0]=0;
    heap.push({dist[0],-1,0});
    //代价,前驱,当前点,
    while(!heap.empty())
    {
        auto [_,last,u]=heap.top();
        heap.pop();
        if(st[u]) continue;
        st[u]=true;
        pre[u]=last;
        for(int v=0;v<=n+1;v++)
        {
            if(dist[v]>dist[u]+get<2>(edg[u][v]))
            {
                dist[v]=dist[u]+get<2>(edg[u][v]);
                heap.push({dist[v],u,v});
            }
        }
    }
    if(1ll*dist[n+1]*dist[n+1]>1ll*(x[0]-x[n+1])*(x[0]-x[n+1])+1ll*(y[0]-y[n+1])*(y[0]-y[n+1]))
    {
        long double res=sqrtl(1ll*(x[0]-x[n+1])*(x[0]-x[n+1])+1ll*(y[0]-y[n+1])*(y[0]-y[n+1]));
        printf("%.10Lf\n",res);
        printf("%d\n",1);
        printf("%d %d %d\n",0,x[n+1],y[n+1]);
        return 0;
    }
    printf("%d\n",dist[n+1]);

    vector<tp> path;
    int cur=n+1;
    while(cur!=0)
    {
        int last=pre[cur];
        auto [xx,yy,_]=edg[last][cur];
        if(last>=1&&last<=n&&(cur<1||cur>n))//last->cur
        {
            if(cur==n+1&&(x[last]==x[cur]||y[last]==y[cur]))
            {
                path.push_back({last,xx,yy});
            }
            else
            {
                path.push_back({0,xx,yy});
                path.push_back({last,xx,y[last]});
            }
        }
        else
        {
            path.push_back({last,xx,yy});
        }
        cur=last;
    }
    reverse(path.begin(),path.end());
    printf("%d\n",int(path.size()));
    for(auto [t,x,y]:path)
    {
        printf("%d %d %d\n",t,x,y);
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3656kb

input:

1 2
1 1
5 3
6 2

output:

4
3
0 1 2
1 5 2
0 5 3

result:

ok correct

Test #2:

score: 0
Accepted
time: 1ms
memory: 3676kb

input:

2 1
1 1
6 1
1 3
6 3

output:

2
3
0 1 1
1 1 3
2 6 1

result:

ok correct

Test #3:

score: 0
Accepted
time: 1ms
memory: 3684kb

input:

0 0
1 1
1 1

output:

0.0000000000
1
0 1 1

result:

ok correct

Test #4:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

0 0
100 100
0 0

output:

141.4213562373
1
0 0 0

result:

ok correct

Test #5:

score: 0
Accepted
time: 0ms
memory: 3600kb

input:

1 0
100 100
0 0
100 100

output:

100
3
0 100 100
1 0 100
0 0 0

result:

ok correct

Test #6:

score: 0
Accepted
time: 1ms
memory: 3724kb

input:

1 0
100 100
0 0
100 0

output:

0
2
0 100 100
1 0 0

result:

ok correct

Test #7:

score: 0
Accepted
time: 1ms
memory: 3696kb

input:

1 0
100 100
0 0
0 100

output:

0
2
0 100 100
1 0 0

result:

ok correct

Test #8:

score: 0
Accepted
time: 0ms
memory: 3776kb

input:

1 100
50 50
0 0
50 50

output:

70.7106781187
1
0 0 0

result:

ok correct

Test #9:

score: 0
Accepted
time: 1ms
memory: 3792kb

input:

1 100
50 50
0 0
0 50

output:

70.7106781187
1
0 0 0

result:

ok correct

Test #10:

score: 0
Accepted
time: 1ms
memory: 3656kb

input:

1 100
50 50
0 0
51 51

output:

70.7106781187
1
0 0 0

result:

ok correct

Test #11:

score: 0
Accepted
time: 1ms
memory: 3636kb

input:

1 100
50 50
0 0
2 53

output:

70.7106781187
1
0 0 0

result:

ok correct

Test #12:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

1 100
0 0
100 100
50 50

output:

141.4213562373
1
0 100 100

result:

ok correct

Test #13:

score: 0
Accepted
time: 1ms
memory: 3772kb

input:

1 33
0 0
100 100
50 50

output:

133
3
0 0 50
1 100 50
0 100 100

result:

ok correct

Test #14:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

1 12
100 0
11 90
0 100

output:

122
3
0 100 100
1 11 100
0 11 90

result:

ok correct

Test #15:

score: -100
Wrong Answer
time: 1ms
memory: 3624kb

input:

1 12
100 0
10 89
0 100

output:

122
3
0 100 100
1 10 100
0 10 89

result:

wrong answer claimed 122.0000000000, actual 123.0000000000