結果

問題 No.134 走れ!サブロー君
ユーザー itezpaceitezpace
提出日時 2016-08-20 10:10:28
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,079 bytes
コンパイル時間 633 ms
コンパイル使用メモリ 69,888 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 10:47:12
合計ジャッジ時間 1,238 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:50:24: warning: ‘p’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   50 |   double& wt=get<0>(v[p]);
      |                        ^

ソースコード

diff #

#include <iostream>
#include <vector>
#include <tuple>
#include <climits>
#include <algorithm>
using namespace std;
int main(){
  int n;
  double x,y,x0,y0,xi,yi,wi,T,TC,TA;
  TA=0;
  cin>>x0>>y0;
  x=x0;
  y=y0;
  cin>>n;
  vector<tuple<double,double,double>> v;
  int ws=0;
  for(int i=0; i<n; ++i){
    cin>>xi>>yi>>wi;
    tuple<double,double,double> t;
    t=make_tuple(wi,xi,yi);
    v.push_back(t);
    ws+=wi;
  }
  double d;
  int p;
  double dx,dy,dd;
  while(1){
  d=SHRT_MAX;
  if(v.size()==0){
    dx=x-x0;
    dy=y-y0;
    dd=abs(dx)+abs(dy);
    T=(ws+100);
    T/=120;
    TC=dd*T;
    TA+=TC;
    break;
  }
  for(int i=0; i<v.size(); ++i){
    double& xt=get<1>(v[i]);
    double& yt=get<2>(v[i]);
    dx=xt-x;
    dy=yt-y;
    dd=abs(dx)+abs(dy);
    if(dd<d){
      d=dd;
      p=i;
    }
  }
  double& wt=get<0>(v[p]);
  double& xt=get<1>(v[p]);
  double& yt=get<2>(v[p]);
  dx=xt-x;
  dy=yt-y;
  dd=abs(dx)+abs(dy);
  T=(ws+100);
  T/=120;
  TC=dd*T;
  x=xt;
  y=yt;
  TA+=wt;
  TA+=TC;
  ws-=wt;
  v.erase(v.begin()+p);
  }
  cout<<TA<<endl;
  return 0;
}
0