結果

問題 No.2551 2, 3, 5, 7 Game
ユーザー cho435cho435
提出日時 2023-12-02 11:38:59
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 510 ms / 2,357 ms
コード長 1,167 bytes
コンパイル時間 5,317 ms
コンパイル使用メモリ 284,396 KB
実行使用メモリ 59,432 KB
最終ジャッジ日時 2023-12-02 11:39:09
合計ジャッジ時間 8,147 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
56,844 KB
testcase_01 AC 77 ms
56,588 KB
testcase_02 AC 74 ms
56,844 KB
testcase_03 AC 76 ms
56,716 KB
testcase_04 AC 75 ms
56,844 KB
testcase_05 AC 455 ms
59,432 KB
testcase_06 AC 482 ms
59,432 KB
testcase_07 AC 510 ms
59,432 KB
testcase_08 AC 465 ms
59,432 KB
testcase_09 AC 43 ms
7,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

constexpr int mxsz = 8192;
using bst = bitset<mxsz>;

vector<ll> v(mxsz);
unordered_map<ll,bst> mp;
bst dfs(ll x){
	auto itr=mp.find(x);
	if(itr!=mp.end()) return itr->second;
	int shf=v.end()-upper_bound(v.begin(),v.end(),x);
	if(!shf) return mp[x]=0;
	bst res;
	res.set();
	res>>=shf;
	res|=dfs(x*7);
	res|=dfs(x*5);
	res|=dfs(x*3);
	res|=dfs(x*2);
	res.flip();
	return mp[x]=res;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int t;
	cin>>t;
	vector<ll> vv(t);
	rep(i,t) cin>>vv[i];
	vector<bool> ans(t);
	vector<int> p(t);
	iota(p.begin(),p.end(),0);
	sort(p.begin(),p.end(),[&](int a,int b){
		return vv[a]<vv[b];
	});
	for(int i=0;i<t;i+=mxsz){
		mp.clear();
		for(int j=i;j<min(i+mxsz,t);j++){
			v[j-i]=vv[p[j]];
		}
		if(i+mxsz>t){
			for(int j=t;j<i+mxsz;j++){
				v[j-i]=vv[p.back()];
			}
		}
		bst res=dfs(1);
		for(int j=i;j<min(i+mxsz,t);j++){
			ans[p[j]]=res[j-i];
		}
	}
	rep(i,t){
		cout<<(ans[i]?"ryota\n":"sepa\n");
	}
}
0