結果
問題 | No.164 ちっちゃくないよ!! |
ユーザー |
![]() |
提出日時 | 2015-05-25 11:22:43 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,756 bytes |
コンパイル時間 | 768 ms |
コンパイル使用メモリ | 96,268 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 14:15:50 |
合計ジャッジ時間 | 1,236 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 11 |
ソースコード
#include <iostream> #include <vector> #include <string> #include <stack> #include <queue> #include <deque> #include <set> #include <map> #include <algorithm> // require sort next_permutation count __gcd reverse etc. #include <cstdlib> // require abs exit atof atoi #include <cstdio> // require scanf printf #include <functional> #include <numeric> // require accumulate #include <cmath> // require fabs #include <climits> #include <limits> #include <cfloat> #include <iomanip> // require setw #include <sstream> // require stringstream #include <cstring> // require memset #include <cctype> // require tolower, toupper #include <fstream> // require freopen #include <ctime> // require srand #define rep(i,n) for(int i=0;i<(n);i++) #define ALL(A) A.begin(), A.end() using namespace std; typedef long long ll; typedef pair<int, int> P; const char order[36] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; map<char,int> digits; ll todigit (string s, int d ){ ll res = 0LL; ll d1 = 1LL; for (int i = s.length() - 1; i >= 0; i-- ){ res += digits[s[i]]*d1; d1 *= d; } // end for return res; } int main() { digits.clear(); rep (i, sizeof(order)/sizeof(order[0] ) ) digits[order[i]] = i; ios_base::sync_with_stdio(0); int N; cin >> N; ll res; rep (i, N ){ string s; cin >> s; int max_digits = 0; rep (j, s.length() ){ max_digits = max (max_digits, digits[s[j]]+1 ); } // end rep ll curr = todigit (s, max_digits ); res = (i == 0 ? curr : min (res, curr ) ); // cerr << s <<'(' << max_digits << ')' << ' ' << curr << endl; } // end rep cout << res << endl; return 0; }