結果

問題 No.2593 Reorder and Mod 120
ユーザー t98slider
提出日時 2023-12-21 22:07:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 802 bytes
コンパイル時間 1,922 ms
コンパイル使用メモリ 195,992 KB
最終ジャッジ日時 2025-02-18 13:07:12
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 21 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, sumv = 0, v;
    string s;
    cin >> n >> s;
    array<int, 10> cnt{};
    vector<bool> used(120);
    for(auto &&c : s){
        v = c - '0';
        cnt[v]++;
        sumv += v;
    }
    sumv *= 40;
    for(int i = 0; i < 10; i++){
        if(cnt[i] == 0) continue;
        cnt[i]--;
        for(int j = 0; j < 10; j++){
            if(cnt[j] == 0) continue;
            cnt[j]--;
            for(int k = 0; k < 10; k++){
                if(cnt[k] == 0) continue;
                used[(sumv - 40 * (i + j + k) + 100 * i + 10 * j + k) % 120] = true;
            }
            cnt[j]++;
        }
        cnt[i]++;
    }
    cout << count(used.begin(), used.end(), true) << '\n';
}
0