結果
| 問題 | No.2454 Former < Latter |
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2024-06-25 11:27:40 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 591 bytes |
| コンパイル時間 | 2,053 ms |
| コンパイル使用メモリ | 195,396 KB |
| 最終ジャッジ日時 | 2025-02-22 00:30:00 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 23 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
void solve(const string& S) {
int N = S.size();
vector<char> min_right(N + 1, 'z' + 1);
for (int i = N - 1; i >= 0; --i) {
min_right[i] = min(S[i], min_right[i + 1]);
}
int count = 0;
for (int i = 0; i < N - 1; ++i) {
if (S[i] < min_right[i + 1]) {
++count;
}
}
cout << count << '\n';
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin >> T;
while (T--) {
string S;
cin >> S;
solve(S);
}
return 0;
}
srjywrdnprkt