結果

問題 No.2030 Googol Strings
ユーザー polyesterpolyester
提出日時 2022-08-05 23:14:12
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 1,388 bytes
コンパイル時間 2,477 ms
コンパイル使用メモリ 107,196 KB
実行使用メモリ 9,020 KB
最終ジャッジ日時 2023-10-14 01:03:12
合計ジャッジ時間 3,422 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
4,368 KB
testcase_01 AC 18 ms
4,372 KB
testcase_02 AC 15 ms
4,372 KB
testcase_03 AC 2 ms
4,368 KB
testcase_04 AC 42 ms
4,372 KB
testcase_05 AC 22 ms
4,368 KB
testcase_06 AC 49 ms
9,020 KB
testcase_07 AC 41 ms
7,084 KB
testcase_08 AC 42 ms
7,036 KB
testcase_09 AC 30 ms
4,372 KB
testcase_10 AC 31 ms
4,368 KB
testcase_11 AC 31 ms
4,368 KB
testcase_12 AC 51 ms
4,372 KB
testcase_13 AC 55 ms
4,368 KB
testcase_14 AC 28 ms
4,368 KB
testcase_15 AC 64 ms
4,368 KB
testcase_16 AC 52 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int t;
  cin >> t;
  while(t--) {
    string x, y;
    cin >> x >> y;
    int mini = min(x.size(), y.size());
    int maxi = max(x.size(), y.size());
    bool ok = false;
    for(int i = 0; i < mini; i++) {
      if(x[i] < y[i]) {
        cout << "Y" << endl;
        ok = true;
        break;
      }
      if(x[i] > y[i]) {
        cout << "X" << endl;
        ok = true;
        break;
      }
    }
    if(ok) {
      continue;
    }
    int cnt = 0;
    string tmpX = x, tmpY = y;
    while(tmpX.size() < maxi * 2) {
      tmpX.push_back(x[cnt % x.size()]);
      cnt++;
    }
    cnt = 0;
    while(tmpY.size() < maxi * 2) {
      tmpY.push_back(y[cnt % y.size()]);
      cnt++;
    }
    for(int i = 0; i < maxi * 2; i++) {
      if(tmpX[i] < tmpY[i]) {
        cout << "Y" << endl;
        ok = true;
        break;
      }
      if(tmpX[i] > tmpY[i]) {
        cout << "X" << endl;
        ok = true;
        break;
      }
    }
    if(ok) {
      continue;
    }
    if(x.size() < y.size()) {
      cout << "Y" << endl;
    } else {
      cout << "X" << endl;
    }
  }
  return 0;
}
0