結果
| 問題 |
No.437 cwwゲーム
|
| コンテスト | |
| ユーザー |
aaa
|
| 提出日時 | 2018-09-26 19:27:04 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,358 bytes |
| コンパイル時間 | 1,417 ms |
| コンパイル使用メモリ | 104,596 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-11 23:38:57 |
| 合計ジャッジ時間 | 2,299 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 31 WA * 10 |
ソースコード
#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;
}
aaa