結果
| 問題 | No.2593 Reorder and Mod 120 | 
| コンテスト | |
| ユーザー |  tnakao0123 | 
| 提出日時 | 2023-12-22 14:10:54 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 3 ms / 2,000 ms | 
| コード長 | 864 bytes | 
| コンパイル時間 | 333 ms | 
| コンパイル使用メモリ | 43,008 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-27 11:24:16 | 
| 合計ジャッジ時間 | 1,243 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 26 | 
ソースコード
/* -*- coding: utf-8 -*-
 *
 * 2593.cc:  No.2593 Reorder and Mod 120 - yukicoder
 */
#include<cstdio>
#include<algorithm>
 
using namespace std;
/* constant */
const int MAX_N = 200000;
const int M = 40;
/* typedef */
/* global variables */
char s[MAX_N + 4];
int cs[10], ds[10], es[M];
/* subroutines */
/* main */
int main() {
  int n;
  scanf("%d%s", &n, s);
  for (int i = 0; i < n; i++) cs[s[i] - '0']++;
  int k, l;
  if (n <= 1) k = 10, l = 1;
  else if (n == 2) k = 100, l = 2;
  else k = 1000, l = 3;
  for (int i = 0; i < k; i++) {
    fill(ds, ds + 10, 0);
    for (int j = 0, p = i; j < l; j++, p /= 10) ds[p % 10]++;
    bool ok = true;
    for (int j = 0; ok && j < 10; j++)
      ok = (ds[j] <= cs[j]);
    if (ok) es[i % M] = 1;
  }
  int cnt = 0;
  for (int i = 0; i < M; i++) cnt += es[i];
  printf("%d\n", cnt);
  
  return 0;
}
            
            
            
        