結果
問題 | No.559 swapAB列 |
ユーザー | kichirb3 |
提出日時 | 2018-03-02 21:05:55 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 670 bytes |
コンパイル時間 | 652 ms |
コンパイル使用メモリ | 72,428 KB |
実行使用メモリ | 4,380 KB |
最終ジャッジ日時 | 2023-09-03 17:06:32 |
合計ジャッジ時間 | 1,294 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,376 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,380 KB |
testcase_06 | AC | 1 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 1 ms
4,376 KB |
testcase_09 | AC | 2 ms
4,380 KB |
ソースコード
// 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; }