結果

問題 No.2561 みんな大好きmod 998
ユーザー ku_senjanku_senjan
提出日時 2023-12-02 14:46:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 248 ms / 4,000 ms
コード長 1,827 bytes
コンパイル時間 5,838 ms
コンパイル使用メモリ 302,972 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2023-12-02 14:46:41
合計ジャッジ時間 9,749 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 9 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 248 ms
6,548 KB
testcase_04 AC 228 ms
6,548 KB
testcase_05 AC 222 ms
6,548 KB
testcase_06 AC 221 ms
6,548 KB
testcase_07 AC 1 ms
6,548 KB
testcase_08 AC 1 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 2 ms
6,548 KB
testcase_11 AC 35 ms
6,548 KB
testcase_12 AC 2 ms
6,548 KB
testcase_13 AC 2 ms
6,548 KB
testcase_14 AC 1 ms
6,548 KB
testcase_15 AC 242 ms
6,548 KB
testcase_16 AC 2 ms
6,548 KB
testcase_17 AC 1 ms
6,548 KB
testcase_18 AC 1 ms
6,548 KB
testcase_19 AC 172 ms
6,548 KB
testcase_20 AC 2 ms
6,548 KB
testcase_21 AC 1 ms
6,548 KB
testcase_22 AC 2 ms
6,548 KB
testcase_23 AC 1 ms
6,548 KB
testcase_24 AC 2 ms
6,548 KB
testcase_25 AC 1 ms
6,548 KB
testcase_26 AC 49 ms
6,548 KB
testcase_27 AC 222 ms
6,548 KB
testcase_28 AC 66 ms
6,548 KB
testcase_29 AC 18 ms
6,548 KB
testcase_30 AC 49 ms
6,548 KB
testcase_31 AC 118 ms
6,548 KB
testcase_32 AC 34 ms
6,548 KB
testcase_33 AC 17 ms
6,548 KB
testcase_34 AC 242 ms
6,548 KB
testcase_35 AC 17 ms
6,548 KB
testcase_36 AC 17 ms
6,548 KB
testcase_37 AC 9 ms
6,548 KB
testcase_38 AC 38 ms
6,548 KB
testcase_39 AC 49 ms
6,548 KB
testcase_40 AC 48 ms
6,548 KB
testcase_41 AC 35 ms
6,548 KB
testcase_42 AC 66 ms
6,548 KB
testcase_43 AC 9 ms
6,548 KB
testcase_44 AC 27 ms
6,548 KB
testcase_45 AC 163 ms
6,548 KB
testcase_46 AC 25 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifdef SENJAN
#include <ku/debug.hpp>
#else
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define debug(...)
#endif
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
using graph=vector<vector<int>>;
template<class T> using wgraph=vector<vector<pair<int,T>>>;
template<class T> using min_priority_queue=priority_queue<T,vector<T>,greater<T>>;
constexpr int INF32=INT_MAX/2;
constexpr ll INF64=1LL<<60;
constexpr ld PI=3.14159265358979323846;
constexpr int dx[]={0,0,-1,1,-1,-1,1,1},dy[]={-1,1,0,0,-1,1,-1,1};
#define rep(i,s,n) for(ll i=(ll)(s);i<(ll)(n);i++)
#define rrep(i,s,n) for(ll i=(ll)(s);i>=(ll)(n);i--)
template<class T> inline bool chmax(T &a,T b){return a<b?a=b,true:false;}
template<class T> inline bool chmin(T &a,T b){return a>b?a=b,true:false;}
void _main();
int main(){cin.tie(0)->sync_with_stdio(0);cout<<fixed<<setprecision(16);_main();}

template <typename T> bool next_combination(const T begin, const T end, int k){
	const T sub = begin+k;
	if (begin==end || begin==sub || end==sub) return false;
	T src = sub;
	while(begin!=src){
		src--;
		if((*src)<(*(end-1))){
			T des=sub;
			while((*des)<=(*src)){
				des++;
			}
			iter_swap(src, des);
			rotate(src+1, des+1, end);
			rotate(sub, sub+(end-des)-1, end);
			return true;
		}
	}
	rotate(begin, sub, end);
	return false;
}


void _main(){
	int N, K; cin >> N >> K;
	vector<ll> A(N); rep(i,0,N) cin >> A[i];

	vector<int> id(N);
	iota(id.begin(), id.end(), 0);

	int ans{};
	do{
		ll s1{}, s2{};
		rep(i,0,K){
			s1 = (s1+A[id[i]]) % 998;
			s2 = (s2+A[id[i]]) % 998244353;
		}
		if(s1>=s2) ans = (ans+1) % 998;
	}while(next_combination(id.begin(), id.end(), K));


	cout << ans << endl;
}
0