結果
| 問題 | No.346 チワワ数え上げ問題 |
| コンテスト | |
| ユーザー |
startcpp
|
| 提出日時 | 2016-02-28 00:49:48 |
| 言語 | C++11 (gcc 15.3.0 + boost 1.92.0) |
| 結果 |
AC
不安定
|
| 実行時間 | 3 ms / 2,000 ms |
| + 234µs | |
| コード長 | 440 bytes |
| 記録 | |
| コンパイル時間 | 276 ms |
| コンパイル使用メモリ | 71,756 KB |
| 実行使用メモリ | 9,792 KB |
| 最終ジャッジ日時 | 2026-09-03 05:54:36 |
| 合計ジャッジ時間 | 1,932 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
ソースコード
#include <iostream>
#include <string>
using namespace std;
string s;
long long wNum[100000]; //wNum[x] = s[N-1]~s[x]に存在するwの個数
int main(){
cin >> s;
int num = 0;
for( int i = s.length() - 1; i >= 0; i-- ){
if( s[i] == 'w' )
num++;
wNum[i] = num;
}
long long ans = 0;
for( int i = 0; i < s.length(); i++ ){
if( s[i] == 'c' )
ans += wNum[i] * (wNum[i] - 1) / 2;
}
cout << ans << endl;
return 0;
}
startcpp