結果

問題 No.437 cwwゲーム
ユーザー kpinkcat
提出日時 2024-05-28 00:38:29
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 649 bytes
コンパイル時間 2,179 ms
コンパイル使用メモリ 192,312 KB
最終ジャッジ日時 2025-02-21 16:58:48
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
using namespace std;

string n;

int cww(int num){
	int sum1 = 0, t = 0;
	for (int i = 0; i < n.size()-2; i++){
		if (n[i] == '0' || num>>i&1) continue;
		for (int j = i+1; j < n.size()-1; j++){
			if (n[i] == n[j] || num>>j&1) continue;
			for (int k = j+1; k < n.size(); k++){
				if (n[j] != n[k] || num>>k&1) continue;
				t = ((n[i] - '0')*100 + (n[j]- '0')*10 + (n[k]- '0') + cww(num^(1<<i)^(1<<j)^(1<<k)));
				sum1 = max(sum1, t);
			}
		}
		
	}
	return sum1;
}

int main(){
	cin >> n;
	
	cout << cww(0) << endl;
}
0