結果

問題 No.437 cwwゲーム
ユーザー aaaaaa
提出日時 2018-09-26 19:27:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,358 bytes
コンパイル時間 1,140 ms
コンパイル使用メモリ 103,032 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 04:42:25
合計ジャッジ時間 2,334 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 WA -
testcase_08 AC 1 ms
5,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 3 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 WA -
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 1 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 1 ms
5,376 KB
testcase_24 AC 1 ms
5,376 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 1 ms
5,376 KB
testcase_28 AC 2 ms
5,376 KB
testcase_29 AC 2 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 2 ms
5,376 KB
testcase_32 AC 2 ms
5,376 KB
testcase_33 AC 2 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 2 ms
5,376 KB
testcase_39 AC 3 ms
5,376 KB
testcase_40 AC 2 ms
5,376 KB
testcase_41 WA -
testcase_42 AC 2 ms
5,376 KB
testcase_43 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <functional>
#include <map>
#include <iomanip>
#include <math.h> 
#include <stack>
#include <queue>
#include <bitset>
#include <cstdlib>
#include <tuple>
#include <cctype>
#include <ctype.h>
#include <set>

using namespace std;


int main() {
	int  i, j, k;
	string stn;
	//vector<int>list(10, 0);
	vector<bool>flag(1000, false);
	long sum = 0;


	cin >> stn;

	while (true)
	{
		//vector<vector<int>>list(10, vector<int>(1, 0));
		bool flag2 = false;
		char chw1, chw2, chc;
		vector<int>list(10, -1);
		for (i = 0; i < stn.length(); i++) {
			//list[(int)stn[i] - 48]++;
			if (flag[i] == true)continue;
			if ((int)stn[i] - 48 == 0)continue;
			if (list[(int)stn[i] - 48] == -1) {
				list[(int)stn[i] - 48] = i;
			}
		}

		int num;
		for (i = 9; i >= 1; i--) {
			if (list[i] >= 0) {
				num = i;
				vector<int>list2(10, 0);
				vector<vector<int>>list3(10, vector<int>(2));
				for (j = list[i] + 1; j < stn.length(); j++) {
					if (flag[j] == true) continue;
					if (i == (int)stn[j] - 48) continue;

					if (list2[(int)stn[j] - 48] < 2) {
						list2[(int)stn[j] - 48]++;
						if (list2[(int)stn[j] - 48] == 1) {
							list3[(int)stn[j] - 48][0] = j;
						}
						else if (list2[(int)stn[j] - 48] == 2) {
							list3[(int)stn[j] - 48][1] = j;
						}
					}
				}

				for (j = 9; j >= 0; j--) {
					if (list2[j] >= 2) {
						chw1 = (char)j + 48;
						chw2 = (char)j + 48;
						chc = (char)num + 48;
						list2[j] -= 2;
						flag[list3[j][0]] = true;
						flag[list3[j][1]] = true;
						flag[list[i]] = true;
						string str = { chc,chw1,chw2 };
						//cout << "str->" << str << endl;
						sum += stol(str);
						//cout << "sum->" << sum << endl;

						flag2 = true;
						break;
					}
				}
				if (flag2 == true)break;
			}
		}

		if (flag2 == false)break;
	}

	cout << sum << endl;


	/*
	for (i = 0; i < stn.length(); i++) {
		list[(int)stn[i] - 48]++;
	}

	long long sum = 0;

	for (i = 9; i >= 1; i--) {
		char chw1, chw2, chc;
		if (list[i] >= 2) {
			chw1 = (char)list[i] + 48;
			chw2 = (char)list[i] + 48;
			list[i] -= 2;
			for (j = 9; j >= 1; j--) {
				if (list[i] >= 1) {
					chc = (char)list[i] + 48;
					list[i]--;
					string str={ch}
				}
			}
		}
	}*/












	getchar();
	getchar();
	return 0;
}
0