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

#include <algorithm> //辞書順=next_permutation
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <locale>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <string> //char 小文字のほうが32大きい
#include <time.h>
#include <utility> //swap=数値交換
#include <vector>  //s1.erase(n)=文字列s1の、n文字目以降削除

#define rt "\\n"
#define rep(i, n) for (int i = 0; i < n; i++)
#define rop(i, n) for (int i = 1; i <= n; i++)
#define drep(i, n) for (int i = n - 1; 0 <= i; i--)
#define drop(i, n) for (int i = n; 0 < i; i--)
#define yes(ans)                                                               \\
  if (ans)                                                                     \\
    cout << "yes" << rt;                                                       \\
  else                                                                         \\
    cout << "no" << rt;
#define Yes(ans)                                                               \\
  if (ans)                                                                     \\
    cout << "Yes" << rt;                                                       \\
  else                                                                         \\
    cout << "No" << rt;
#define YES(ans)                                                               \\
  if (ans)                                                                     \\
    cout << "YES" << rt;                                                       \\
  else                                                                         \\
    cout << "NO" << rt;
#define sec(a, b, ans)                                                         \\
  if (ans)                                                                     \\
    cout << a << rt;                                                           \\
  else                                                                         \\
    cout << b << rt;
#define vcin(s, n) rep(i, n) cin >> s[i]; // vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(), s.end())  // 標準=昇順
#define reve(s) reverse(s.begin(), s.end())
#define asas int ans = 0
#define llcncn llint cnt = 0
#define llasas llint ans = 0
#define str string
#define please return
#define AC 0
#define ic_a                                                                   \\
  int a;                                                                       \\
  cin >> a;
#define ic_b                                                                   \\
  int b;                                                                       \\
  cin >> b;
#define ic_s                                                                   \\
  string s;                                                                    \\
  cin >> s;
#define Rapid_pleaseAC_fast                                                    \\
  cin.tie(0);                                                                  \\
  ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000
using ll = long long;
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差
long long GCD(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}

long long LCM(long long a, long long b) { return a * b / GCD(a, b); }

unsigned GetDigit(unsigned num) { return std::to_string(num).length(); }

int tow(int n) { // 2のn乗
  if (n == 0)
    return 1;
  int x = tow(n / 2);
  x *= x;
  if (n % 2 == 1)
    x *= 2;
  return x; //@domino
}

int keta(int n) {
  int sum = 0;
  while (n != 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum; // Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
ld mysqrtl(ld x) {
  ld a = sqrtl((double)x); // 近似値
  do {
    a = (a + x / a) / 2.0L;
  } while (fabsl(x - a * a) > eps);
  return a;
}
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}

// 平方根を求める。sqrtより精度が高い。
// epsを変えて誤差を調整する。
int main(void) {
  Rapid_pleaseAC_fast;
  llint ans = 0, n = 0, m = 0, count = 0, sum = 0;
  llint k, a = -100, b = -100, d, x;
  bool check = false;
  string ss;
  vector<llint> array, sarrey;
  cin >> x;
  vector<bool> bo(n, true);
  for (a = -200; a < 200; a++) {
    for (b = -200; b < 200; b++) {
      if ((a - b) * (a * a * a * a + a * a * a * b + a * a * b * b +
                     a * b * b * b + b * b * b * b) ==
          x) {
        cout << a << " " << b << endl;
        check = true;
        break;
      }
    }
    if (check == true)
      break;
  }

  please AC;
}


Error: TLE

Fixed submission:

#include <algorithm> //辞書順=next_permutation
#include <cmath>
#include <complex>
#include <iomanip>
#include <iostream>
#include <locale>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string.h>
#include <string> //char 小文字のほうが32大きい
#include <time.h>
#include <utility> //swap=数値交換
#include <vector>  //s1.erase(n)=文字列s1の、n文字目以降削除

#define rt "\\n"
#define rep(i, n) for (int i = 0; i < n; i++)
#define rop(i, n) for (int i = 1; i <= n; i++)
#define drep(i, n) for (int i = n - 1; 0 <= i; i--)
#define drop(i, n) for (int i = n; 0 < i; i--)
#define yes(ans)                                                               \\
  if (ans)                                                                     \\
    cout << "yes" << rt;                                                       \\
  else                                                                         \\
    cout << "no" << rt;
#define Yes(ans)                                                               \\
  if (ans)                                                                     \\
    cout << "Yes" << rt;                                                       \\
  else                                                                         \\
    cout << "No" << rt;
#define YES(ans)                                                               \\
  if (ans)                                                                     \\
    cout << "YES" << rt;                                                       \\
  else                                                                         \\
    cout << "NO" << rt;
#define sec(a, b, ans)                                                         \\
  if (ans)                                                                     \\
    cout << a << rt;                                                           \\
  else                                                                         \\
    cout << b << rt;
#define vcin(s, n) rep(i, n) cin >> s[i]; // vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(), s.end())  // 標準=昇順
#define reve(s) reverse(s.begin(), s.end())
#define asas int ans = 0
#define llcncn llint cnt = 0
#define llasas llint ans = 0
#define str string
#define please return
#define AC 0
#define ic_a                                                                   \\
  int a;                                                                       \\
  cin >> a;
#define ic_b                                                                   \\
  int b;                                                                       \\
  cin >> b;
#define ic_s                                                                   \\
  string s;                                                                    \\
  cin >> s;
#define Rapid_pleaseAC_fast                                                    \\
  cin.tie(0);                                                                  \\
  ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000
using ll = long long;
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差
long long GCD(long long a, long long b) {
  if (b == 0)
    return a;
  else
    return GCD(b, a % b);
}

long long LCM(long long a, long long b) { return a * b / GCD(a, b); }

unsigned GetDigit(unsigned num) { return std::to_string(num).length(); }

int tow(int n) { // 2のn乗
  if (n == 0)
    return 1;
  int x = tow(n / 2);
  x *= x;
  if (n % 2 == 1)
    x *= 2;
  return x; //@domino
}

int keta(int n) {
  int sum = 0;
  while (n != 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum; // Nanashi,tRue,wai
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */
ld mysqrtl(ld x) {
  ld a = sqrtl((double)x); // 近似値
  do {
    a = (a + x / a) / 2.0L;
  } while (fabsl(x - a * a) > eps);
  return a;
}
ll gcd(ll a, ll b) {
  if (b == 0)
    return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}

// 平方根を求める。sqrtより精度が高い。
// epsを変えて誤差を調整する。
int main(void) {
  Rapid_pleaseAC_fast;
  llint ans = 0, n = 0, m = 0, count = 0, sum = 0;
  llint k, a = -100, b = -100, d, x;
  bool check = false;
  string ss;
  vector<llint> array, sarrey;
  cin >> x;
  vector<bool> bo(n, true);
  while (1) {
    for (b = -100; b < 100; b++) {
      if ((a - b) * (a * a * a * a + a * a * a * b + a * a * b * b +
                     a * b * b * b + b * b * b * b) ==
          x) {
        cout << a << " " << b << endl;
        check = true;
        break;
      }
    }
    a++;
    if (check == true)
      break;
  }

  please AC;
}