結果

問題 No.562 超高速一人かるた small
ユーザー nmnmnmnmnmnmnmnmnmnmnmnmnmnm
提出日時 2017-08-25 23:52:01
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,625 bytes
コンパイル時間 1,027 ms
コンパイル使用メモリ 99,460 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-04-23 16:19:43
合計ジャッジ時間 24,199 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1int;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

ll dp[1<<20];

int main() {
  clr(dp,0);
  ll n;
  cin>>n;
  vector<string> vs;
  rep(i,0,n){
    string s;
    cin>>s;
    vs.pb(s);
  }
  sort(all(vs));
  rep(i,0,1<<n){
    vector<string> v;
    rep(j,0,n){
      if(((i>>j)&1)==0){
        v.pb(vs[j]);
      }
    }
    vector<ll> v1;
    rep(j,0,v.sz){
      ll mx = 1;
      rep(k,0,v.sz){
        if(j==k)continue;
        rep(l,0,min(v[j].sz,v[k].sz)){
          if(v[j][l]==v[k][l]){
            mx = max(mx,l+2);
          }
        }
      }
      v1.pb(mx);
    }
    ll index = 0;
    rep(j,0,n){
      if(((i>>j)&1)==0){
        dp[i|(1<<j)]+=dp[i]+v1[index];
        index++;
      }
    }
  }
  ll d[22];
  clr(d,0);
  rep(i,0,1<<n){
    ll a = 0;
    rep(j,0,n){
      if(((i>>j)&1)==1){
        a++;
      }
    }
    d[a]+=dp[i];
  }
  rep(i,0,n){
    cout << d[i+1] << endl;
  }
  return 0;
}
0