Problem p02361 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <array>
#include <iostream>

typedef struct {
  int point1;
  int point2;
  int cost;
} way;

int main() {
  int number_point, number_edge;
  int start_point;
  std::cin >> number_point >> number_edge >>
      start_point; //?????????????????°??¨?§???????????????????

  //?§????????????????????????????
  const int BIGNUMBER = 1001001001;
  int *shortest_way = new int[number_point];

  for (int i = 0; i < number_point; i++) {
    shortest_way[i] = BIGNUMBER; //??§???????????§?????????
  }
  shortest_way[start_point] = 0; //???????????´??????????§????????????????0

  //?§?????????????????´?????????????????????£???????????????????????????
  way *way_data = new way[number_edge];
  for (int i = 0; i < number_edge; i++) {
    std::cin >> (way_data[i]).point1 >> (way_data[i]).point2 >>
        (way_data[i]).cost;
  }

  //????????????????°?????????´??°??????
  while (true) {
    bool changed = false;
    for (int i = 0; i < number_edge; i++) {
      //?????????point1????????±????????????????????£??????????????±??????
      if (shortest_way[(way_data[i]).point2] >
          shortest_way[(way_data[i]).point1] + (way_data[i]).cost) {
        shortest_way[(way_data[i]).point2] =
            shortest_way[(way_data[i]).point1] + (way_data[i]).cost;
        changed = true;
      }
    }

    //??????for??§???????????????????????????????????????????????????????????????????????£??????,?????????????????????
    if (!changed) {
      break;
    }
  }

  for (int i = 0; i < number_point; i++) {
    if (shortest_way[i] == BIGNUMBER) {
      std::cout << "INF" << std::endl;
    } else {
      std::cout << shortest_way[i] << std::endl;
    }
  }

  delete[] shortest_way;
  delete[] way_data;

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <array>
#include <iostream>

typedef struct {
  int point1;
  int point2;
  int cost;
} way;

int main() {
  int number_point, number_edge;
  int start_point;
  std::cin >> number_point >> number_edge >>
      start_point; //?????????????????°??¨?§???????????????????

  //?§????????????????????????????
  const int BIGNUMBER = 1001001001;
  int *shortest_way = new int[number_point];

  for (int i = 0; i < number_point; i++) {
    shortest_way[i] = BIGNUMBER; //??§???????????§?????????
  }
  shortest_way[start_point] = 0; //???????????´??????????§????????????????0

  //?§?????????????????´?????????????????????£???????????????????????????
  way *way_data = new way[number_edge];
  for (int i = 0; i < number_edge; i++) {
    std::cin >> (way_data[i]).point1 >> (way_data[i]).point2 >>
        (way_data[i]).cost;
  }

  //????????????????°?????????´??°??????
  for (int kaisu = 0; kaisu < number_point; kaisu++) {
    for (int i = 0; i < number_edge; i++) {
      //?????????point1????????±????????????????????£??????????????±??????
      shortest_way[(way_data[i]).point2] =
          std::min(shortest_way[(way_data[i]).point2],
                   shortest_way[(way_data[i]).point1] + (way_data[i]).cost);
    }
  }

  for (int i = 0; i < number_point; i++) {
    if (shortest_way[i] == BIGNUMBER) {
      std::cout << "INF" << std::endl;
    } else {
      std::cout << shortest_way[i] << std::endl;
    }
  }

  delete[] shortest_way;
  delete[] way_data;

  return 0;
}