結果

問題 No.164 ちっちゃくないよ!!
ユーザー ty70ty70
提出日時 2015-05-25 11:22:43
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,756 bytes
コンパイル時間 836 ms
コンパイル使用メモリ 96,360 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-21 15:25:23
合計ジャッジ時間 1,387 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
}
0