답안 #872732

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
872732 2023-11-13T16:00:05 Z binh192004 고장난 휴대전화기 (COCI14_mobitel) C++17
50 / 50
2 ms 7508 KB
#include <bits/stdc++.h>
#include <iostream>
#include <stack>
#include <vector>
#include <set>
#include <queue>
#include <string>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>

using namespace std;

typedef long double ld;
mt19937_64 rnd(chrono::steady_clock::now().time_since_epoch().count());
//#define int long long
#define double long double
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define lowbit(x) x & (-x);
#define inf 1e18
#define _inf -1e18
#define pyes cout << "YES" << endl
#define pno cout << "NO" << endl
#define inv(a) for (int& x: a) cin >> x;
#define llv(a) for (ll& x: a) cin >> x;
#define pri(a) for (int& x: a) cout << x << '\n'
int const MOD = 998244353;
int const lg = 20;
int const block = 500;
// int block;
int const MAX = 3e5 + 1, N = 4000;
int n, m, q, k;

struct SEG {
      int n;
      vector<int> tree, a, lazy;
#define lc id*2
#define rc id*2+1
#define mid (l+r)/2

      SEG() {}
      SEG(int n) : n(n) {
            tree = lazy = vector<int>(4 * n + 1);
      }

      void push(int id, int l, int r) {
            if (!lazy[id])
                  return;
            tree[id] += lazy[id];
            if (l != r) {
                  lazy[lc] += lazy[id];
                  lazy[rc] += lazy[id];
            }
            lazy[id] = 0;
      }

      void update(int id, int l, int r, int u, int v, int val) {
            push(id, l, r);
            if (u > r || l > v)
                  return;
            if (u <= l && r <= v) {
                  lazy[id] += val;
                  push(id, l, r);
                  return;
            }
            update(lc, l, mid, u, v, val);
            update(rc, mid + 1, r, u, v, val);
            tree[id] = max(tree[lc], tree[rc]);
      }

      int get(int id, int l, int r, int u, int v){
            push(id, l, r);
            if (l > v || u > r)
                  return 0;
            if (u <= l && r <= v)
                  return tree[id];
            return max(get(lc, l, mid, u, v), get(rc, mid + 1, r, u, v));
      }
};
vector<tuple<int, int, int, int>> save[MAX];
struct fenwick{
      int n;
      vector<int> bit;
      fenwick() = default;
      fenwick(int n): n(n){
            bit.resize(n + 1);
      }
      void add(int id, int val){
            while (id){
                  bit[id] += val;
                  id -= lowbit(id);
            }
      }
      int get(int id){
            int ans = 0;
            while (id <= n){
                  ans += bit[id];
                  id += lowbit(id);
            }
            return ans;
      }
};

void bexuyen67() {
      int cnt = 0;
      vector<pii> pos(26);
      int key = 2;
      for (int i = 0; i < 26; i++){
            cnt++;
            pos[i] = {key, cnt};
            if (key != 7 && key != 9){
                  if (cnt == 3){
                        cnt = 0, key++;
                  }
            }
            else{
                  if (cnt == 4){
                        cnt = 0, key++;
                  }
            }
      }
      vector<int> change(10);
      for (int i = 1, x; i <= 9; i++){
            cin >> x;
            change[x] = i;
      }
      string s;
      cin >> s;
      int pre = 0;
      for (char x: s){
            if (pos[x - 'a'].first == pre)
                  cout << '#';
            for (int i = 0; i < pos[x - 'a'].second; i++)
                  cout << change[pos[x - 'a'].first];
            pre = pos[x - 'a'].first;
      }
}

signed main() {
#ifdef binhball
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
#endif
      cin.tie(0)->sync_with_stdio(0);
      cout << fixed << setprecision(15);
      int t = 1;
//      cin >> t;
      while (t--)
            bexuyen67();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 7256 KB Output is correct
2 Correct 2 ms 7260 KB Output is correct
3 Correct 2 ms 7260 KB Output is correct
4 Correct 2 ms 7476 KB Output is correct
5 Correct 2 ms 7268 KB Output is correct
6 Correct 2 ms 7256 KB Output is correct
7 Correct 2 ms 7260 KB Output is correct
8 Correct 2 ms 7260 KB Output is correct
9 Correct 2 ms 7508 KB Output is correct
10 Correct 2 ms 7260 KB Output is correct