結果

問題 No.2593 Reorder and Mod 120
ユーザー ochiaigawaochiaigawa
提出日時 2023-12-22 18:35:06
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 843 bytes
コンパイル時間 2,212 ms
コンパイル使用メモリ 207,280 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-22 18:35:09
合計ジャッジ時間 3,171 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,676 KB
testcase_01 AC 3 ms
6,676 KB
testcase_02 AC 3 ms
6,676 KB
testcase_03 AC 3 ms
6,676 KB
testcase_04 AC 3 ms
6,676 KB
testcase_05 AC 3 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 WA -
testcase_08 AC 3 ms
6,676 KB
testcase_09 AC 3 ms
6,676 KB
testcase_10 WA -
testcase_11 AC 4 ms
6,676 KB
testcase_12 AC 3 ms
6,676 KB
testcase_13 AC 5 ms
6,676 KB
testcase_14 AC 4 ms
6,676 KB
testcase_15 AC 4 ms
6,676 KB
testcase_16 AC 3 ms
6,676 KB
testcase_17 AC 3 ms
6,676 KB
testcase_18 AC 3 ms
6,676 KB
testcase_19 AC 4 ms
6,676 KB
testcase_20 AC 5 ms
6,676 KB
testcase_21 AC 5 ms
6,676 KB
testcase_22 AC 5 ms
6,676 KB
testcase_23 AC 4 ms
6,676 KB
testcase_24 WA -
testcase_25 AC 4 ms
6,676 KB
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
random_device rnd;
mt19937 mt(rnd());
int main() {
  cin.tie(0); cout.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  string S;
  cin >> S;
  int mod3 = 0;
  vector<int> cnt(10, 0);
  for(char c : S) {
    cnt[c - '0']++;
    mod3 = (mod3 + c - '0') % 3;
  }
  if(mod3 == 0) {
    mod3 += 3;
  }
  vector<bool> can(120, false);
  while(mod3 < 120000) {
    int tmp = mod3;
    vector<int> c(10, 0);
    while(tmp > 0) {
      c[tmp % 10]++;
      tmp /= 10;
    }
    bool fn = true;
    for(int i = 0; i < 10; i++) {
      if(c[i] > cnt[i]) {
        fn = false;
      }
    }
    if(fn) {
      can[mod3 % 120] = true;
    }
    mod3 += 3;
  }
  cout << accumulate(can.begin(), can.end(), 0) << '\n';
  return 0;
}
0