結果

問題 No.2561 みんな大好きmod 998
ユーザー MMMM
提出日時 2023-12-02 14:47:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 198 ms / 4,000 ms
コード長 970 bytes
コンパイル時間 3,635 ms
コンパイル使用メモリ 233,156 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-02 14:47:54
合計ジャッジ時間 7,042 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 10 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 198 ms
6,676 KB
testcase_04 AC 198 ms
6,676 KB
testcase_05 AC 197 ms
6,676 KB
testcase_06 AC 197 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 27 ms
6,676 KB
testcase_12 AC 1 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 198 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 128 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 1 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 37 ms
6,676 KB
testcase_27 AC 197 ms
6,676 KB
testcase_28 AC 55 ms
6,676 KB
testcase_29 AC 15 ms
6,676 KB
testcase_30 AC 45 ms
6,676 KB
testcase_31 AC 90 ms
6,676 KB
testcase_32 AC 21 ms
6,676 KB
testcase_33 AC 15 ms
6,676 KB
testcase_34 AC 197 ms
6,676 KB
testcase_35 AC 14 ms
6,676 KB
testcase_36 AC 15 ms
6,676 KB
testcase_37 AC 7 ms
6,676 KB
testcase_38 AC 28 ms
6,676 KB
testcase_39 AC 44 ms
6,676 KB
testcase_40 AC 45 ms
6,676 KB
testcase_41 AC 27 ms
6,676 KB
testcase_42 AC 54 ms
6,676 KB
testcase_43 AC 6 ms
6,676 KB
testcase_44 AC 20 ms
6,676 KB
testcase_45 AC 130 ms
6,676 KB
testcase_46 AC 18 ms
6,676 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:33:48: warning: narrowing conversion of '((((__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)mod998) + A.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)nxt))) % 998)' from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' [-Wnarrowing]
   33 |       st.push({bit+(1<<nxt),nxt,(mod998+A[nxt])%998,(mod353+A[nxt])%mod});
      |                                 ~~~~~~~~~~~~~~~^~~~
main.cpp:33:48: warning: narrowing conversion of '((((__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)mod998) + A.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)nxt))) % 998)' from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' [-Wnarrowing]
main.cpp:33:68: warning: narrowing conversion of '((((__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)mod353) + A.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)nxt))) % ((long long int)mod))' from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' [-Wnarrowing]
   33 |       st.push({bit+(1<<nxt),nxt,(mod998+A[nxt])%998,(mod353+A[nxt])%mod});
      |                                                     ~~~~~~~~~~~~~~~^~~~
main.cpp:33:68: warning: narrowing conversion of '((((__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)mod353) + A.std::vector<long long int>::operator[](((std::vector<long long int>::size_type)nxt))) % ((long long int)mod))' from '__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type' {aka 'long long int'} to 'int' [-Wnarrowing]

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
#define chmin(x,y) (x) = min((x),(y))
#define chmax(x,y) (x) = max((x),(y))
#define ld long double
using namespace std;
using namespace atcoder;
using ll = long long;
const ll mod = 998244353;
using mint = modint998244353;
using Graph = vector<vector<int>>;
const vector<int> dx = {1,0,-1,0}, dy = {0,1,0,-1};

int main(){
  // input
  int N,K; cin >> N >> K;
  vector<ll> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  
  // solve
  ll ans = 0;
  
  stack<vector<int>> st;
  st.push({0,-1,0,0}); // v = {bit,cur,mod998, mod998244353}
  
  while(!st.empty()){
    int bit = st.top()[0], cur = st.top()[1], mod998 = st.top()[2], mod353 = st.top()[3];
    st.pop();
    if(__builtin_popcount(bit) == K){
      if(mod353 <= mod998) ans++;
    }
    else for(int nxt = cur + 1; nxt < N; nxt++){
      st.push({bit+(1<<nxt),nxt,(mod998+A[nxt])%998,(mod353+A[nxt])%mod});
    }
  }
  
  // output
  cout << ans % 998 << endl;
}
0