Submission #28026962
Source Code Expand
import java.util.Arrays;
import java.util.Scanner;
/**
* B - Caesar Cipher
*/
public class Main {
public static void main( String[] args ) {
// 入力値
Scanner sc = new Scanner( System.in );
char[] s = sc.next().toCharArray();
char[] t = sc.next().toCharArray();
sc.close();
char[] c = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' };
String result = "Yes";
int firstSIdx = Arrays.binarySearch( c, s[0] );
int firstTIdx = Arrays.binarySearch( c, t[0] );
int diffIdx = firstTIdx > firstSIdx ? firstTIdx - firstSIdx : ( firstTIdx + c.length ) - firstSIdx;
for( int i = 0; i < s.length; i++ ) {
int sIndex = Arrays.binarySearch( c, s[i] );
int tIndex = Arrays.binarySearch( c, t[i] );
int tmp = sIndex + diffIdx;
int tmpIdx = tmp >= 26 ? tmp - 26 : tmp;
if( c[tmpIdx] != t[i] ) {
result = "No";
break;
}
}
System.out.println( result );
}
}
Submission Info
| Submission Time |
|
| Task |
B - Caesar Cipher |
| User |
fetia |
| Language |
Java (OpenJDK 11.0.6) |
| Score |
200 |
| Code Size |
1184 Byte |
| Status |
AC |
| Exec Time |
221 ms |
| Memory |
40380 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
200 / 200 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
example0.txt, example1.txt, example2.txt, example3.txt |
| All |
000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, example0.txt, example1.txt, example2.txt, example3.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 000.txt |
AC |
110 ms |
35444 KiB |
| 001.txt |
AC |
184 ms |
39844 KiB |
| 002.txt |
AC |
157 ms |
39656 KiB |
| 003.txt |
AC |
155 ms |
39364 KiB |
| 004.txt |
AC |
155 ms |
38228 KiB |
| 005.txt |
AC |
202 ms |
39904 KiB |
| 006.txt |
AC |
194 ms |
39888 KiB |
| 007.txt |
AC |
194 ms |
40080 KiB |
| 008.txt |
AC |
200 ms |
39820 KiB |
| 009.txt |
AC |
195 ms |
39932 KiB |
| 010.txt |
AC |
184 ms |
40112 KiB |
| 011.txt |
AC |
187 ms |
40224 KiB |
| 012.txt |
AC |
182 ms |
40164 KiB |
| 013.txt |
AC |
221 ms |
40228 KiB |
| 014.txt |
AC |
194 ms |
40268 KiB |
| 015.txt |
AC |
203 ms |
40256 KiB |
| 016.txt |
AC |
205 ms |
39924 KiB |
| 017.txt |
AC |
174 ms |
39796 KiB |
| 018.txt |
AC |
210 ms |
40380 KiB |
| 019.txt |
AC |
105 ms |
35584 KiB |
| 020.txt |
AC |
204 ms |
40320 KiB |
| 021.txt |
AC |
221 ms |
40228 KiB |
| 022.txt |
AC |
199 ms |
40200 KiB |
| example0.txt |
AC |
109 ms |
35548 KiB |
| example1.txt |
AC |
104 ms |
35332 KiB |
| example2.txt |
AC |
109 ms |
35424 KiB |
| example3.txt |
AC |
93 ms |
35324 KiB |