結果

問題 No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1)
ユーザー LayCurseLayCurse
提出日時 2021-11-05 22:12:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 3,818 bytes
コンパイル時間 2,715 ms
コンパイル使用メモリ 218,316 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-24 05:59:20
合計ジャッジ時間 3,520 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("inline")
#include<bits/stdc++.h>
using namespace std;
template<class T> struct cLtraits_identity{
  using type = T;
}
;
template<class T> using cLtraits_try_make_signed =
  typename conditional<
    is_integral<T>::value,
    make_signed<T>,
    cLtraits_identity<T>
    >::type;
template <class S, class T> struct cLtraits_common_type{
  using tS = typename cLtraits_try_make_signed<S>::type;
  using tT = typename cLtraits_try_make_signed<T>::type;
  using type = typename common_type<tS,tT>::type;
}
;
template<class S, class T> inline auto max_L(S a, T b)
-> typename cLtraits_common_type<S,T>::type{
  return (typename cLtraits_common_type<S,T>::type) a >= (typename cLtraits_common_type<S,T>::type) b ? a : b;
}
inline int my_getchar_unlocked(){
  static char buf[1048576];
  static int s = 1048576;
  static int e = 1048576;
  if(s == e && e == 1048576){
    e = fread_unlocked(buf, 1, 1048576, stdin);
    s = 0;
  }
  if(s == e){
    return EOF;
  }
  return buf[s++];
}
inline void rd(char &c){
  int i;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c = i;
}
inline int rd(char c[]){
  int i;
  int sz = 0;
  for(;;){
    i = my_getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = my_getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
struct MY_WRITER{
  char buf[1048576];
  int s;
  int e;
  MY_WRITER(){
    s = 0;
    e = 1048576;
  }
  ~MY_WRITER(){
    if(s){
      fwrite_unlocked(buf, 1, s, stdout);
    }
  }
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
  if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
    fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
    MY_WRITER_VAR.s = 0;
  }
  MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
  my_putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    my_putchar_unlocked('-');
  }
  while(s--){
    my_putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int N;
  char S[100000];
  int sz = 0;
  int d[100000];
  int cnt[8] = {};
  int i;
  int j;
  int k;
  int ress = 0;
  int res[100000];
  N = rd(S);
  for(i=(N)-1;i>=(0);i--){
    int Q5VJL1cS;
    k = S[i] - 'A' + 10;
    for(Q5VJL1cS=(0);Q5VJL1cS<(4);Q5VJL1cS++){
      d[sz++] = k % 2;
      k /= 2;
    }
  }
  while(sz%3){
    d[sz++] = 0;
  }
  for(i=(0);i<(sz);i+=(3)){
    k = d[i] + d[i+1] * 2 + d[i+2] * 4;
    cnt[k]++;
  }
  int t_ynMSdg;
  cLtraits_try_make_signed<remove_reference<decltype((*((int*)NULL)))>::type>::type KrdatlYV;
  if(8==0){
    KrdatlYV = 0;
  }
  else{
    KrdatlYV = cnt[0];
    for(t_ynMSdg=(1);t_ynMSdg<(8);t_ynMSdg++){
      KrdatlYV = max_L(KrdatlYV, cnt[t_ynMSdg]);
    }
  }
  k =KrdatlYV;
  for(i=(0);i<(8);i++){
    if(k==cnt[i]){
      res[ress++] = i;
    }
  }
  {
    int V9aVTaxx;
    if(ress==0){
      wt_L('\n');
    }
    else{
      for(V9aVTaxx=(0);V9aVTaxx<(ress-1);V9aVTaxx++){
        wt_L(res[V9aVTaxx]);
        wt_L(' ');
      }
      wt_L(res[V9aVTaxx]);
      wt_L('\n');
    }
  }
  return 0;
}
// cLay version 20211024-1

// --- original code ---
// int N; char S[1d5];
// int sz = 0, d[], cnt[8] = {}, i, j, k;
// int ress = 0, res[];
// rd(S@N);
// rrep(i,N){
//   k = S[i] - 'A' + 10;
//   rep(4) d[sz++] = k % 2, k /= 2;
// }
// while(sz%3) d[sz++] = 0;
// rep(i,0,sz,3){
//   k = d[i] + d[i+1] * 2 + d[i+2] * 4;
//   cnt[k]++;
// }
// k = max(cnt(8));
// rep(i,8) if(k==cnt[i]) res[ress++] = i;
// wt(res(ress));
0