結果

問題 No.2561 みんな大好きmod 998
ユーザー tsunamayo123tsunamayo123
提出日時 2023-12-02 16:50:42
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,660 bytes
コンパイル時間 4,476 ms
コンパイル使用メモリ 269,564 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2023-12-02 16:50:54
合計ジャッジ時間 10,641 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,548 KB
testcase_01 AC 14 ms
6,548 KB
testcase_02 AC 1 ms
6,548 KB
testcase_03 AC 485 ms
6,548 KB
testcase_04 AC 500 ms
6,548 KB
testcase_05 AC 477 ms
6,548 KB
testcase_06 AC 483 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 2 ms
6,548 KB
testcase_11 AC 70 ms
6,548 KB
testcase_12 AC 1 ms
6,548 KB
testcase_13 AC 2 ms
6,548 KB
testcase_14 AC 1 ms
6,548 KB
testcase_15 WA -
testcase_16 AC 2 ms
6,548 KB
testcase_17 AC 2 ms
6,548 KB
testcase_18 AC 2 ms
6,548 KB
testcase_19 WA -
testcase_20 AC 2 ms
6,548 KB
testcase_21 AC 1 ms
6,548 KB
testcase_22 AC 1 ms
6,548 KB
testcase_23 AC 2 ms
6,548 KB
testcase_24 AC 2 ms
6,548 KB
testcase_25 AC 2 ms
6,548 KB
testcase_26 AC 103 ms
6,548 KB
testcase_27 AC 524 ms
6,548 KB
testcase_28 AC 118 ms
6,548 KB
testcase_29 AC 34 ms
6,548 KB
testcase_30 AC 95 ms
6,548 KB
testcase_31 AC 223 ms
6,548 KB
testcase_32 AC 57 ms
6,548 KB
testcase_33 AC 33 ms
6,548 KB
testcase_34 AC 412 ms
6,548 KB
testcase_35 AC 33 ms
6,548 KB
testcase_36 AC 39 ms
6,548 KB
testcase_37 AC 14 ms
6,548 KB
testcase_38 AC 54 ms
6,548 KB
testcase_39 AC 82 ms
6,548 KB
testcase_40 AC 96 ms
6,548 KB
testcase_41 AC 55 ms
6,548 KB
testcase_42 AC 141 ms
6,548 KB
testcase_43 AC 16 ms
6,548 KB
testcase_44 AC 39 ms
6,548 KB
testcase_45 AC 368 ms
6,548 KB
testcase_46 AC 41 ms
6,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#if !__INCLUDE_LEVEL__
#include __FILE__

template <typename T> bool next_combination(const T first, const T last, int k) {
    const T subset = first + k;
    // empty container | k = 0 | k == n 
    if (first == last || first == subset || last == subset) {
        return false;
    }
    T src = subset;
    while (first != src) {
        src--;
        if (*src < *(last - 1)) {
            T dest = subset;
            while (*src >= *dest) {
                dest++;
            }
            iter_swap(src, dest);
            rotate(src + 1, dest + 1, last);
            rotate(subset, subset + (last - dest) - 1, last);
            return true;
        }
    }
    // restore
    rotate(first, subset, last);
    return false;
}

void solve(){
    int N,K; cin>>N>>K;
    vector<long double> A(N); rep(i,N){cin>>A[i];A[i]+=i/10.0;} sort(all(A));
    int cnt=0;
    do{
        ll sum=0;
        rep(i,K)sum+=A[i];
        if(sum%998==sum%998244353)cnt++;
    }while(next_combination(all(A),K));
    cout<<cnt%998<<endl;
}

#else

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define rep(i,n) FOR(i,0,n)
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long,long long>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
#define pf push_front
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define pqueue priority_queue
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
#define INF (1<<30)-1
#define INFLL (1LL<<60)-1
#define pcnt __builtin_popcount
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end());
template<typename T> void out(T vec){for(int c:vec)cout<<c<<' ';}
void yn(bool flag){if(flag)cout<<"Yes"<<'\n'; else cout<<"No"<<'\n';}
template <typename T>
bool chmax(T &a,const T& b){if(a<b){a=b;return true;}return false;}
template <typename T>
bool chmin(T &a,const T& b){if(a>b){a=b;return true;}return false;}
void solve();

// const int mod = ;
// using mint = modint998244353;
// using mint = modint1000000007;

#ifdef LOCAL
#  include <debug_print.hpp>
#  define debug(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define debug(...) (static_cast<void>(0))
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(10);
    solve();
}

#endif
0