結果

問題 No.437 cwwゲーム
ユーザー olpheolphe
提出日時 2016-11-14 02:30:54
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,659 bytes
コンパイル時間 634 ms
コンパイル使用メモリ 59,828 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-12 08:39:36
合計ジャッジ時間 1,659 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 2 ms
5,248 KB
testcase_03 AC 2 ms
5,248 KB
testcase_04 AC 1 ms
5,248 KB
testcase_05 AC 2 ms
5,248 KB
testcase_06 AC 2 ms
5,248 KB
testcase_07 AC 2 ms
5,248 KB
testcase_08 AC 2 ms
5,248 KB
testcase_09 AC 2 ms
5,248 KB
testcase_10 AC 2 ms
5,248 KB
testcase_11 AC 1 ms
5,248 KB
testcase_12 AC 2 ms
5,248 KB
testcase_13 AC 1 ms
5,248 KB
testcase_14 AC 2 ms
5,248 KB
testcase_15 AC 2 ms
5,248 KB
testcase_16 AC 2 ms
5,248 KB
testcase_17 AC 1 ms
5,248 KB
testcase_18 AC 2 ms
5,248 KB
testcase_19 AC 2 ms
5,248 KB
testcase_20 AC 2 ms
5,248 KB
testcase_21 AC 1 ms
5,248 KB
testcase_22 AC 2 ms
5,248 KB
testcase_23 AC 1 ms
5,248 KB
testcase_24 AC 1 ms
5,248 KB
testcase_25 AC 2 ms
5,248 KB
testcase_26 AC 1 ms
5,248 KB
testcase_27 AC 1 ms
5,248 KB
testcase_28 AC 2 ms
5,248 KB
testcase_29 AC 2 ms
5,248 KB
testcase_30 AC 1 ms
5,248 KB
testcase_31 AC 2 ms
5,248 KB
testcase_32 AC 2 ms
5,248 KB
testcase_33 AC 2 ms
5,248 KB
testcase_34 AC 2 ms
5,248 KB
testcase_35 AC 2 ms
5,248 KB
testcase_36 AC 1 ms
5,248 KB
testcase_37 AC 1 ms
5,248 KB
testcase_38 AC 2 ms
5,248 KB
testcase_39 AC 2 ms
5,248 KB
testcase_40 AC 2 ms
5,248 KB
testcase_41 AC 2 ms
5,248 KB
testcase_42 AC 1 ms
5,248 KB
testcase_43 AC 2 ms
5,248 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:37: warning: NULL used in arithmetic [-Wpointer-arith]
   10 |         for (int i = 0; num[i+2] != NULL; i++) {
      |                                     ^~~~
main.cpp:11:49: warning: NULL used in arithmetic [-Wpointer-arith]
   11 |                 for (int j = i + 1; num[j+1] != NULL; j++) {
      |                                                 ^~~~
main.cpp:13:63: warning: NULL used in arithmetic [-Wpointer-arith]
   13 |                                 for (int k = j + 1; num[k] != NULL; k++) {
      |                                                               ^~~~
main.cpp:17:83: warning: NULL used in arithmetic [-Wpointer-arith]
   17 |                                                 for (int l = i + 1; num[l + 2] != NULL; l++) {
      |                                                                                   ^~~~
main.cpp:19:99: warning: NULL used in arithmetic [-Wpointer-arith]
   19 |                                                                 for (int m = l + 1; num[m + 1] != NULL; m++) {
      |                                                                                                   ^~~~
main.cpp:21:111: warning: NULL used in arithmetic [-Wpointer-arith]
   21 |                                                                                 for (int n = m + 1; num[n] != NULL; n++) {
      |                                                                                                               ^~~~
main.cpp:25:131: warning: NULL used in arithmetic [-Wpointer-arith]
   25 |                                                                                                 for (int o = l + 1; num[o + 2] != NULL; o++) {
      |                                                                                                                                   ^~~~
main.cpp:27:147: warning: NULL used in arithmetic [-Wpointer-arith]
   27 |                                            

ソースコード

diff #

#include "iostream"
using namespace std;

char num[20];
int ans = 0;
int box[4] = {};

int main() {
	cin >> num;
	for (int i = 0; num[i+2] != NULL; i++) {
		for (int j = i + 1; num[j+1] != NULL; j++) {
			if (num[i] != num[j]&&num[i]!='0') {
				for (int k = j + 1; num[k] != NULL; k++) {
					if (num[j] == num[k]) {
						box[0] = (num[i] - '0') * 100 + (num[j] - '0') * 10 + num[k] - '0';
						if (ans < box[0])ans = box[0];
						for (int l = i + 1; num[l + 2] != NULL; l++) {
							if (l!=i&&l!=j&&l!=k) {
								for (int m = l + 1; num[m + 1] != NULL; m++) {
									if (num[l] != num[m]&&m!=i&&m!=j&&m!=k&&num[l] != '0') {
										for (int n = m + 1; num[n] != NULL; n++) {
											if (num[m] == num[n] && n != i&&n != j&&n != k) {
												box[1] = box[0] + (num[l] - '0') * 100 + (num[m] - '0') * 10 + num[n] - '0';
												if (ans < box[1])ans = box[1];
												for (int o = l + 1; num[o + 2] != NULL; o++) {
													if (o!=i&&o!=j&&o!=k&&o!=l&&o!=m&&o!=n&&num[o] != '0') {
														for (int p = o + 1; num[p + 1] != NULL; p++) {
															if (num[o] != num[p]&& p != i&&p != j&&p != k&&p != l&&p != m&&p != n) {
																for (int q = p + 1; num[q] != NULL; q++) {
																	if (num[p] == num[q]&& q != i&&q != j&&q != k&&q != l&&q != m&&q != n) {
																		box[2] = box[1] + (num[o] - '0') * 100 + (num[p] - '0') * 10 + num[q] - '0';
																		if (ans < box[2])ans = box[2];
																		for (int r = o + 1; num[r + 2] != NULL; r++) {
																			if (r != i&&r != j&&r != k&&r != l&&r != m&&r != n&&r != o&&r != p&&r != q&&num[r] != '0') {
																				for (int s = r + 1; num[s+1] != NULL; s++) {
																					if (num[r] != num[s]&& s != i&&s != j&&s != k&&s != l&&s != m&&s != n&&s != o&&s != p&&s != q) {
																						for (int t = s + 1; num[t] != NULL; t++) {
																							if (num[s] == num[t]&& t != i&&t != j&&t != k&&t != l&&t != m&&t != n&&t != o&&t != p&&t != q) {
																								box[3] = box[2] + (num[r] - '0') * 100 + (num[s] - '0') * 10 + num[t] - '0';
																								if (ans < box[3])ans = box[3];
																							}
																						}
																					}
																				}
																			}
																		}
																	}
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
						if (box[3] > ans)ans = box[3]; 
						if (box[2] > ans)ans = box[2]; 
						if (box[1] > ans)ans = box[1]; 
						if (box[0] > ans)ans = box[0]; 

					}
				}
			}
		}
	}
	cout << ans<<"\n";
	return 0;
}
0