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 '24 J5 - Harvest Waterloo

#include<iostream> #include <vector> #include <algorithm> #include <cmath> #include <stack> using namespace std; int main() { int r, c,...

CCC '22 J5 - Square Pool

#include<iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; bool rowcom(pair<int, int> a, pair<int,...

CCC 2013 J5/S3

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

One-time Donations
I hope I can solve all CCC problems!,
Please e-transfer cccottawa862008@gmail.com

Subscribe to AIOICode newsletter

I'm a title. ​Click here to edit me.

Thanks for submitting!

  • Twitter
  • Facebook
  • Linkedin

© 2023 by AIOICode.

bottom of page