結果

問題 No.2734 Addition and Multiplication in yukicoder (Hard)
ユーザー GOTKAKOGOTKAKO
提出日時 2024-04-19 21:52:39
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 701 ms / 5,000 ms
コード長 1,915 bytes
コンパイル時間 2,675 ms
コンパイル使用メモリ 204,348 KB
実行使用メモリ 18,816 KB
最終ジャッジ日時 2024-04-19 21:53:09
合計ジャッジ時間 13,104 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 271 ms
9,344 KB
testcase_18 AC 293 ms
9,344 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 654 ms
18,816 KB
testcase_23 AC 626 ms
18,816 KB
testcase_24 AC 681 ms
18,816 KB
testcase_25 AC 651 ms
18,816 KB
testcase_26 AC 701 ms
18,816 KB
testcase_27 AC 554 ms
16,128 KB
testcase_28 AC 652 ms
17,920 KB
testcase_29 AC 641 ms
17,664 KB
testcase_30 AC 486 ms
14,456 KB
testcase_31 AC 644 ms
18,304 KB
testcase_32 AC 570 ms
16,512 KB
testcase_33 AC 327 ms
11,012 KB
testcase_34 AC 467 ms
13,696 KB
testcase_35 AC 197 ms
7,992 KB
testcase_36 AC 206 ms
7,936 KB
testcase_37 AC 393 ms
12,640 KB
testcase_38 AC 351 ms
11,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

long long mod = 998244353;
//入力が必ずmod未満の時に使う.
struct mint{
    long long v = 0;
    mint(){} mint(int a){v = a;} mint(long long a){v = a;} mint(unsigned long long a){v = a;}
    long long val(){return v;}
    void modu(){v %= mod;}
 
    mint repeat2mint(long long a,long long b){
        mint ret = 1,p = a;
        while(b){if(b&1) ret *= p; p *= p; b >>= 1;}
        return ret;
    };
 
    mint operator-(){return mint(0)-mint(v);}
    mint operator+(mint b){return (v+b.v)%mod;}
    mint operator-(mint b){return (v-b.v+mod)%mod;}
    mint operator*(mint b){return v*b.v%mod;}
    mint operator/(mint b){
        if(b.v == 0) assert(false);
        return v*(repeat2mint(b.v,mod-2)).v%mod;
    }
 
    void operator+=(mint b){v = (v+b.v)%mod;}
    void operator-=(mint b){v = (v-b.v+mod)%mod;}
    void operator*=(mint b){v = v*b.v%mod;}
    void operator/=(mint b){
    if(b.v == 0) assert(false);
        v = v*repeat2mint(b.v,mod-2).v%mod;
    }
 
    void operator++(int){v = (v+1)%mod; return;}
    void operator--(int){v = (v-1+mod)%mod; return;}
    bool operator==(mint b){return v == b.v;}
    bool operator!=(mint b){return v != b.v;}
    bool operator>(mint b) {return v >  b.v;}
    bool operator>=(mint b){return v >= b.v;}
    bool operator<(mint b) {return v <  b.v;}
    bool operator<=(mint b){return v <= b.v;}
 
    mint pow(long long x){return repeat2mint(v,x);}
    mint inv(){return mint(1)/v;}
};			

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int N; cin >> N;
    vector<string> S(N);
    for(auto &s : S) cin >> s;

    auto f = [](string &s,string &t) -> bool {
        string st = s+t,ts = t+s;
        return st < ts;
    };
    sort(S.begin(),S.end(),f);

    mint answer = 0;
    for(auto s : S) for(auto c : s) answer = answer*10+c-'0';
    cout << answer.v << endl;
}
0