結果
| 問題 | No.345 最小チワワ問題 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-02-29 04:15:49 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 812 bytes |
| 記録 | |
| コンパイル時間 | 352 ms |
| コンパイル使用メモリ | 56,432 KB |
| 最終ジャッジ日時 | 2024-11-14 19:35:31 |
| 合計ジャッジ時間 | 698 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:21: error: ‘numeric_limits’ is not a member of ‘std’
18 | int minLen = std::numeric_limits<int>::max();
| ^~~~~~~~~~~~~~
main.cpp:18:36: error: expected primary-expression before ‘int’
18 | int minLen = std::numeric_limits<int>::max();
| ^~~
main.cpp:33:32: error: ‘numeric_limits’ is not a member of ‘std’
33 | std::cout << (minLen == std::numeric_limits<int>::max() ? -1 : minLen) << std::endl;
| ^~~~~~~~~~~~~~
main.cpp:33:47: error: expected primary-expression before ‘int’
33 | std::cout << (minLen == std::numeric_limits<int>::max() ? -1 : minLen) << std::endl;
| ^~~
main.cpp:33:47: error: expected ‘)’ before ‘int’
33 | std::cout << (minLen == std::numeric_limits<int>::max() ? -1 : minLen) << std::endl;
| ~ ^~~
| )
ソースコード
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <string>
#include <stack>
int
main()
{
std::cin.tie(0);
std::ios::sync_with_stdio(false);
std::string s;
std::cin >> s;
std::stack<std::string::size_type> wposStack;
int minLen = std::numeric_limits<int>::max();
for (std::string::size_type i = s.length() - 1; i != static_cast<std::string::size_type>(-1); i--) {
switch (s[i]) {
case 'c':
if (wposStack.size() > 1) {
wposStack.pop();
minLen = std::min(minLen, static_cast<int>(wposStack.top() - i + 1));
wposStack.pop();
}
break;
case 'w':
wposStack.push(i);
break;
}
}
std::cout << (minLen == std::numeric_limits<int>::max() ? -1 : minLen) << std::endl;
return EXIT_SUCCESS;
}