結果
| 問題 | No.346 チワワ数え上げ問題 |
| コンテスト | |
| ユーザー |
willowoooo
|
| 提出日時 | 2016-05-15 21:52:02 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 485 bytes |
| 記録 | |
| コンパイル時間 | 491 ms |
| コンパイル使用メモリ | 63,712 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-06 04:08:38 |
| 合計ジャッジ時間 | 1,278 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 9 |
ソースコード
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
string s;
cin >> s;
vector<int> c, w;
int ans = 0;
for (int i = 0; i < s.size(); i++)
{
if (s[i] == 'c')
c.push_back(i);
else if (s[i] == 'w')
w.push_back(i);
}
for (int i = 0; i < c.size(); i++)
{
auto it = lower_bound(w.begin(), w.end(), c[i]);
int count = distance(it, w.end());
ans += count * (count -1) / 2;
}
cout << ans << endl;
return 0;
}
willowoooo