Created
January 3, 2021 01:14
-
-
Save monhime/4c599a49ee9636cbd4c810ba02e4e9ee to your computer and use it in GitHub Desktop.
ABC187 C問題解答
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
def input(): return sys.stdin.readline().rstrip() | |
def main(): | |
n = int(input()) | |
S = [input() for i in range(n)] | |
S.sort() | |
for i, s in enumerate(S): | |
if s[0] != '!': | |
idx_s2 = i | |
break | |
else: | |
print('satisfiable') | |
sys.exit() | |
#print(S) | |
for i in range(idx_s2): | |
s1 = S[i][1:] | |
while True: | |
#print(i, idx_s2) | |
s2 = S[idx_s2] | |
if s2 > s1: | |
break | |
if s2 == s1: | |
print(s1) | |
sys.exit() | |
idx_s2 += 1 | |
if idx_s2 == n: | |
print('satisfiable') | |
sys.exit() | |
print('satisfiable') | |
if __name__=='__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment