結果

問題 No.225 文字列変更(medium)
ユーザー mikoto1357mikoto1357
提出日時 2015-06-12 22:38:30
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 755 bytes
コンパイル時間 5,610 ms
コンパイル使用メモリ 75,916 KB
実行使用メモリ 61,428 KB
最終ジャッジ日時 2023-09-20 21:07:20
合計ジャッジ時間 8,944 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 RE -
testcase_02 AC 157 ms
56,944 KB
testcase_03 AC 156 ms
56,736 KB
testcase_04 WA -
testcase_05 RE -
testcase_06 AC 158 ms
57,240 KB
testcase_07 WA -
testcase_08 RE -
testcase_09 RE -
testcase_10 WA -
testcase_11 RE -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Yukicoder225{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		String s = scan.next();
		String t = scan.next();
		int kazu = 0;
		for(int i = 0;i < s.length();i++){
			if(s.charAt(i) != t.charAt(i) || i == s.length() - 1){
				if(i == s.length() - 1 && s.length() < m){
					s += t.substring(s.length() , s.length() + 1);
					if(s.length() == m){
						kazu++;
						break;
					}
				}else if(s.charAt(i + 1) == t.charAt(i)){
					s = s.substring(0,i) + s.substring(i+1,s.length());
				}else{
					s = s.substring(0,i) + t.substring(i,i+1) + s.substring(i+1,s.length());
				}
				kazu++;
			}
		}
		System.out.println(kazu);
	}
}
0