結果
| 問題 |
No.437 cwwゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-11-14 02:30:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.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 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
コンパイルメッセージ
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 |
ソースコード
#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;
}