結果

問題 No.2178 Payable Magic Items
ユーザー _yurimoir_yurimoir
提出日時 2023-01-07 07:43:31
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,274 ms / 4,000 ms
コード長 1,038 bytes
コンパイル時間 3,406 ms
コンパイル使用メモリ 252,728 KB
実行使用メモリ 33,152 KB
最終ジャッジ日時 2023-08-21 08:33:07
合計ジャッジ時間 15,001 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,500 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 577 ms
22,196 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 16 ms
4,436 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 15 ms
4,544 KB
testcase_09 AC 9 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 779 ms
22,960 KB
testcase_12 AC 1,213 ms
33,016 KB
testcase_13 AC 1,269 ms
32,952 KB
testcase_14 AC 1,274 ms
33,152 KB
testcase_15 AC 1,231 ms
32,956 KB
testcase_16 AC 1,240 ms
32,952 KB
testcase_17 AC 955 ms
25,640 KB
testcase_18 AC 5 ms
4,380 KB
testcase_19 AC 167 ms
9,920 KB
testcase_20 AC 3 ms
4,376 KB
testcase_21 AC 5 ms
4,376 KB
testcase_22 AC 5 ms
4,376 KB
testcase_23 AC 3 ms
4,376 KB
testcase_24 AC 1,090 ms
29,672 KB
testcase_25 AC 876 ms
23,532 KB
testcase_26 AC 190 ms
10,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main(){
    int n,k;
    cin>>n>>k;
    int tank[n];
    set<int> st;
    for(int i=0;i<n;i++){
        string s;
        cin>>s;
        tank[i]=stoi(s);
        st.insert(tank[i]);
    }
    int ans=0;
    set<int> used;
    for(int i=0;i<n;i++){
        if(used.find(tank[i])!=used.end())continue;
        queue<int> que;
        que.push(tank[i]);
        // used.insert(tank[i]);
        // map<int,int> dist;
        // dist[tank[i]]=0;
        while(!que.empty()){
            int px=que.front();
            int v=px;
            px*=10;
            que.pop();
            for(int j=0;j<k;j++){
                px/=10;
                if(px%10>0){
                    int nx=v-pow(10,j);
                    if(used.find(nx)!=used.end())continue;
                    if(st.find(nx)!=st.end())ans++;
                    used.insert(nx);
                    que.push(nx);
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}
0