結果
| 問題 |
No.3079 Unite Japanese Prefectures
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2025-03-28 21:58:19 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,264 ms / 4,000 ms |
| コード長 | 992 bytes |
| コンパイル時間 | 5,030 ms |
| コンパイル使用メモリ | 264,744 KB |
| 実行使用メモリ | 49,792 KB |
| 最終ジャッジ日時 | 2025-03-28 21:58:38 |
| 合計ジャッジ時間 | 14,009 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000000
#define Inf64 1000000000000000001LL
map<vector<int>, double> mp;
double solve(vector<int> c){
if(mp.count(c)) return mp[c];
if(c==vector<int>(6,0))return 0;
double ng = 0.0;
double res = 0.0;
rep(i,6){
bool f = false;
for(int j=i;j>=0;j--){
if(c[j]==0)continue;
c[j]--;
res += solve(c);
c[j]++;
f = true;
break;
}
if(!f)ng++;
}
res /= 6-ng;
res += 6.0/(6.0-ng);
return mp[c] = res;
}
int main(){
int n,m;
cin>>n>>m;
vector<vector<int>> t(m);
rep(i,m){
int a,b,c;
cin>>a>>b>>c;
a--,b--,c--;
t[i] = {c,a,b};
}
sort(t.begin(),t.end());
dsu D(n);
vector<int> cnt(6);
rep(i,m){
if(!D.same(t[i][1],t[i][2])){
D.merge(t[i][1],t[i][2]);
cnt[t[i][0]]++;
}
}
cout<<fixed<<setprecision(20)<<solve(cnt)<<endl;
return 0;
}
沙耶花