Skip to content

Instantly share code, notes, and snippets.

@monhime
Created January 3, 2021 01:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monhime/4c599a49ee9636cbd4c810ba02e4e9ee to your computer and use it in GitHub Desktop.
Save monhime/4c599a49ee9636cbd4c810ba02e4e9ee to your computer and use it in GitHub Desktop.
ABC187 C問題解答
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