結果
| 問題 |
No.346 チワワ数え上げ問題
|
| コンテスト | |
| ユーザー |
FF256grhy
|
| 提出日時 | 2016-03-24 14:43:16 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 333 bytes |
| コンパイル時間 | 156 ms |
| コンパイル使用メモリ | 22,272 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-02 00:09:27 |
| 合計ジャッジ時間 | 889 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 23 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%s", s);
| ~~~~~^~~~~~~~~
ソースコード
#include <stdio.h>
char s[100001];
long long int w[100001], ans;
int main(void) {
scanf("%s", s);
int i = 0, p = 0;
while(s[i] != '\0') {
if(s[i] == 'c') { p++; }
if(s[i] == 'w') { w[p]++; }
i++;
}
while(p > 0) {
w[p] += w[p + 1];
ans += w[p] * (w[p] - 1) / 2;
p--;
}
printf("%lld\n", ans);
return 0;
}
FF256grhy