結果
問題 |
No.1183 コイン遊び
|
ユーザー |
|
提出日時 | 2020-08-22 13:40:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 177 ms / 2,000 ms |
コード長 | 921 bytes |
コンパイル時間 | 814 ms |
コンパイル使用メモリ | 74,856 KB |
最終ジャッジ日時 | 2025-01-13 07:55:12 |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 32 |
ソースコード
#include <iostream> #include <vector> #include <string> template <class It> std::vector<std::pair<typename It::value_type, int>> runlength( It begin, It end) { using T = typename It::value_type; std::vector<std::pair<T, int>> res; while (begin != end) { const T& c = *(begin++); if (res.empty() || c != res.back().first) { res.emplace_back(c, 1); } else { ++res.back().second; } } return res; } void solve() { int n; std::cin >> n; std::vector<int> xs(n); for (auto& x : xs) std::cin >> x; for (auto& x : xs) { int y; std::cin >> y; x ^= y; } auto ps = runlength(xs.begin(), xs.end()); int ans = 0; for (auto [c, l] : ps) ans += c; std::cout << ans << "\n"; } int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); solve(); return 0; }