結果
問題 |
No.884 Eat and Add
|
ユーザー |
![]() |
提出日時 | 2019-09-13 21:49:56 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,371 bytes |
コンパイル時間 | 2,124 ms |
コンパイル使用メモリ | 194,292 KB |
最終ジャッジ日時 | 2025-01-07 17:48:50 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 5 WA * 4 |
ソースコード
#include <bits/stdc++.h> #define loop(n) for (int ngtkana_is_genius = 0; ngtkana_is_genius < int(n); ngtkana_is_genius++) #define rep(i, begin, end) for(int i = int(begin); i < int(end); i++) #define all(v) v.begin(), v.end() #define lint long long auto cmn = [](auto& a, auto b){if (a > b) {a = b; return true;} return false;}; auto cmx = [](auto& a, auto b){if (a < b) {a = b; return true;} return false;}; void debug_impl() { std::cerr << std::endl; } template <typename Head, typename... Tail> void debug_impl(Head head, Tail... tail){ std::cerr << " " << head; debug_impl(tail...); } #define debug(...)\ std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\ debug_impl(__VA_ARGS__);\ std::cerr << std::noboolalpha; int main() { std::cin.tie(0); std::cin.sync_with_stdio(false); std::string s; std::cin >> s; std::string t; auto x = 2, y = 0, z = 0; int nx = 0, ny = 0, nz = 0; constexpr int inf = 1'000'000'000; for (auto c : s) { t.push_back(c); if (c == '0') { nx = x + 1; ny = inf; nz = std::min({x, y, z}); } else { nx = x; ny = std::min({x, y, z}) + 1; nz = inf; } cmn(nx, inf); cmn(ny, inf); cmn(nz, inf); std::swap(x, nx); std::swap(y, ny); std::swap(z, nz); // debug(x, y, z, t); } std::cout << std::min({x, y, z}) << std::endl; return 0; }