結果
| 問題 |
No.437 cwwゲーム
|
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-08-27 22:27:06 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 882 bytes |
| コンパイル時間 | 2,099 ms |
| コンパイル使用メモリ | 193,008 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2025-08-27 22:27:09 |
| 合計ジャッジ時間 | 3,165 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 3 |
| other | WA * 41 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | freopen("abb.in","r",stdin); freopen("abb.out","W",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~
main.cpp:7:41: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | freopen("abb.in","r",stdin); freopen("abb.out","W",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>
using namespace std;
const int maxn=15;
string in;
int f[1<<maxn+5],a[maxn+5];
int main() {
freopen("abb.in","r",stdin); freopen("abb.out","W",stdout);
ios::sync_with_stdio(false); cin.tie(0);
cin>>in;
for(int i=0;i<in.size();i++) a[i+1]=in[i]-'0';
int len=in.size();
int maxstatus=1<<len-1,ans=0;
for(int s=0;s<maxstatus;s++) {
for(int i=1;i<=len;i++) if(!(s&(1<<i))) {
for(int j=i+1;j<=len;j++) if(!(s&(1<<j))) {
for(int k=j+1;k<=len;k++) if(!(s&(1<<k))) {
if(a[i]&&a[i]!=a[j]&&a[j]==a[k]) {
int snew=((s|(1<<i))|(i<<j))|(1<<k);
f[snew]=max(f[snew],f[s]+a[i]*100+a[j]*10+a[k]);
ans=max(ans,f[snew]);
}
}
}
}
}
cout<<ans;
return 0;
}
vjudge1