Linux tsuru-no-tsurugi 5.15.0-186-generic #196-Ubuntu SMP Sat Jun 20 16:09:34 UTC 2026 x86_64
Apache/2.4.52 (Ubuntu)
Server IP : 192.168.0.18 & Your IP : 216.73.217.105
Domains :
Cant Read [ /etc/named.conf ]
User : www-data
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
var /
www /
submit2 /
115014 /
Delete
Unzip
Name
Size
Permission
Date
Action
a.cpp
2.25
KB
-rwxr-x---
2024-08-28 22:35
cerror.txt
0
B
-rwxr-x---
2024-08-28 22:35
error.txt
0
B
-rwxr-x---
2024-08-28 22:35
submit_info.txt
350
B
-rwxr-x---
2024-08-28 22:35
Save
Rename
#include <bits/stdc++.h> using namespace std; //#include <atcoder/all> //using namespace atcoder; using ll = long long; using VI = vector<int>; using VVI = vector<VI>; using VL = vector<ll>; using VVL = vector<VL>; using VD = vector<double>; using VVD = vector<VD>; using VS = vector<string>; using P = pair<ll,ll>; using VP = vector<P>; #define rep(i, n) for (ll i = 0; i < ll(n); i++) #define out(x) cout << x << endl #define dout(x) cout << fixed << setprecision(10) << x << endl #define all(a) (a).begin(),(a).end() #define rall(a) (a).rbegin(),(a).rend() #define sz(x) (int)(x.size()) #define re0 return 0 #define pcnt __builtin_popcountll template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } constexpr int inf = 1e9; constexpr ll INF = 1e18; //using mint = modint1000000007; //using mint = modint998244353; int di[4] = {1,0,-1,0}; int dj[4] = {0,1,0,-1}; ll dp[1<<16][52][52]; int main(){ ll n; cin >> n; VS s(n); rep(i,n) cin >> s[i]; ll n2 = 1<<n; rep(i,n2)rep(j,52)rep(k,52) dp[i][j][k] = -INF; rep(j,52) dp[0][j][j] = 0; ll ans = 0; /* rep(bit,n2)rep(j,26)rep(k,26){ rep(i,n){ if(bit>>i&1) continue; if(s[i].back()-'a' == j){ chmax(dp[bit|(1<<i)][s[i][0]-'a'][k],dp[bit][j][k]+sz(s[i])); } if(s[i][0]-'a' == k){ chmax(dp[bit|(1<<i)][j][s[i].back()-'a'],dp[bit][j][k]+sz(s[i])); } } chmax(ans,dp[bit][j][k]); } */ auto f = [](char c){ if('a' <= c && c <= 'z'){ return c-'a'; } else { return 26+(c-'A'); } }; rep(bit,n2){ rep(i,n){ if(bit>>i&1) continue; rep(k,52){ ll j = f(s[i].back()); chmax(dp[bit|(1<<i)][f(s[i][0])][k],dp[bit][j][k]+sz(s[i])); } rep(j,52){ ll k = f(s[i][0]); chmax(dp[bit|(1<<i)][j][f(s[i].back())],dp[bit][j][k]+sz(s[i])); } } rep(j,26)rep(k,26) chmax(ans,dp[bit][j][k]); } out(ans); }