結果
問題 | No.2035 Tunnel |
ユーザー |
|
提出日時 | 2022-08-12 21:51:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 520 bytes |
コンパイル時間 | 1,920 ms |
コンパイル使用メモリ | 192,980 KB |
最終ジャッジ日時 | 2025-01-30 21:02:43 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); i++) using namespace std; using ll = long long; using P = pair<int, int>; int main() { ll n; cin >> n; string s; cin >> s; reverse(s.begin(), s.end()); s += '.'; int idx = 0; rep(i, n) { if (s[i] == '#') idx = i; } ll add = 0; rep(i, idx) { if (s[i] == '#' && s[i + 1] == '#') add++; if (s[i] == '.' && s[i + 1] == '.' && add > 0) add--; } cout << idx + 1 + add << endl; }