結果

問題 No.164 ちっちゃくないよ!!
ユーザー なおなお
提出日時 2015-03-09 23:07:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 820 bytes
コンパイル時間 2,649 ms
コンパイル使用メモリ 146,712 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-03 16:57:33
合計ジャッジ時間 1,984 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 想定解: やるだけ
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename _T> void rc(_T v,_T mn,_T mx){if(v<mn||mx<v){cerr<<"error"<<endl;throw;}}
#define REP(i, n)           for(int(i)=0;(i)<(n);++(i))

int c2n(char c){return(c>='0'&&c<='9'?c-'0':c>='A'&&c<='Z'?c-'A'+10:c>='a'&&c<='z'?c-'a'+10:throw);}

ll solve(const string &s){
    vector<int> v;
    int b = 0;
    for(auto c : s){
        int n = c2n(c);
        v.push_back(n); b = max(b,n+1);
    }
    ll res = 0;
    for(auto n : v) res = (res * b + n);
    return res;
}

int main(){
    int N; cin >> N; rc(N, 1, 1000);
    ll minv = LLONG_MAX;
    REP(i,N){
        string s; cin >> s; rc(int(s.size()), 1, 12);
        minv = min(minv, solve(s));
    }
    cout << minv << endl;
    string s; if(cin >> s) throw;
}
0