結果
問題 | No.2030 Googol Strings |
ユーザー |
|
提出日時 | 2022-08-06 02:04:57 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 906 bytes |
コンパイル時間 | 2,172 ms |
コンパイル使用メモリ | 197,548 KB |
最終ジャッジ日時 | 2025-01-30 18:56:24 |
ジャッジサーバーID (参考情報) |
judge3 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | RE * 1 |
other | AC * 6 WA * 4 RE * 6 |
ソースコード
#include <bits/stdc++.h> using namespace std; int solve(string& s, string& t) { if (s == t) { return 0; } if (s.size() > t.size()) { return solve(t, s) * -1; } for (int i = 0; i < t.size() / s.size(); i ++) { if (s != t.substr(i * s.size(), s.size())) { return (s > t.substr(i * s.size(), s.size()) ? 1 : -1); } } int l = t.size() % s.size(); t = s.substr(0, l) + s.substr(0, s.size() - l); if (s != t) { return (s > t ? 1 : -1); } t = t.substr(0, l); return solve(t, s); } int main() { int T; cin >> T; for (int t = 0; t < T; t ++) { string x, y; cin >> x >> y; bool lg = x.size() > y.size(); int r = solve(x, y); if (r) { cout << (r > 0 ? "X" : "Y") << endl; } else { cout << (lg ? "X" : "Y") << endl; } } }