結果
問題 | No.1729 ~サンプルはちゃんと見て!~ 16進数と8進数(1) |
ユーザー |
![]() |
提出日時 | 2021-11-05 22:12:05 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 3,818 bytes |
コンパイル時間 | 3,104 ms |
コンパイル使用メモリ | 222,572 KB |
最終ジャッジ日時 | 2025-01-25 12:23:39 |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 24 |
ソースコード
#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));