結果

問題 No.1439 Let's Compare!!!!
ユーザー ninoinuininoinui
提出日時 2021-03-26 21:55:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,075 bytes
コンパイル時間 7,616 ms
コンパイル使用メモリ 448,588 KB
実行使用メモリ 12,308 KB
最終ジャッジ日時 2024-05-06 15:25:22
合計ジャッジ時間 12,649 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 402 ms
5,376 KB
testcase_08 AC 407 ms
5,376 KB
testcase_09 AC 27 ms
5,376 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC diagnostic warning "-Wextra"
#pragma GCC diagnostic warning "-Wshadow"
#include <bits/stdc++.h>
using namespace std;

#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using namespace boost::multiprecision;

using bint = cpp_int;
using bdec = cpp_dec_float_100;
// using bdec = number<cpp_dec_float<10000>>;

template <class A, class B> bool cmin(A& a, B b) { return a > b && (a = b, true); }
template <class A, class B> bool cmax(A& a, B b) { return a < b && (a = b, true); }
template <class A, class B> ostream& operator<<(ostream& os, pair<A, B>& p) { return os << '(' << p.first << ", " << p.second << ')'; }
static bool debug = false;
void dump() {}
template <class A, class... B> void dump(A&& a, B&&... b) { if (debug) cout << a << (sizeof...(b) ? ' ' : '\n'), dump(b...); }
template <class A> void dump1D(A& a) { if (debug) for (auto i = a.begin(); i != a.end(); i++) cout << *i << (next(i) != a.end() ? ' ' : '\n'); }
template <class A> void dump2D(A& a) { if (debug) for (auto i = a.begin(); i != a.end(); i++) dump1D(*i), cout << (next(i) != a.end() ? "" : "\n"); }

signed main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  // debug = true;

  int N;
  cin >> N;
  string S, T;
  cin >> S >> T;
  int Q;
  cin >> Q;
  vector<tuple<char, int, int>> V(Q);
  for (int i = 0; i < Q; i++) {
    char a;
    int b, c;
    cin >> a >> b >> c;
    V.at(i) = {a, b, c};
  }

  while (S.front() == '0') S.erase(S.begin());
  if ((int)S.size() == 0) S = "0";
  while (T.front() == '0') T.erase(T.begin());
  if ((int)T.size() == 0) T = "0";
  
  bint L(S);
  bint R(T);
  
  auto f = [&](auto n, auto a, auto b) {
    bint tmp = pow((bint)10, N - a);
    bint m = n / tmp % 10;
    n -= tmp * m;
    n += tmp * b;
    dump(make_pair("n", n), make_pair("tmp", tmp), make_pair("m", m));
    return n;
  };
  
  for (const auto& [a, b, c] : V) {
    if (a == 'S') L = f(L, b, c);
    else R = f(R, b, c);
    dump(make_pair("L", L), make_pair("R", R));
    cout << ((L > R) ? '>' : (L < R) ? '<' : '=') << '\n';
  }
}
0