BIẾN ĐỔI XÂU

View as PDF

Submit solution

Points: 100.00 (partial)
Time limit: 1.0s
Memory limit: 512M
Input: stdin
Output: stdout

Problem type
Allowed languages
C++, Pascal, Python

In case the statement didn't load correctly, you can download the statement here: Statement


Comments

Please read the guidelines before commenting.



  • 0
    khoasadnhan   commented on April 16, 2025, 8:11 p.m.

    def doixau(s, list1): s = list(s)
    for i, j, c1, c2 in list1: for k in range(i, j+1): if s[k] == c1: s[k] = c2 return "".join(s)

    s = input().strip() m = int(input().strip()) list1 = [tuple(input().split()) for _ in range(m)] list1 = [(int(i), int(j), c1, c2) for i, j, c1, c2 in list1] print(doixau(s,list1))


  • 0
    Thaibaohp   commented on March 29, 2025, 3:49 p.m.

    ngôn ngữ gì vậy


  • 1
    duy_khanh_2k7   commented on Feb. 23, 2025, 7:22 p.m. edit 2
    #include <iostream>
    #include <string>
    #include <algorithm>
    
    int main() {
        std::string string;
        std::getline(std::cin, string);
        int _;
        std::cin >> _;
        size_t start, end;
        char _from, _to;
        while (std::cin >> start >> end >> _from >> _to) {
            std::replace(string.begin() + start, string.begin() + end + 1, _from, _to);
        }
        std::cout << string;
    }
    

    Quá thời gian từ test thứ 9 trở đi


    • 1
      lovevsick   commented on March 28, 2025, 8:22 p.m.

      vậy là tốt rồi, tôi quá thời gian từ 4 trở đi T_T


  • -2
    anhkiet1306   commented on Jan. 25, 2025, 11:39 a.m.

    cho xin code


  • 0
    tamduc   commented on June 18, 2024, 10:43 a.m.

    hehehe


  • -1
    Hoang_Linh   commented on June 17, 2024, 10:36 a.m.

    Bn nào biết tối ưu python 80/100 ko giúp mình với


    • -1
      tinhoctredtsd   commented on Feb. 11, 2025, 10:19 a.m.

      bạn thử dùng pypy đi, có thể sẽ hết TLE


  • 0
    HDG_12   commented on June 16, 2024, 9:46 p.m.

    cứu


  • 0
    KVMB23A_67   commented on June 8, 2024, 9:01 p.m.

    bài này khó quá


  • 0
    KDF5A   commented on June 6, 2024, 6:52 p.m.

    Có ai bị lỗi chữ a thành ký tự ? trong tam giác k