結果

問題 No.2030 Googol Strings
ユーザー polyesterpolyester
提出日時 2022-08-05 23:08:23
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,351 bytes
コンパイル時間 1,788 ms
コンパイル使用メモリ 108,032 KB
実行使用メモリ 6,992 KB
最終ジャッジ日時 2023-10-14 00:54:43
合計ジャッジ時間 3,588 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 18 ms
4,372 KB
testcase_02 AC 15 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 42 ms
6,992 KB
testcase_08 AC 41 ms
6,948 KB
testcase_09 AC 21 ms
4,368 KB
testcase_10 AC 22 ms
4,372 KB
testcase_11 AC 22 ms
4,376 KB
testcase_12 AC 41 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

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) {
      tmpX.push_back(x[cnt % x.size()]);
      cnt++;
    }
    while(tmpY.size() < maxi) {
      tmpY.push_back(y[cnt % y.size()]);
      cnt++;
    }
    for(int i = 0; i < maxi; 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;
    }
    if(x.size() < y.size()) {
      cout << "Y" << endl;
    } else {
      cout << "X" << endl;
    }
  }
  return 0;
}
0