第2回早稲田大学プログラミングコンテスト

Submission #1652640

Source codeソースコード

// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  int n;
  string s;
  cin >> n >> s;
  vi dp(n, INF);
  rep(i, 3) dp[i] = s[i] == 'X';
  loop(i, 3, n) rep(j, 3) cmin(dp[i], dp[i - j - 1] + (s[i] == 'X'));
  cout << dp.back() << endl;
}

Submission

Task問題 B - 雨上がり
User nameユーザ名 vvataarne
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 50
Source lengthソースコード長 1650 Byte
File nameファイル名
Exec time実行時間 1 ms
Memory usageメモリ使用量 256 KB

Test case

Set

Set name Score得点 / Max score Cases
All 50 / 50 case_000.txt,case_001.txt,case_002.txt,case_003.txt,case_004.txt,case_005.txt,case_006.txt,case_007.txt,case_008.txt,case_009.txt,case_010.txt,case_011.txt,case_012.txt,case_013.txt,case_014.txt,case_015.txt,case_016.txt,case_017.txt,case_018.txt,case_019.txt,case_020.txt,case_021.txt,case_022.txt,case_023.txt,case_024.txt,case_025.txt,case_026.txt,case_027.txt,case_028.txt,case_029.txt,case_030.txt,case_031.txt,case_032.txt,case_033.txt,case_034.txt,case_035.txt,case_036.txt,case_037.txt,case_038.txt,case_039.txt,case_040.txt,case_041.txt,case_042.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
case_000.txt AC 1 ms 256 KB
case_001.txt AC 1 ms 256 KB
case_002.txt AC 1 ms 256 KB
case_003.txt AC 1 ms 256 KB
case_004.txt AC 1 ms 256 KB
case_005.txt AC 1 ms 256 KB
case_006.txt AC 1 ms 256 KB
case_007.txt AC 1 ms 256 KB
case_008.txt AC 1 ms 256 KB
case_009.txt AC 1 ms 256 KB
case_010.txt AC 1 ms 256 KB
case_011.txt AC 1 ms 256 KB
case_012.txt AC 1 ms 256 KB
case_013.txt AC 1 ms 256 KB
case_014.txt AC 1 ms 256 KB
case_015.txt AC 1 ms 256 KB
case_016.txt AC 1 ms 256 KB
case_017.txt AC 1 ms 256 KB
case_018.txt AC 1 ms 256 KB
case_019.txt AC 1 ms 256 KB
case_020.txt AC 1 ms 256 KB
case_021.txt AC 1 ms 256 KB
case_022.txt AC 1 ms 256 KB
case_023.txt AC 1 ms 256 KB
case_024.txt AC 1 ms 256 KB
case_025.txt AC 1 ms 256 KB
case_026.txt AC 1 ms 256 KB
case_027.txt AC 1 ms 256 KB
case_028.txt AC 1 ms 256 KB
case_029.txt AC 1 ms 256 KB
case_030.txt AC 1 ms 256 KB
case_031.txt AC 1 ms 256 KB
case_032.txt AC 1 ms 256 KB
case_033.txt AC 1 ms 256 KB
case_034.txt AC 1 ms 256 KB
case_035.txt AC 1 ms 256 KB
case_036.txt AC 1 ms 256 KB
case_037.txt AC 1 ms 256 KB
case_038.txt AC 1 ms 256 KB
case_039.txt AC 1 ms 256 KB
case_040.txt AC 1 ms 256 KB
case_041.txt AC 1 ms 256 KB
case_042.txt AC 1 ms 256 KB