結果

問題 No.548 国士無双
ユーザー moti
提出日時 2018-05-20 17:27:36
言語 Perl
(5.40.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 524 bytes
コンパイル時間 340 ms
コンパイル使用メモリ 6,684 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-17 14:49:44
合計ジャッジ時間 1,313 ms
ジャッジサーバーID
(参考情報)
judge6 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

#!/usr/bin/env perl

use strict;
use warnings;

my $target = "abcdefghijklm";
my %h;
my $count2 = 0;
my $twoer;
my $s = <>; chomp$s;
for my $c (split//, $s) {
  $h{$c}++;
  if ($h{$c} >= 2) {
    if ($count2 == 1) {
      print "Impossible\n";
      exit;
    }
    $count2 = 1;
    $twoer = $c;
  }
  if ($target !~ /$c/) {
    print "Impossible\n";
    exit;
  }
}

if ($twoer) {
  for my $tch (split//, $target) {
    if (!exists$h{$tch}) {
      print "$tch\n";
      exit;
    }
  }
}
print join("\n", split//,$target)
0