結果

問題 No.390 最長の数列
ユーザー tabataba
提出日時 2017-05-19 06:10:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 819 bytes
コンパイル時間 1,554 ms
コンパイル使用メモリ 149,696 KB
実行使用メモリ 10,068 KB
最終ジャッジ日時 2023-10-19 02:00:27
合計ジャッジ時間 8,564 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <random>
#include <vector>
#include <algorithm>
#include <array>
#include <functional>
#include <utility>
#include <regex>
#include <tuple>
#include <map>
#include <set>

using namespace std;

int main(){
	int64_t n;
	-scanf("%ld",&n);
	vector<int> x(n);
	for(int i=0;i<n;i++){
		-scanf("%d",&x[i]);
	}
	sort(x.begin(),x.end());
	vector<vector<int>> t(n);
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(x[j]%x[i]==0){
				t[i].push_back(j);
			}
		}
	}
	set<int> b;
	for(int i=0;i<n;i++)b.insert(i);
	int cnt=0;
	while(!b.empty()){
		cnt++;
		set<int> nb;
		for_each(b.begin(),b.end(),[&t,&nb](auto i){
			for_each(t[i].begin(),t[i].end(),[&nb](auto i){
				nb.insert(i);
			});
		});
		b=nb;
	}
	printf("%d\n",cnt);
	return 0;
}
0