結果
| 問題 |
No.632 穴埋め門松列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-06-02 12:09:20 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 678 bytes |
| コンパイル時間 | 423 ms |
| コンパイル使用メモリ | 59,016 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 09:02:36 |
| 合計ジャッジ時間 | 859 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:40:14: warning: ‘q’ may be used uninitialized in this function [-Wmaybe-uninitialized]
40 | c[q] = 4;
| ~~~~~^~~
ソースコード
#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;
}