結果

問題 No.632 穴埋め門松列
ユーザー pirozhkipirozhki
提出日時 2018-06-02 12:09:20
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 678 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 58,792 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 21:32:03
合計ジャッジ時間 1,023 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:36:7: warning: ‘q’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  c[q] = 1;
  ~~~~~^~~

ソースコード

diff #

#include <iostream>
#include <algorithm>

using namespace std;

template<typename T>
inline int Max(T arr[]) {
	return distance(arr, max_element(arr, arr + 3));
}

template<typename T>
inline int Min(T arr[]) {
	return distance(arr, min_element(arr, arr + 3));
}

inline int ctoi(const char& c) {
	return c - '0';
}

int main() {
	char c[3];
	int q;

	cin >> c[0] >> c[1] >> c[2];

	for (int i = 0; i < sizeof(c);i++) {
		if (c[i] != '?') {
			c[i] = ctoi(c[i]);
		}
		else {
			q = i;
		}
	}

	string ans;
	c[q] = 1;
	if (Max(c) == 1 || Min(c) == 1) {
		ans.append("1");
	}
	c[q] = 4;
	if (Max(c) == 1 || Min(c) == 1) {
		ans.append("4");
	}
	cout << ans << endl;

	return 0;
}
0