baryon's blog

By baryon, 2 years 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:

Full text and comments »

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