結果
| 問題 |
No.1711 Divide LCM
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2021-10-15 22:46:19 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,816 bytes |
| コンパイル時間 | 5,257 ms |
| コンパイル使用メモリ | 272,292 KB |
| 最終ジャッジ日時 | 2025-01-25 01:02:20 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 TLE * 1 |
ソースコード
#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 Inf 1000000001
int main(){
int N;
cin>>N;
vector<map<int,int>> mp(N);
map<int,int> LCA;
vector<long long> v(N,1);
rep(i,N){
int m;
cin>>m;
rep(j,m){
int p,e;
cin>>p>>e;
mp[i][p] = e;
LCA[p] = max(LCA[p],e);
rep(k,e)v[i] *= p;
}
}
map<int,int> pos;
int cur = 0;
vector<int> ps(LCA.size());
for(auto a:LCA){
pos[a.first] = cur;
ps[cur] = a.first;
cur++;
}
set<vector<int>> S;
vector<vector<int>> tt(N);
rep(i,N){
vector<int> t;
for(auto a:mp[i]){
if(a.second == LCA[a.first]){
t.push_back(pos[a.first]);
}
}
sort(t.begin(),t.end());
tt[i] = t;
if(S.count(t))continue;
rep(j,1<<t.size()){
vector<int> nt;
rep(k,t.size()){
if((j>>k)&1)nt.push_back(t[k]);
}
S.insert(nt);
}
}
//cout<<'a'<<endl;
vector<vector<int>> t(cur);
rep(i,cur)t[i] = {i};
while(true){
if(t.size()==0){
cout<<-1<<endl;
return 0;
}
vector<vector<int>> nt;
rep(i,t.size()){
int last = t[i].back();
for(int j=last+1;j<cur;j++){
vector<int> temp = t[i];
temp.push_back(j);
if(!S.count(temp)){
cout<<temp.size()<<endl;
vector<vector<int>> ans(temp.size());
rep(i,N){
rep(j,temp.size()){
if(binary_search(tt[i].begin(),tt[i].end(),temp[j]))continue;
ans[j].push_back(v[i]);
break;
}
}
rep(i,temp.size()){
cout<<ans[i].size();
rep(j,ans[i].size()){
cout<<' ';
cout<<ans[i][j];
}
cout<<endl;
}
return 0;
}
nt.push_back(temp);
}
}
swap(t,nt);
}
return 0;
}
沙耶花