結果

問題 No.164 ちっちゃくないよ!!
コンテスト
ユーザー umaumax
提出日時 2017-05-07 20:10:36
言語 C++11(廃止可能性あり)
(gcc 15.2.0 + boost 1.89.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 782 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 675 ms
コンパイル使用メモリ 55,236 KB
最終ジャッジ日時 2025-12-30 23:25:03
合計ジャッジ時間 1,638 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp: In lambda function:
main.cpp:28:17: error: ‘uint64_t’ was not declared in this scope
   28 |                 uint64_t sum               = 0;
      |                 ^~~~~~~~
main.cpp:3:1: note: ‘uint64_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
    2 | #include <iostream>
  +++ |+#include <cstdint>
    3 | 
main.cpp:29:36: error: ‘sum’ was not declared in this scope
   29 |                 for (auto&& c : s) sum = sum * base + c2v(c);
      |                                    ^~~
main.cpp:30:24: error: ‘sum’ was not declared in this scope
   30 |                 return sum;
      |                        ^~~
main.cpp: In function ‘int main(int, const char**)’:
main.cpp:32:9: error: ‘uint64_t’ was not declared in this scope
   32 |         uint64_t RET[N];
      |         ^~~~~~~~
main.cpp:32:9: note: ‘uint64_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
main.cpp:33:37: error: ‘RET’ was not declared in this scope
   33 |         for (int i = 0; i < N; i++) RET[i] = conv(V[i], bases[i]);
      |                                     ^~~
main.cpp:35:14: error: ‘RET’ was not declared in this scope
   35 |         sort(RET, &RET[N]);
      |              ^~~

ソースコード

diff #
raw source code

#include <algorithm>
#include <iostream>

using namespace std;

int main(int argc, const char* argv[])
{
	int N;
	cin >> N;
	string V[N];
	int bases[N];
	for (auto&& v : V) cin >> v;

	auto c2v = [](char c) {
		int v						= 0;
		if ('0' <= c && c <= '9') v = c - '0';
		if ('A' <= c && c <= 'Z') v = 10 + c - 'A';
		return v;
	};
	auto s2base = [&](string s) {
		int maxval				  = 0;
		for (auto&& c : s) maxval = max(c2v(c), maxval);
		return maxval + 1;
	};
	for (int i = 0; i < N; i++) bases[i] = s2base(V[i]);

	auto conv = [&](string s, int base) {
		uint64_t sum		   = 0;
		for (auto&& c : s) sum = sum * base + c2v(c);
		return sum;
	};
	uint64_t RET[N];
	for (int i = 0; i < N; i++) RET[i] = conv(V[i], bases[i]);

	sort(RET, &RET[N]);
	cout << RET[0] << endl;
	return 0;
}
0