結果

問題 No.1711 Divide LCM
ユーザー 沙耶花沙耶花
提出日時 2021-10-15 22:53:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,104 bytes
コンパイル時間 5,940 ms
コンパイル使用メモリ 282,604 KB
実行使用メモリ 36,984 KB
最終ジャッジ日時 2023-10-17 20:45:35
合計ジャッジ時間 17,953 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 271 ms
23,960 KB
testcase_19 AC 262 ms
23,956 KB
testcase_20 AC 260 ms
23,932 KB
testcase_21 AC 253 ms
25,320 KB
testcase_22 AC 140 ms
16,644 KB
testcase_23 WA -
testcase_24 AC 156 ms
21,588 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 168 ms
22,988 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 183 ms
25,792 KB
testcase_31 WA -
testcase_32 AC 254 ms
30,032 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 450 ms
36,984 KB
testcase_39 AC 300 ms
31,412 KB
testcase_40 AC 4 ms
4,348 KB
testcase_41 AC 4 ms
4,348 KB
testcase_42 AC 5 ms
4,348 KB
testcase_43 AC 4 ms
4,348 KB
testcase_44 AC 5 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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

long long gethash(vector<int> t){
	long long ret= 0;
	
	rep(i,t.size()){
		long long x = t[i] + 110558;
		x <<= 38;
		x ^= t[i];
		x ^= 13478729717847197;
		x += 553332;
		ret ^= x;
	}/*
	rep(i,t.size()){
		cout<<t[i]<<',';
	}
	cout<<ret<<endl;*/
	return ret;
}

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<long long> 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(gethash(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(gethash(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(gethash(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;
}
0