結果

問題 No.2773 Wake up Record 1
ユーザー ks2mks2m
提出日時 2024-06-07 21:39:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 214 ms / 2,000 ms
コード長 533 bytes
コンパイル時間 1,726 ms
コンパイル使用メモリ 74,400 KB
実行使用メモリ 43,348 KB
最終ジャッジ日時 2024-06-07 21:39:48
合計ジャッジ時間 6,526 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 107 ms
41,176 KB
testcase_01 AC 106 ms
41,256 KB
testcase_02 AC 109 ms
41,512 KB
testcase_03 AC 93 ms
40,028 KB
testcase_04 AC 93 ms
39,948 KB
testcase_05 AC 182 ms
42,832 KB
testcase_06 AC 151 ms
41,544 KB
testcase_07 AC 183 ms
42,724 KB
testcase_08 AC 164 ms
41,920 KB
testcase_09 AC 161 ms
42,048 KB
testcase_10 AC 155 ms
42,068 KB
testcase_11 AC 176 ms
43,172 KB
testcase_12 AC 196 ms
42,288 KB
testcase_13 AC 139 ms
41,688 KB
testcase_14 AC 171 ms
42,296 KB
testcase_15 AC 120 ms
41,072 KB
testcase_16 AC 179 ms
43,348 KB
testcase_17 AC 176 ms
42,996 KB
testcase_18 AC 123 ms
40,772 KB
testcase_19 AC 190 ms
42,992 KB
testcase_20 AC 126 ms
41,024 KB
testcase_21 AC 183 ms
43,148 KB
testcase_22 AC 174 ms
43,288 KB
testcase_23 AC 214 ms
42,816 KB
testcase_24 AC 167 ms
42,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] s = sc.next().toCharArray();
		sc.close();

		int cnt = 0;
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i < n; i++) {
			if (s[i - 1] == 'x' && s[i] == 'o') {
				cnt++;
				sb.append(i + 1).append(' ');
			}
		}
		System.out.println(cnt);
		if (cnt > 0) {
			sb.deleteCharAt(sb.length() - 1);
		}
		System.out.println(sb.toString());
	}
}
0