fork download
  1. #!/usr/bin/perl -l
  2.  
  3. use warnings;
  4. use strict;
  5.  
  6. <>;
  7.  
  8. while(<>){
  9. my( undef, $K ) = split;
  10.  
  11. my $A = <>;
  12. chomp $A;
  13. my $B = <>;
  14. chomp $B;
  15.  
  16. my $ok;
  17. my $c = 27;
  18.  
  19. while( $c -- ){
  20. $A ++;
  21. last if $A eq $B;
  22. last if $A =~ $K and $ok = $A;
  23. }
  24.  
  25. print defined $ok ? $ok : 'NO';
  26. }
Success #stdin #stdout 0.01s 5432KB
stdin
X
10 m
christmasa
christmasx
6 m
spring
winter
21 a
ithinkthereforeisleep
ithinkthereforeithink
3 z
tcs
tcz
3 a
tcs
tcz
5 a
izzzb
jzzzc
1 a
b
c
2 m
ma
mb
2 a
mz
oa
stdout
christmasb
sprinm
ithinkthereforeislefa
NO
NO
jaaaa
NO
NO
na