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

#include <cmath>
#include <iostream>
#include <map>
#include <utility>
#include <vector>

using namespace std;

typedef pair<double, double> PBB;
typedef vector<PBB> VPBB;
typedef multimap<double, int> MDI;
typedef MDI::iterator MDII;

#define PUSH push_back
#define MDIVT MDI::value_type
#define PI 3.14159265359
#define INF 10000000000
#define NMAX 100

int main() {

  int n;
  int main, st;
  int num;
  double x, y;
  double sita;
  char gav;
  double bef;
  VPBB pin;
  MDI point;
  MDII ite;

  while (1) {
    cin >> n;
    if (n == 0)
      break;
    for (int i = 0; i < n; i++) {
      cin >> x >> gav >> y;
      pin.PUSH(PBB(x, y));
    }

    main = 0;
    for (int i = 1; i < n; i++) {
      if (pin[main].second < pin[i].second)
        main = i;
      else if (pin[main].second == pin[i].second &&
               pin[main].first < pin[i].first)
        main = i;
    }
    st = main;
    num = 0;
    bef = -1 * PI;
    while (1) {
      /// cout<<num<<"\\\\\\\\"<<main<<endl;
      for (int i = 0; i < n; i++) {
        if (pin[i].second != pin[main].second)
          sita = atan2(pin[i].second - pin[main].second,
                       pin[i].first - pin[main].first);
        else
          sita = -1 * PI;
        if (i != main && sita > bef) {
          /// cout<<sita<<"---"<<i<<endl;
          point.insert(MDIVT(sita, i));
        }
      }
      ite = point.begin();
      bef = (*ite).first;
      main = (*ite).second;
      point.clear();
      num++;
      if (main == st)
        break;
    }
    cout << n - num << endl;
    pin.clear();
  }
}

Error: TLE

Fixed submission:

#include <cmath>
#include <iostream>
#include <map>
#include <utility>
#include <vector>

using namespace std;

typedef pair<double, double> PBB;
typedef vector<PBB> VPBB;
typedef multimap<double, int> MDI;
typedef MDI::iterator MDII;

#define PUSH push_back
#define MDIVT MDI::value_type
#define PI 3.14159265359
#define INF 10000000000
#define NMAX 100

int main() {

  int n;
  int main, st;
  int num;
  double x, y;
  double ax, ay, bx, by, cx, cy;
  double ans;
  double sita;
  char gav;
  double bef;
  VPBB pin;
  MDI point;
  MDII ite;

  while (1) {
    cin >> n;
    for (int i = 0; i < n; i++) {
      cin >> x >> gav >> y;
      pin.PUSH(PBB(x, y));
    }

    main = 0;
    for (int i = 1; i < n; i++) {
      if (pin[main].second < pin[i].second)
        main = i;
      else if (pin[main].second == pin[i].second &&
               pin[main].first < pin[i].first)
        main = i;
    }
    st = main;
    num = 0;
    bef = -1 * PI;
    while (1) {
      /// cout<<num<<"\\\\\\\\"<<main<<endl;
      for (int i = 0; i < n; i++) {
        if (pin[i].second != pin[main].second)
          sita = atan2(pin[i].second - pin[main].second,
                       pin[i].first - pin[main].first);
        else
          sita = -1 * PI;
        if (i != main && sita > bef) {
          /// cout<<sita<<"---"<<i<<endl;
          point.insert(MDIVT(sita, i));
        }
      }
      ite = point.begin();
      bef = (*ite).first;
      main = (*ite).second;
      point.clear();
      num++;
      if (main == st)
        break;
    }
    cout << n - num << endl;
    pin.clear();
  }
}