結果
| 問題 | No.345 最小チワワ問題 |
| コンテスト | |
| ユーザー |
ldsyb
|
| 提出日時 | 2016-02-27 19:44:14 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 552 bytes |
| 記録 | |
| コンパイル時間 | 357 ms |
| コンパイル使用メモリ | 78,704 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-04-11 16:48:19 |
| 合計ジャッジ時間 | 1,476 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 15 WA * 14 |
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:17:30: warning: ignoring return value of 'const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = int]', declared with attribute 'nodiscard' [-Wunused-result]
17 | else min(ans,k - i + 1);
| ~~~^~~~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:53,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/locale_classes.h:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ios_base.h:43,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ios:46,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:43,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ostream:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/iostream:43,
from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_algobase.h:234:5: note: declared here
234 | min(const _Tp& __a, const _Tp& __b)
| ^~~
ソースコード
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main(){
int ans = -1;
string s;
cin >> s;
for(int i = 0;i < s.size();i++){
if(s[i] == 'c'){
for(int j = i + 1;j < s.size();j++){
if(s[j] == 'w'){
for(int k = j + 1;k < s.size();k++){
if(s[k] == 'w'){
if(ans == -1) ans = k - i + 1;
else min(ans,k - i + 1);
}
}
}
}
}
}
cout << ans << endl;
}
ldsyb