답안 #1030589

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1030589 2024-07-22T07:14:25 Z fuad27 Vim (BOI13_vim) C++17
11.7222 / 100
55 ms 59740 KB
#include <bits/stdc++.h>
using namespace std;
 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define vt vector
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
template<class T> bool chmin(T& a, const T& b) {
	return b<a?a=b, 1:0;
}
template<class T> bool chmax(T& a, const T& b) { 
	return a<b?a=b, 1:0;
} 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

int k(int a, int b) {
 if(a==b)return 1e9;
 return 0;
}
int u(int v) {
  if(v)return 1e9;
  return 0;
}
int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);
  int n;
  string s;
  cin >> n >> s;
  int ans=0;
  reverse(all(s));
  while(sz(s) and s.back() == 'e') {
    ans++;
    s.pop_back();
  }
  reverse(all(s));
  vt<bool> need(n);
  {
    string tmp = "";
    for(int i = 0;i<n;i++) {
      if(s[i] == 'e') {
        ans+=2;
        continue;
      }
      if(i == 0 or s[i-1] == 'e') {
        need[tmp.size()]=1;
      }
      tmp.push_back(s[i]);
      tmp.back()-='a';
    }
    swap(tmp, s);
  }
  n=s.size();
  vt dp2(n+1, vt(12, vt(12, 0)));
  vt dp1(n+1, vt(12, (int)1e9));
  for(int i = 0;i<12;i++) {
    if(s[i] != i)dp1[0][i] = 2;
  }
 for(int i = 0;i<n;i++) {
    for(int j = 0;j<12;j++) {
      dp1[i+1][j] = min({dp1[i][j] + k(s[i], j) + u(need[i]), dp1[i][s[i]] + 2, dp2[i][s[i]][j]+k(s[i], j), dp2[i][s[i]][s[i]]+2});
      for(int l = 0;l<12;l++) {
        dp2[i+1][j][l] = min({dp1[i][j] + 3 + k(j, s[i]), dp1[i][s[i]] + 5, dp2[i][j][l]+1  + k(j, s[i]) + k(l, s[i]), dp2[i][s[i]][s[i]]+5});
      }
    }
  }
 ans+=dp1[n][11];
 cout << ans << "\n";
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Incorrect 1 ms 716 KB Output isn't correct
3 Incorrect 0 ms 604 KB Output isn't correct
4 Correct 1 ms 856 KB Output is correct
5 Incorrect 0 ms 604 KB Output isn't correct
6 Incorrect 1 ms 860 KB Output isn't correct
7 Incorrect 1 ms 604 KB Output isn't correct
8 Incorrect 0 ms 348 KB Output isn't correct
9 Incorrect 0 ms 348 KB Output isn't correct
10 Incorrect 0 ms 348 KB Output isn't correct
11 Correct 0 ms 348 KB Output is correct
12 Incorrect 0 ms 348 KB Output isn't correct
13 Incorrect 1 ms 604 KB Output isn't correct
14 Incorrect 1 ms 604 KB Output isn't correct
15 Incorrect 1 ms 604 KB Output isn't correct
16 Incorrect 1 ms 604 KB Output isn't correct
17 Incorrect 1 ms 604 KB Output isn't correct
18 Incorrect 0 ms 604 KB Output isn't correct
19 Incorrect 0 ms 604 KB Output isn't correct
20 Incorrect 0 ms 604 KB Output isn't correct
21 Correct 0 ms 604 KB Output is correct
22 Incorrect 1 ms 604 KB Output isn't correct
23 Incorrect 1 ms 860 KB Output isn't correct
24 Incorrect 1 ms 860 KB Output isn't correct
25 Incorrect 1 ms 604 KB Output isn't correct
26 Correct 1 ms 604 KB Output is correct
27 Incorrect 1 ms 604 KB Output isn't correct
28 Incorrect 1 ms 604 KB Output isn't correct
29 Correct 1 ms 604 KB Output is correct
30 Incorrect 1 ms 860 KB Output isn't correct
31 Incorrect 1 ms 604 KB Output isn't correct
32 Incorrect 1 ms 860 KB Output isn't correct
33 Correct 1 ms 860 KB Output is correct
34 Correct 1 ms 604 KB Output is correct
35 Incorrect 0 ms 604 KB Output isn't correct
36 Incorrect 1 ms 604 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2396 KB Output isn't correct
2 Incorrect 4 ms 3420 KB Output isn't correct
3 Correct 2 ms 1884 KB Output is correct
4 Incorrect 2 ms 2452 KB Output isn't correct
5 Correct 3 ms 3420 KB Output is correct
6 Incorrect 5 ms 4680 KB Output isn't correct
7 Incorrect 3 ms 3164 KB Output isn't correct
8 Incorrect 3 ms 3164 KB Output isn't correct
9 Incorrect 3 ms 3420 KB Output isn't correct
10 Incorrect 3 ms 3676 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 52060 KB Output isn't correct
2 Incorrect 46 ms 50004 KB Output isn't correct
3 Incorrect 48 ms 52820 KB Output isn't correct
4 Incorrect 44 ms 53596 KB Output isn't correct
5 Incorrect 50 ms 59740 KB Output isn't correct
6 Incorrect 25 ms 27228 KB Output isn't correct
7 Incorrect 41 ms 44636 KB Output isn't correct
8 Incorrect 46 ms 52060 KB Output isn't correct
9 Incorrect 36 ms 38492 KB Output isn't correct
10 Incorrect 34 ms 36564 KB Output isn't correct
11 Incorrect 50 ms 53588 KB Output isn't correct
12 Incorrect 55 ms 59732 KB Output isn't correct
13 Incorrect 54 ms 58968 KB Output isn't correct
14 Incorrect 53 ms 57644 KB Output isn't correct
15 Incorrect 46 ms 48476 KB Output isn't correct
16 Incorrect 49 ms 52968 KB Output isn't correct
17 Incorrect 49 ms 52060 KB Output isn't correct
18 Incorrect 53 ms 52828 KB Output isn't correct
19 Incorrect 46 ms 50004 KB Output isn't correct
20 Incorrect 40 ms 42076 KB Output isn't correct