Submission #73701917


Source Code Expand

import java.util.Scanner;



public class Main {
	public static void main(String[] args) {
		new Main().C();
		//new C().go();
	}
	
	void A() {
		Scanner in = new Scanner(System.in);

		int N = in.nextInt();
		int M = in.nextInt();

		int max = (N+1)/2;

		System.out.println( max>=M ? "Yes":"No" );
	}


	
	void B() {
		Scanner in = new Scanner(System.in);

		String s = in.next();
		int[] count = new int[26];
		
		for (int i=0;i<s.length();i++) {
			char ch = s.charAt(i);
			count[ch-'a']++;
		}

		int max=0;
		for (int i=0;i<count.length;i++) {
			max = Integer.max(max,count[i]);
		}

		StringBuilder sb = new StringBuilder();
		for (int i=0;i<s.length();i++) {
			char ch = s.charAt(i);
			if ( count[ch-'a'] == max ) {
				
			} else {
				sb.append(ch);
			}
		}
		
		System.out.println(sb.toString());
	}

	void C() {
		int ret = C2();
		System.out.println( ret );
	}
	int C2() {
		Scanner in = new Scanner(System.in);
		String S = in.next() +"#";
		String T = in.next() +"#";
		
		int x=0,y=0;
		int step = 0;
		while (true) {
			int x0=0;
			int y0=0;
			while ( S.charAt(x) == 'A' ) {x++;x0++;}
			while ( T.charAt(y) == 'A' ) {y++;y0++;}
			
			//System.out.println( S.charAt(x) + " " + T.charAt(y) );
			
			if ( S.charAt(x) != T.charAt(y) ) return -1;
			
			step += Math.abs(x0-y0);
			if ( S.charAt(x) == '#' ) return step;
			x++;y++;
		}
	}
}
class C {
	int N;
	
	public C() {
	}
	
	void go() {
		System.out.println(N);
	}

}

/**
 * AllPatternDegi(int N, int D): D進数のN桁全組み合わせを列挙するクラス。
 * boolean next(): 次の組み合わせに進み、状態が更新される。全列挙が終わると false を返す。
 * int[] getStatus(): 現在の組み合わせ(状態)を取得する。
 */
class allPatternDegi {
	int N,D;
	int[] status;
	
	public allPatternDegi(int n,int d) {
		N = n;
		D = d;
		status = null;
	}
	
	boolean next() {
		if ( status==null ) {
			status = new int[N];
			return true;
		}
		
		int idx=0;
		while ( idx<N ) {
			status[idx]++;
			if ( status[idx]<D ) return true;
			
			status[idx]=0;
			idx++;
		}
		
		return false;
	}
}

Submission Info

Submission Time
Task C - Insert and Erase A
User yellowsubmarine
Language Java24 (OpenJDK 24.0.2)
Score 300
Code Size 2238 Byte
Status AC
Exec Time 241 ms
Memory 47952 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 33
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 02_random2_08.txt, 02_random2_09.txt, 02_random2_10.txt, 02_random2_11.txt, 03_random3_00.txt, 03_random3_01.txt, 03_random3_02.txt, 03_random3_03.txt, 04_handmade_00.txt, 04_handmade_01.txt, 04_handmade_02.txt, 04_handmade_03.txt, 04_handmade_04.txt, 04_handmade_05.txt, 04_handmade_06.txt, 04_handmade_07.txt, 04_handmade_08.txt, 04_handmade_09.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 71 ms 40396 KiB
00_sample_01.txt AC 71 ms 40656 KiB
00_sample_02.txt AC 69 ms 41160 KiB
00_sample_03.txt AC 68 ms 39964 KiB
01_random_00.txt AC 121 ms 43496 KiB
01_random_01.txt AC 128 ms 43800 KiB
01_random_02.txt AC 175 ms 45748 KiB
02_random2_00.txt AC 162 ms 44812 KiB
02_random2_01.txt AC 171 ms 47144 KiB
02_random2_02.txt AC 241 ms 46880 KiB
02_random2_03.txt AC 239 ms 46696 KiB
02_random2_04.txt AC 166 ms 46352 KiB
02_random2_05.txt AC 161 ms 46164 KiB
02_random2_06.txt AC 176 ms 46328 KiB
02_random2_07.txt AC 162 ms 46940 KiB
02_random2_08.txt AC 212 ms 46896 KiB
02_random2_09.txt AC 235 ms 46708 KiB
02_random2_10.txt AC 166 ms 45076 KiB
02_random2_11.txt AC 215 ms 47844 KiB
03_random3_00.txt AC 224 ms 46748 KiB
03_random3_01.txt AC 188 ms 47048 KiB
03_random3_02.txt AC 164 ms 44948 KiB
03_random3_03.txt AC 145 ms 45380 KiB
04_handmade_00.txt AC 70 ms 40744 KiB
04_handmade_01.txt AC 83 ms 40684 KiB
04_handmade_02.txt AC 69 ms 40192 KiB
04_handmade_03.txt AC 69 ms 40268 KiB
04_handmade_04.txt AC 206 ms 47952 KiB
04_handmade_05.txt AC 222 ms 47340 KiB
04_handmade_06.txt AC 228 ms 46668 KiB
04_handmade_07.txt AC 192 ms 47500 KiB
04_handmade_08.txt AC 133 ms 46852 KiB
04_handmade_09.txt AC 149 ms 46700 KiB