結果

問題 No.2178 Payable Magic Items
ユーザー 👑 NachiaNachia
提出日時 2023-01-06 21:48:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 19 ms / 4,000 ms
コード長 1,018 bytes
コンパイル時間 663 ms
コンパイル使用メモリ 79,772 KB
実行使用メモリ 5,488 KB
最終ジャッジ日時 2023-08-21 08:13:29
合計ジャッジ時間 2,111 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 4 ms
4,656 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 4 ms
4,648 KB
testcase_06 AC 5 ms
4,712 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 5 ms
4,700 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 19 ms
5,488 KB
testcase_12 AC 19 ms
5,432 KB
testcase_13 AC 19 ms
5,404 KB
testcase_14 AC 19 ms
5,432 KB
testcase_15 AC 19 ms
5,420 KB
testcase_16 AC 19 ms
5,480 KB
testcase_17 AC 9 ms
4,964 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 6 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 2 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 15 ms
5,160 KB
testcase_25 AC 6 ms
4,696 KB
testcase_26 AC 7 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <atcoder/modint>
using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const i64 INF = 1001001001001001001;

using Modint = atcoder::static_modint<998244353>;

int main(){
    int N, K; cin >> N >> K;
    vector<int> A(N);
    rep(i,N){
        string S; cin >> S;
        int id = 0;
        for(char c : S) id = id * 5 + '4' - c;
        A[i] = id;
    }
    int K5 = 1; rep(i,K) K5 *= 5;
    vector<int> C(K5);
    rep(i,N) C[A[i]]++;
    for(int k5=1; k5<K5; k5*=5) for(int i=0; i<K5; i+=k5*5) for(int q=i; q<i+k5*4; q+=k5) for(int r=q; r<q+k5; r++) C[r+k5] += C[r];
    int ans = 0;
    rep(i,N) if(C[A[i]] > 1) ans++;
    cout << ans << endl;
    return 0;
}



struct ios_do_not_sync{
    ios_do_not_sync(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} ios_do_not_sync_instance;

0