QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#385701#5422. Perfect PalindromeshepherdAC ✓3ms3876kbC++204.2kb2024-04-10 23:47:052024-04-10 23:47:06

Judging History

你现在查看的是最新测评结果

  • [2024-04-10 23:47:06]
  • 评测
  • 测评结果:AC
  • 用时:3ms
  • 内存:3876kb
  • [2024-04-10 23:47:05]
  • 提交

answer

#include <bits/stdc++.h>

#include <climits>
#include <cstdint>

using namespace std;

#pragma GCC optimize("Ofast,unroll-loops")

using ui = unsigned int;
using ll = long long;
using ull = uint64_t;
using ld = long double;

template <typename K, typename V>
using umap = unordered_map<K, V>;

#define null NULL
#define len(a) static_cast<int>((a).size())
#define present(c, x) (c.find(x) != c.end())
#define inrange(val, start, end) (val >= start && val <= end)
const double PI = 2 * acos(0.0);

constexpr int iinf = 0x3f3f3f3f;
constexpr ll inf = 1'000'000'000'000'000;
constexpr ll mod = 1e9 + 7;

#define var(args...)                       \
  {                                        \
    string _s = #args;                     \
    stringstream _ss;                      \
    string ccurr = "";                     \
    for (int zz = 0; zz < len(_s); zz++) { \
      if (_s[zz] == ' ') continue;         \
      if (_s[zz] == ',') {                 \
        _ss << ' ' + ccurr;                \
        ccurr = "";                        \
      } else {                             \
        ccurr += _s[zz];                   \
      }                                    \
    }                                      \
    _ss << ' ' + ccurr;                    \
    istream_iterator<string> _it(_ss);     \
    vars(_it, args);                       \
  }
#define debugDecimal(d) cerr << setprecision(d) << fixed

void vars(istream_iterator<string> it) { cerr << '\n'; }
template <typename T, typename... Args>
void vars(istream_iterator<string> it, T a, Args... args) {
  cerr << " [" << *it << ": " << a << "] ";
  vars(++it, args...);
}

#define printVerdict(verdict) cout << (verdict ? "YES" : "NO") << '\n'
#define printDecimal(d) cout << setprecision(d) << fixed
#define printCase(_) cout << "Case #" << (_) << ": "

template <int I, typename TupleT>
ostream& printTupleImpl(ostream& out, const TupleT& t) {
  if constexpr (I < tuple_size_v<TupleT>) {
    out << get<I>(t) << " ";
    printTupleImpl<I + 1, TupleT>(out, t);
  }
  return out;
}
template <typename... Ts>
ostream& operator<<(ostream& out, const tuple<Ts...>& t) {
  return printTupleImpl<0>(out, t);
}

template <int I, typename TupleT>
istream& readTupleImpl(istream& in, TupleT* t) {
  if constexpr (I < tuple_size_v<TupleT>) {
    in >> get<I>(*t);
    readTupleImpl<I + 1, TupleT>(in, t);
  }
  return in;
}

template <typename... Ts>
istream& operator>>(istream& in, tuple<Ts...>& t) {
  return readTupleImpl<0>(in, &t);
}

template <typename T1, typename T2>
ostream& operator<<(ostream& out, const pair<T1, T2>& p) {
  return out << p.first << " " << p.second;
}
template <typename T>
ostream& operator<<(ostream& out, const vector<T>& arr) {
  for (const T& a : arr) out << a << " ";
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, const vector<vector<T>>& grid) {
  for (const vector<T>& row : grid) out << row << '\n';
  return out;
}
template <typename T>
istream& operator>>(istream& in, vector<T>& arr) {
  for (T& a : arr) in >> a;
  return in;
}
template <typename T1, typename T2>
istream& operator>>(istream& in, pair<T1, T2>& a) {
  in >> a.first >> a.second;
  return in;
}

template <typename Fun>
class y_combinator_result {
  Fun fun_;

 public:
  template <typename T>
  explicit y_combinator_result(T&& fun) : fun_{std::forward<T>(fun)} {}

  template <typename... ArgTs>
  decltype(auto) operator()(ArgTs&&... args) {
    return fun_(std::ref(*this), std::forward<ArgTs>(args)...);
  }
};

template <typename Fun>
decltype(auto) y_combinator(Fun&& fun) {
  return y_combinator_result<decay_t<Fun>>(std::forward<Fun>(fun));
}

inline void prayGod() {
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    vector<int> cnt(26);
    for (char c : s) {
      cnt[c - 'a']++;
    }
    cout << len(s) - *max_element(cnt.begin(), cnt.end()) << '\n';
  }
}

int main() {
#ifdef LLOCAL
  clock_t start = clock();
#endif
  std::ios_base::sync_with_stdio(false);
  cin.tie(0);

  prayGod();
#ifdef LLOCAL
  clock_t end = clock();

  double time_taken = double(end - start) / CLOCKS_PER_SEC;
  debugDecimal(5) << time_taken << " s" << '\n';
#endif
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3612kb

input:

2
abcb
xxx

output:

2
0

result:

ok 2 number(s): "2 0"

Test #2:

score: 0
Accepted
time: 3ms
memory: 3876kb

input:

11107
lfpbavjsm
pdtlkfwn
fmb
hptdswsoul
bhyjhp
pscfliuqn
nej
nxolzbd
z
clzb
zqomviosz
u
ek
vco
oymonrq
rjd
ktsqti
mdcvserv
x
birnpfu
gsgk
ftchwlm
bzqgar
ovj
nsgiegk
dbolme
nvr
rpsc
fprodu
eqtidwto
j
qty
o
jknssmabwl
qjfv
wrd
aa
ejsf
i
npmmhkef
dzvyon
p
zww
dp
ru
qmwm
sc
wnnjyoepxo
hc
opvfepiko
inuxx...

output:

8
7
2
8
4
8
2
6
0
3
7
0
1
2
5
2
4
6
0
6
2
6
5
2
5
5
2
3
5
6
0
2
0
8
3
2
0
3
0
6
5
0
1
1
1
2
1
8
1
7
5
3
4
4
1
8
5
5
8
8
6
3
0
2
3
2
1
5
0
0
9
3
3
4
8
4
0
4
2
6
6
0
8
7
4
3
9
3
4
2
5
8
8
8
6
1
4
4
2
7
2
8
6
4
4
8
7
8
4
9
3
8
0
7
7
2
6
0
0
5
4
0
7
5
4
2
1
6
7
5
2
4
4
7
3
3
2
5
4
8
5
0
3
5
1
2
3
0
4
7
...

result:

ok 11107 numbers