結果

問題 No.3261 yiwiy9 → yiwiY9
ユーザー ts5208
提出日時 2025-09-06 14:53:51
言語 C++17(gnu拡張)
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,890 bytes
コンパイル時間 2,051 ms
コンパイル使用メモリ 196,072 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-09-06 14:54:01
合計ジャッジ時間 3,092 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12 WA * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

// ======================== ORIGINAL PYTHON CODE (AS REQUIRED) ========================
// from heapq import heappop, heappush, heapify
// from bisect import bisect
// #from sortedcontainers import SortedList
// from collections import deque, defaultdict
// from math import floor, ceil, isqrt, comb
// from sys import stdin, setrecursionlimit
// #setrecursionlimit(10**7)
// intin = lambda: int(stdin.readline())
// strin = lambda: stdin.readline().rstrip()
// listin = lambda: list(map(int, stdin.readline().split()))
// tuplein = lambda m: [tuple(map(lambda x: int(x) if x.isdigit() or (len(x) > 1 and x[0] == "-" and x[1:].isdigit()) else x, stdin.readline().split())) for _ in range(m)]
// gridin = lambda m: [list(map(int, stdin.readline().split())) for _ in range(m)]
// strgridin = lambda h: [stdin.readline().rstrip() for _ in range(h)]
// mapin = lambda: map(int, stdin.readline().split())
// H, W = mapin()
// S = strgridin(H)
// for i in range(H):
//     S[i] = S[i].replace("yiwiy9", "yiwiY9")
//     S[i] = S[i].replace("9yiwiy", "9Yiwiy")
//     print(S[i])
// ====================================================================================

#include <bits/stdc++.h>
using namespace std;

static void replace_all(string &s, const string &from, const string &to) {
    if (from.empty()) return;
    size_t pos = 0;
    while ((pos = s.find(from, pos)) != string::npos) {
        s.replace(pos, from.size(), to);
        pos += to.size(); // non-overlapping, matches Python's replace behavior
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int H, W;
    if (!(cin >> H >> W)) return 0;
    vector<string> S(H);
    for (int i = 0; i < H; ++i) cin >> S[i];

    for (int i = 0; i < H; ++i) {
        replace_all(S[i], "yiwiy9", "yiwiY9");
        replace_all(S[i], "9yiwiy", "9Yiwiy");
        cout << S[i] << '\n';
    }
    return 0;
}
0