top of page

CCC '24 J4 - Troublesome Keys

s1 = input()
s2 = input()

silly = ''
silly_o = ''

quiete = '-'
i = 0
j = 0

while i < len(s1) and j < len(s2):
    if s1[i] != s2[j]:
        if s1[i] == silly:
            i += 1
            j += 1
        elif s1[i] == quiete:
            i += 1

        elif silly == '' and quiete != '-':
            silly = s1[i]
            silly_o = s2[j]
            break
        elif silly != '' and quiete == '-':
            quiete = s1[i]
            break
        elif silly == '' and quiete == '-':
            if i + 1 >= len(s1):
                silly = s1[i]
                silly_o = s2[j]
                break
            else:
                m = i
                while m < len(s1) and s1[m] == s1[i]:
                    m += 1
                if m == len(s1):
                    silly = s1[i]
                    silly_o = s2[j]
                    break
                elif s1[m] == s2[j]:
                    quiete = s1[i]
                    i = m
                else:
                    silly = s1[i]
                    silly_o = s2[j]
                    i = m
                    j = m

    else:
        i += 1
        j += 1

if i < len(s1) and j >= len(s2):
  quiete = s1[i]

print(silly + ' ' + silly_o)
print(quiete)

Recent Posts

See All

CCC 2013 J5/S3

#include <iostream> #include <string> #include <map> #include <vector> #include <algorithm> #include <cmath> using namespace std; char...

Comments


bottom of page