結果
問題 | No.5013 セクスタプル (open) |
ユーザー |
![]() |
提出日時 | 2022-12-29 17:37:31 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 2,000 ms |
コード長 | 3,353 bytes |
コンパイル時間 | 3,685 ms |
実行使用メモリ | 5,452 KB |
スコア | 11,093 |
最終ジャッジ日時 | 2022-12-29 17:38:26 |
合計ジャッジ時間 | 8,479 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
純コード判定しない問題か言語 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 100 |
ソースコード
#include<bits/stdc++.h> using namespace std; #define rep(i,n) for (int i=0;i<(int)(n);i++) #define all(v) v.begin(),v.end() using ll=long long; using pll=pair<ll,ll>; using tll=tuple<ll,ll,ll>; const ll INF=(1ll<<60); template<class T> void chmin(T &a,T b){ if(a>b){ a=b; } } template<class T> void chmax(T &a,T b){ if(a<b){ a=b; } } int to(int i,int j){ return i*6+j; } pair<int,int> back(int x){ return {x/6,x%6}; } int d[36][6]; int cell[36]; int dp[36][6]; int max_cell[36]; int diff(int x){ int p=back(x).first,q=back(x).second; int ret=0; rep(k,6){ int sum=0; bool t=true; rep(j,6){ sum+=dp[to(p,j)][k]; if(dp[to(p,j)][k]==0){ t=false; break; } } if(t) ret+=3+(sum-6); } rep(k,6){ int sum=0; bool t=true; rep(i,6){ sum+=dp[to(i,q)][k]; if(dp[to(i,q)][k]==0){ t=false; break; } } if(t) ret+=3+(sum-6); } return ret; } void modify(int x,int y){ rep(k,6){ swap(dp[x][k],dp[y][k]); } swap(cell[x],cell[y]); } int main(){ mt19937 mt; auto start=chrono::system_clock::now(); vector<vector<pair<int,int>>> cnt(6); rep(i,36){ int x; rep(j,6){ cin >> x; x--; d[i][x]++; } rep(j,6){ cnt[j].emplace_back(d[i][j],i); } } int max_score=0; vector<int> per={0,1,2,3,4,5}; do{ set<int> selected; for(auto &i:per){ sort(all(cnt[i])); reverse(all(cnt[i])); int p=0; for(auto &[a,b]:cnt[i]){ if(selected.find(b)!=selected.end()) continue; cell[to(i,p)]=b; selected.insert(b); p++; if(6<=p) break; } } rep(i,36){ rep(k,6){ dp[i][k]=d[cell[i]][k]; } } int now_score=0; rep(i,6){ rep(k,6){ int sum=0; bool t=true; rep(j,6){ sum+=dp[to(i,j)][k]; if(dp[to(i,j)][k]==0){ t=false; break; } } if(t) now_score+=3+(sum-6); } } rep(j,6){ rep(k,6){ int sum=0; bool t=true; rep(i,6){ sum+=dp[to(i,j)][k]; if(dp[to(i,j)][k]==0){ t=false; break; } } if(t) now_score+=3+(sum-6); } } if(max_score<now_score){ max_score=now_score; rep(i,36){ max_cell[i]=cell[i]; } } }while(next_permutation(all(per))); int pre_score=max_score; rep(i,36){ cell[i]=max_cell[i]; } vector<pair<int,int>> ans(36); rep(i,6){ rep(j,6){ ans[max_cell[to(i,j)]]={i,j}; } } rep(i,36){ cout << ans[i].first+1 << " " << ans[i].second+1 << endl; } }