結果
問題 |
No.1711 Divide LCM
|
ユーザー |
![]() |
提出日時 | 2021-10-15 22:41:08 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,879 bytes |
コンパイル時間 | 5,412 ms |
コンパイル使用メモリ | 269,424 KB |
最終ジャッジ日時 | 2025-01-25 01:01:20 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 5 WA * 35 TLE * 2 |
ソースコード
#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; 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); } } 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; rep(i,N){ vector<int> t; for(auto a:mp[i]){ if(a.second == LCA[a.first]){ //cout<<pos[a.first]<<endl; t.push_back(pos[a.first]); } } sort(t.begin(),t.end()); if(S.count(t))continue; //cout<<i<<endl; rep(j,1<<t.size()){ vector<int> nt; rep(k,t.size()){ if((j>>k)&1)nt.push_back(t[k]); } S.insert(nt); } /* for(auto a:S){ rep(j,a.size()){ cout<<a[j]<<','; } cout<<endl; } cout<<endl; */ } //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(mp[i].count(ps[temp[j]])&&mp[i][ps[temp[j]]]==LCA[ps[temp[j]]])continue; ans[j].push_back(i+1); break; } } rep(i,temp.size()){ rep(j,ans[i].size()){ if(j!=0)cout<<' '; cout<<ans[i][j]; } cout<<endl; } return 0; } nt.push_back(temp); } } swap(t,nt); } return 0; }