結果

問題 No.164 ちっちゃくないよ!!
ユーザー MayimgMayimg
提出日時 2019-01-08 23:09:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 750 bytes
コンパイル時間 1,865 ms
コンパイル使用メモリ 166,712 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-15 16:49:49
合計ジャッジ時間 2,084 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:27:40: 警告: ‘tmp’ may be used uninitialized [-Wmaybe-uninitialized]
   27 |                         base = max(tmp + 1, base);
      |                                    ~~~~^~~
main.cpp:19:29: 備考: ‘tmp’ はここで定義されています
   19 |                         int tmp;
      |                             ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	string digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	int n;
	cin >> n;
	long long ans = LLONG_MAX;
	while(n--) {
		string s;
		cin >> s;
		int len = s.length();
		int base = 0;
		vector<int> v(len);
		for(int i = 0; i < len; i++) {
			int tmp;
			for(int j = 0; j < 36; j++) {
				if(s[i] == digits[j]) {
					tmp = j;
					v[i] = j;
					break;
				}
			}
			base = max(tmp + 1, base);
		}
		reverse(v.begin(), v.end());
		long long num = 0;
		for(int i = 0; i < len; i++) {
			long long t = 1;
			for(int j = 0; j < i; j++) {
				t *= base;
			}
			num += 1LL * v[i] * t;
		}
		ans = min(num, ans);
	}
	cout << ans << endl;
	return 0;
}
0