fork download
  1. #pragma GCC optimize("Ofast")
  2. #pragma GCC optimize("unroll-loops")
  3. #pragma GCC optimize("inline")
  4. #include<bits/stdc++.h>
  5. using namespace std;
  6. template<class T> struct cLtraits_identity{
  7. using type = T;
  8. }
  9. ;
  10. template<class T> using cLtraits_try_make_signed =
  11. typename conditional<
  12. is_integral<T>::value,
  13. make_signed<T>,
  14. cLtraits_identity<T>
  15. >::type;
  16. template <class S, class T> struct cLtraits_common_type{
  17. using tS = typename cLtraits_try_make_signed<S>::type;
  18. using tT = typename cLtraits_try_make_signed<T>::type;
  19. using type = typename common_type<tS,tT>::type;
  20. }
  21. ;
  22. template<class S, class T> inline auto min_L(S a, T b)
  23. -> typename cLtraits_common_type<S,T>::type{
  24. return (typename cLtraits_common_type<S,T>::type) a <= (typename cLtraits_common_type<S,T>::type) b ? a : b;
  25. }
  26. #define main dummy_main
  27. int main(){
  28. return 0;
  29. }
  30. #undef main
  31. class Solution{
  32. public:
  33. int longestPalindrome(vector<string>& words){
  34. int i;
  35. int j;
  36. int res = 0;
  37. int cnt[26][26] = {};
  38. for(string s : words){
  39. cnt[s[0]-'a'][s[1]-'a']++;
  40. }
  41. for(i=(0);i<(26);i++){
  42. for(j=(i+1);j<(26);j++){
  43. res += 4 *min_L(cnt[i][j], cnt[j][i]);
  44. }
  45. }
  46. for(i=(0);i<(26);i++){
  47. res += 4 * (cnt[i][i] / 2);
  48. cnt[i][i] %= 2;
  49. }
  50. for(i=(0);i<(26);i++){
  51. if(cnt[i][i]){
  52. res+=2;
  53. break;
  54. }
  55. }
  56. return res;
  57. }
  58. }
  59. ;
  60. // cLay version 20220312-1
  61.  
  62. // --- original code ---
  63. // #define main dummy_main
  64. // {}
  65. // #undef main
  66. //
  67. // class Solution {
  68. // public:
  69. // int longestPalindrome(vector<string>& words) {
  70. // int i, j, res = 0;
  71. // int cnt[26][26] = {};
  72. // for(string s : words) cnt[s[0]-'a'][s[1]-'a']++;
  73. // rep(i,26) rep(j,i+1,26) res += 4 * min(cnt[i][j], cnt[j][i]);
  74. // rep(i,26){
  75. // res += 4 * (cnt[i][i] / 2);
  76. // cnt[i][i] %= 2;
  77. // }
  78. // rep(i,26) if(cnt[i][i]) res+=2, break;
  79. // return res;
  80. // }
  81. // };
  82.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x20): undefined reference to `main'
collect2: error: ld returned 1 exit status
stdout
Standard output is empty