提出 #43625129
ソースコード 拡げる
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main {
public static void main(String[] args) throws Exception {
try (Scanner scanner = new Scanner(System.in)) {
int n = scanner.nextInt();
Set<String> set = new HashSet<>();
Set<String> allSet = new HashSet<>();
for (int i = 0; i < n; i++) {
String s = scanner.next();
StringBuilder builder = new StringBuilder();
for (int j = s.length() - 1; j >= 0; j--) {
builder.append(s.charAt(j));
}
String reverse = builder.toString();
int size = allSet.size();
allSet.remove(s);
allSet.remove(reverse);
int removeSize = allSet.size();
if (size == removeSize) {
set.add(s);
}
allSet.add(s);
allSet.add(reverse);
}
System.out.println(set.size());
}
}
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | C - Reversible |
| ユーザ | kmatsu |
| 言語 | Java (OpenJDK 11.0.6) |
| 得点 | 300 |
| コード長 | 851 Byte |
| 結果 | AC |
| 実行時間 | 396 ms |
| メモリ | 68604 KiB |
ジャッジ結果
| セット名 | Sample | All | ||||
|---|---|---|---|---|---|---|
| 得点 / 配点 | 0 / 0 | 300 / 300 | ||||
| 結果 |
|
|
| セット名 | テストケース |
|---|---|
| Sample | example0.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, example0.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 000.txt | AC | 209 ms | 40200 KiB |
| 001.txt | AC | 194 ms | 40740 KiB |
| 002.txt | AC | 396 ms | 56460 KiB |
| 003.txt | AC | 384 ms | 56144 KiB |
| 004.txt | AC | 318 ms | 61448 KiB |
| 005.txt | AC | 352 ms | 68604 KiB |
| 006.txt | AC | 181 ms | 39116 KiB |
| 007.txt | AC | 172 ms | 39268 KiB |
| 008.txt | AC | 177 ms | 39324 KiB |
| 009.txt | AC | 332 ms | 57372 KiB |
| 010.txt | AC | 269 ms | 54900 KiB |
| 011.txt | AC | 248 ms | 54296 KiB |
| 012.txt | AC | 271 ms | 55008 KiB |
| 013.txt | AC | 319 ms | 55568 KiB |
| 014.txt | AC | 186 ms | 40972 KiB |
| 015.txt | AC | 187 ms | 41136 KiB |
| 016.txt | AC | 200 ms | 41336 KiB |
| 017.txt | AC | 182 ms | 39244 KiB |
| 018.txt | AC | 175 ms | 39320 KiB |
| 019.txt | AC | 197 ms | 39544 KiB |
| 020.txt | AC | 190 ms | 40352 KiB |
| 021.txt | AC | 187 ms | 40108 KiB |
| example0.txt | AC | 105 ms | 35304 KiB |