結果

問題 No.632 穴埋め門松列
ユーザー forest3forest3
提出日時 2020-03-13 16:28:56
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 418 bytes
コンパイル時間 1,593 ms
コンパイル使用メモリ 167,800 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-01 23:24:38
合計ジャッジ時間 2,085 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:16:14: warning: 'idx' may be used uninitialized [-Wmaybe-uninitialized]
   16 |         n[idx] = 1;
      |              ^
main.cpp:9:13: note: 'idx' was declared here
    9 |         int idx;
      |             ^~~

ソースコード

diff #

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

int main()
{
	char c[3];
	cin >> c[0] >> c[1] >> c[2];

	int idx;
	vector<int> n( 3 );
	for( int i = 0; i < 3; i++ ) {
		if( c[i] == '?' ) idx = i;
		else n[i] = c[i] - '0';
	}

	n[idx] = 1;
	if( n[0] < n[1] && n[2] < n[1] || n[0] > n[1] && n[2] > n[1] ) cout << 1;
	n[idx] = 4;
	if( n[0] < n[1] && n[2] < n[1] || n[0] > n[1] && n[2] > n[1] ) cout << 4;
	cout << endl;
}
0