結果
問題 |
No.608 God's Maze
|
ユーザー |
|
提出日時 | 2017-12-13 19:33:41 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,463 bytes |
コンパイル時間 | 2,243 ms |
コンパイル使用メモリ | 196,904 KB |
最終ジャッジ日時 | 2025-01-05 05:12:56 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 32 WA * 33 |
ソースコード
#include <bits/stdc++.h> #define show(x) cerr << #x << " = " << x << endl using namespace std; using ll = long long; using pii = pair<int, int>; using vi = vector<int>; template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "sz=" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template <typename S, typename T> ostream& operator<<(ostream& os, const pair<S, T>& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ll MOD = 1e9 + 7; template <typename T> constexpr T INF = numeric_limits<T>::max() / 100; int main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; N--; string S; cin >> S; const int size = S.size(); vector<bool> need(size); for (int i = 0; i < size; i++) { need[i] = S[i] == '#'; } int left = size; int right = 0; for (int i = 0; i < size; i++) { if (need[i]) { left = min(left, i); right = max(right, i); } } ll ans = 0; for (int i = left; i < N; i++) { ans++; need[i] = not need[i]; } for (int i = left; i < right; i++) { ans++; need[i + 1] = not need[i + 1]; if (need[i]) { ans += (i == right - 1 ? 1 : 2); need[i + 1] = not need[i + 1]; } } cout << ans << endl; return 0; }