結果
問題 | No.2035 Tunnel |
ユーザー | ma_tw |
提出日時 | 2022-08-12 21:58:10 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,470 bytes |
コンパイル時間 | 2,099 ms |
コンパイル使用メモリ | 203,680 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-09-23 02:26:02 |
合計ジャッジ時間 | 3,118 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 2 ms
6,940 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 3 ms
6,940 KB |
testcase_08 | AC | 4 ms
6,940 KB |
testcase_09 | AC | 3 ms
6,940 KB |
testcase_10 | AC | 3 ms
6,944 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
コンパイルメッセージ
main.cpp: In function 'int main()': main.cpp:82:16: warning: 'st' may be used uninitialized [-Wmaybe-uninitialized] 82 | ll ans = n - st; | ~~^~~~ main.cpp:72:9: note: 'st' was declared here 72 | int st; | ^~
ソースコード
#pragma region Template #include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using vi = vector<int>; using vll = vector<ll>; using vvi = vector<vector<int>>; using vvll = vector<vector<ll>>; using vvvi = vector<vector<vector<int>>>; using vpi = vector<pair<int,int>>; using vpll = vector<pair<ll,ll>>; using vs = vector<string>; using vb = vector<bool>; using pi = pair<int,int>; using pll = pair<ll,ll>; template<typename T> using spq = priority_queue<T, vector<T>, greater<T>>; template<typename T> using gpq = priority_queue<T>; #define fi first #define se second #define pb push_back #define fore(p,a) for (auto p : a) #define overload4(a,b,c,d,name,...) name #define rep1(n) for (ll i = 0; i < ll(n); ++i) #define rep2(i,n) for (ll i = 0; i < ll(n); ++i) #define rep3(i,a,b) for (ll i = a; i < ll(b); ++i) #define rep4(i,a,b,c) for (ll i = a; i < ll(b); i += c) #define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__) #define rrep1(n) for (ll i = n; i--;) #define rrep2(i,n) for (ll i = n; i--;) #define rrep3(i,a,b) for (ll i = b; i-- > (a);) #define rrep4(i,a,b,c) for (ll i = (a) + ((b) - (a) - 1) / (c) * (c); i >= (a); i -= c) #define rrep(...) overload4(__VA_ARGS__,rrep4,rrep3,rrep2,rrep1)(__VA_ARGS__) #define all(container) begin(container), end(container) #define rall(container) rbegin(container), rend(container) #define Vvll(name,row,column) vvll name(row, vll (column)) #define Max(...) max({__VA_ARGS__}) #define Min(...) min({__VA_ARGS__}) #define fin exit(0) #define FASTIO ios::sync_with_stdio(false); cin.tie(nullptr) #define FLOUT cout << setprecision(15) << fixed #ifdef LOCAL #define debug(x) cerr << "[DEBUG] " << __LINE__ << ": " << #x << " = " << x << endl #else #define debug(x) #endif constexpr int INF = 1001001001; constexpr ll LINF = 1LL << 60; const double PI = acos(-1); template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } ll fact(ll x) { return x == 0 ? 1 : x * fact(x - 1); } ll comb(ll n, ll r) { if (r < 0 || n < r) return 0; ll ret = 1; for (ll i = 1; i <= r; i++) { ret *= n; n--; ret /= i; } return ret; } // void prfl(double x) { printf("%.15f\n", x); } bool ise(ll x) { return x % 2 == 0; } bool dv(ll waru, ll warareru) { return warareru % waru == 0; } int ci(char c) { return c - '0'; } char ic(int i) { return '0' + i; } int Yes(bool f=1) { cout << (f ? "Yes" : "No") << '\n'; return 0; } int No() { Yes(0); return 0; } template<class T> int printvec(vector<T> v) { for (int i = 0; i < (int) v.size(); i++) cout << (i ? " " : "") << v[i]; cout << '\n'; return 0; } #pragma endregion #include <atcoder/segtree.hpp> signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n; string s; cin >> n >> s; int st; for (int i = 0; i < n; i++) { if (s[i] == '#') { st = i; break; } } s = '.' + s; n++; st++; ll ans = n - st; int sh = 0; int pr = 0; int prr = 0; for (int i = 0; i < n; i++) { if (s[i] == '.') { ans += max(0, sh - prr); pr++; sh = 0; } else { if (i > 0 && s[i - 1] == '.') { prr = pr; pr = 0; } sh++; } } ans += max(0, sh - prr); cout << ans << '\n'; }