baryon's blog

By baryon, 3 months ago, In English

Given (N−2) three-letter substrings, find any string of length N corresponding to the given set of three-letter substrings. If there is no solution print NO Else, print YES in the first line, and the N-characters desired string in the second line.

E.X :


xzx, xyx, xyx, zxy, yxz

output : YES, xyxzxyx



abc, def, xyz

output : NO

constraints: 3<=N<=1e5

Problem Source:

Read more »

  • Vote: I like it
  • -10
  • Vote: I do not like it