結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
kurome____
|
| 提出日時 | 2016-03-02 21:13:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 751 bytes |
| コンパイル時間 | 1,553 ms |
| コンパイル使用メモリ | 160,332 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-24 13:38:19 |
| 合計ジャッジ時間 | 2,344 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,s,e) for(int (i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)
#define RFOR(i,e,s) for(int (i)=(e)-1;(i)>=(int)(s);(i)--)
#define RREP(i,e) RFOR(i,e,0)
#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
typedef long long ll;
typedef pair<int, int> PII;
typedef priority_queue<int> PQI;
typedef priority_queue<PII> PQII;
const double EPS = 1e-10;
const int N = 1e5;
int w[N+1];
int main() {
string s;
cin >> s;
int n = (int)s.size();
memset(w, 0, sizeof(w));
RREP(i,n) w[i] = w[i+1] + (s[i]=='w' ? 1 : 0);
ll res = 0;
REP(i,n-2) res += s[i]=='c' ? (ll)w[i+1]*(w[i]-1)/2 : 0;
printf("%lld\n", res);
return 0;
}
kurome____