結果
| 問題 | No.346 チワワ数え上げ問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-26 23:13:51 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 552 bytes |
| 記録 | |
| コンパイル時間 | 663 ms |
| コンパイル使用メモリ | 88,220 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-11 05:11:55 |
| 合計ジャッジ時間 | 5,434 ms |
|
ジャッジサーバーID (参考情報) |
judge3_1 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 1 TLE * 1 |
| other | AC * 3 WA * 16 RE * 2 TLE * 2 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:19:22: warning: 'w' may be used uninitialized [-Wmaybe-uninitialized]
19 | if (c=='w') w+=1;
| ~^~~
main.cpp:13:13: note: 'w' was declared here
13 | int c,i,w,j,n;
| ^
ソースコード
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int fact(int n){int i,j;for(i=1,j=1;i<n;j*=i)i++;return j;}
int combi(int x,int k){return fact(x)/(fact(k)*fact(x-k));}
int main(){
int c,i,w,j,n;
int s[100005];
i=0;
while((c=getchar())!=-1){
s[i++]=c;
if (c=='w') w+=1;
}
n=0;
for (j=0;j<i;j++){
if (w<=1) break;
if (s[j]=='c') n+=combi(w,2);
if (s[j]=='w') w-=1;
}
cout<<n<<endl;
return 0;
}