QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#675358#7184. Transport Pluses22016020736#WA 0ms8076kbC++173.7kb2024-10-25 18:25:152024-10-25 18:25:15

Judging History

This is the latest submission verdict.

  • [2024-10-25 18:25:15]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 8076kb
  • [2024-10-25 18:25:15]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
struct node
{
   int x,y;
}dian[200009];

map<pair<int,int>,int>bianhao;
map<int,pair<int,int>>fbianhao;

double juli[300][300][2];
int biaoji[200009];
double dis[200009];
int pre[200009][2];

double calc(int x1,int y1,int x2,int y2)
{
   return sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

int main()
{
   int n,t;
   int startx,endx,starty,endy;
   scanf("%d%d",&n,&t);
   scanf("%d%d",&startx,&starty);
   scanf("%d%d",&endx,&endy);

   for(int i=1;i<=n;i++)
   {
     int x,y;
     scanf("%d%d",&x,&y);
     dian[i]={x,y};
   }

   int tot=0;
   tot++;///起点是1,终点是2;
   bianhao[make_pair(startx,starty)]=tot;
   fbianhao[tot]=make_pair(startx,starty);
   tot++;
   bianhao[make_pair(endx,endy)]=tot;
   fbianhao[tot]=make_pair(endx,endy);
   for(int i=1;i<=n;i++)
   {
      int x=dian[i].x,y=dian[i].y;
      int xx1=startx,yy1=y,xx2=x,yy2=starty;
      if(!bianhao[make_pair(xx1,yy1)])
      {
         tot++;
         fbianhao[tot]=make_pair(xx1,yy1);
      }
       if(!bianhao[make_pair(xx2,yy2)])
      {
         tot++;
         fbianhao[tot]=make_pair(xx2,yy2);
      }

      xx1=endx,yy1=y,xx2=x,yy2=endy;
       if(!bianhao[make_pair(xx1,yy1)])
      {
         tot++;
         fbianhao[tot]=make_pair(xx1,yy1);
      }
       if(!bianhao[make_pair(xx2,yy2)])
      {
         tot++;
         fbianhao[tot]=make_pair(xx2,yy2);
      }
   }

   for(int i=1;i<=tot;i++)
   {
      for(int j=1;j<=tot;j++)
      {
          if(i==j) continue;
          int x1=fbianhao[i].first,y1=fbianhao[i].second,x2=fbianhao[j].first,y2=fbianhao[j].second;
          double mn=calc(x1,y1,x2,y2);
          int op=0;
         for(int k=1;k<=n;k++)
         {
             int xx=dian[k].x,yy=dian[k].y;
            if(x1==x2&&x1==xx)
            {
                if(mn>(double)(t))
                {
                   mn=double(t);
                   op=1;
                }
               //mn=min(mn,double(t));
               break;
             }
            else if(y1==y2&&y1==yy)
            {
                 if(mn>(double)(t))
                {
                   mn=double(t);
                   op=1;
                }
                break;
            }
            else if(x1==xx&&y2==yy)
            {
                 if(mn>(double)(t))
                {
                   mn=double(t);
                   op=1;
                }
                break;
            }
            else if(x2==xx&&y1==yy)
            {
                 if(mn>(double)(t))
                {
                   mn=double(t);
                   op=1;
                }
                break;
            }

         }
         juli[i][j][0]=op;
         juli[i][j][1]=mn;
      }
   }

   queue<pair<double,int>>qq;
   for(int i=1;i<=tot;i++)
   {
      dis[i]=99999999.9;
   }
   dis[1]=0;
   qq.push({0.0,1});
   while(!qq.empty())
   {
       auto[sum,bh]=qq.front();
       qq.pop();
       for(int j=1;j<=tot;j++)
       {
           if(dis[j]>sum+juli[bh][j][1])
           {
               pre[j][1]=bh;
               pre[j][0]=juli[bh][j][0];
              dis[j]=sum+juli[bh][j][1];
              qq.push({dis[j],j});
           }
       }
   }
   printf("%.6lf\n",dis[2]);
   int pe=2;
   vector<array<int,3>>vt;
   //vt.push_back({pre[2][0],fbianhao[2].first,fbianhao[2].second});
   while(pe!=1)
   {
      vt.push_back({pre[pe][0],fbianhao[pe].first,fbianhao[pe].second});
      pe=pre[pe][1];
   }
   for(int i=vt.size()-1;i>=0;i--)
   {
       printf("%d %d %d\n",vt[i][0],vt[i][1],vt[i][2]);
   }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 8076kb

input:

1 2
1 1
5 3
6 2

output:

4.000000
0 1 2
1 5 2
0 5 3

result:

wrong answer arrived at (1.000000, 1.000000) instead of (5.000000, 3.000000)