結果

問題 No.2035 Tunnel
ユーザー Manuel1024
提出日時 2022-09-05 03:23:16
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 609 bytes
コンパイル時間 768 ms
コンパイル使用メモリ 70,712 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-19 12:06:42
合計ジャッジ時間 2,551 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int n; cin >> n;
    string s; cin >> s;
    
    reverse(s.begin(), s.end());
    string ans = "";
    ans += s[0];
    int cnt = 0;
    for(int i = 1; i < s.size() || cnt > 0; i++){
        if(i < s.size() && s[i] == '#') cnt++;
        if(ans.back() == '#') ans += '.';
        else if(cnt > 0){
            ans += '#';
            cnt--;
        }else ans += '.';
    }
    while(ans.back() == '.') ans.pop_back();
    cout << ans.size() << endl;
    // cerr << ans << endl;
    return 0;
}
0