結果

問題 No.2030 Googol Strings
ユーザー KKT89KKT89
提出日時 2022-08-05 22:34:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,002 bytes
コンパイル時間 2,111 ms
コンパイル使用メモリ 137,436 KB
実行使用メモリ 8,744 KB
最終ジャッジ日時 2023-10-13 23:56:56
合計ジャッジ時間 12,661 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
7,864 KB
testcase_01 AC 36 ms
4,372 KB
testcase_02 AC 30 ms
4,368 KB
testcase_03 AC 21 ms
4,368 KB
testcase_04 AC 37 ms
4,368 KB
testcase_05 AC 38 ms
4,368 KB
testcase_06 AC 83 ms
5,896 KB
testcase_07 AC 107 ms
7,248 KB
testcase_08 AC 109 ms
7,124 KB
testcase_09 TLE -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
#include <deque>
#include <stack>
#include <sstream>
#include <utility>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <array>
#include <bitset>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
    return (ull)rng() % B;
}
inline double time() {
    return static_cast<long double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9;
}

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int q; cin >> q;
    while(q--){
        string s,t; cin >> s >> t;
        {
            auto r = s, rr = t;
            sort(r.begin(), r.end());
            sort(rr.begin(), rr.end());
            if(r[0] == r.back() and r.back() == rr[0] and rr[0] == rr.back()){
                if(r < rr){
                    cout << "Y" << "\n";
                }
                else{
                    cout << "X" << "\n";
                }
                continue;
            }
        }
        bool f = false;
        auto ti = time();
        for(int i=0,j=0;;){
            if(s[i] > t[j]){
                cout << "X" << "\n";
                f = true;
                break;
            }
            else if(s[i] < t[j]){
                cout << "Y" << "\n";
                f = true;
                break;
            }
            if(time()-ti > 0.02) break;
            i++; j++;
            if(i == s.size()) i = 0;
            if(j == t.size()) j = 0;
        }
        if(f) continue;
        if(s < t){
            cout << "Y" << "\n";
        }
        else{
            cout << "X" << "\n";
        }
    }
}
0