結果
| 問題 |
No.559 swapAB列
|
| コンテスト | |
| ユーザー |
kichirb3
|
| 提出日時 | 2018-03-02 21:05:55 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 670 bytes |
| コンパイル時間 | 598 ms |
| コンパイル使用メモリ | 72,676 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-12 22:43:09 |
| 合計ジャッジ時間 | 1,186 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 |
ソースコード
// No.559 swapAB列
// https://yukicoder.me/problems/no/559
//
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;
vector<int> check_A_positions(string &S);
int main() {
string S;
cin >> S;
vector<int> res = check_A_positions(S);
int after_swap = (0 + res.size()-1) * res.size() / 2;
int current_status = accumulate(res.begin(), res.end(), 0);
cout << current_status - after_swap << endl;
}
vector<int> check_A_positions(string &S) {
vector<int> res;
for (auto i = 0; i < S.size(); ++i) {
if (S[i] == 'A')
res.push_back(i);
}
return res;
}
kichirb3