結果

問題 No.170 スワップ文字列(Easy)
ユーザー 0w1
提出日時 2016-11-20 14:00:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 526 bytes
コンパイル時間 1,756 ms
コンパイル使用メモリ 170,760 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 00:45:18
合計ジャッジ時間 2,596 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

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

signed main(){
  string S; cin >> S;
  vector< int > cnt( 256 );
  for( int i = 0; i < S.size(); ++i )
    ++cnt[ S[ i ] ];
  vector< int > fcnt;
  for( int i = 0; i < 256; ++i )
    if( cnt[ i ] > 1 )
      fcnt.emplace_back( cnt[ i ] );
  function< int ( int ) > fact = [ & ]( int x ){ return x == 0 ? 1 : x * fact( x - 1 ); };
  int ans = fact( ( int ) S.size() );
  for( int i = 0; i < fcnt.size(); ++i )
    ans /= fact( fcnt[ i ] );
  cout << ans - 1 << endl;
  return 0;
}
0