Algorithm
[BOJ] 1181 단어정렬
일등하이
2023. 1. 12. 19:38
반응형
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace _1181
{
class Program
{
static void Main(string[] args)
{
using (var stream = new StreamWriter(Console.OpenStandardOutput()))
{
int n = Convert.ToInt32(Console.ReadLine());
List<string> list = new List<string>();
for (int i = 0; i < n; i++)
list.Add(Console.ReadLine());
var sequence = list.OrderBy(x => x.Length).ThenBy(x => x).Distinct();
foreach (string w in sequence)
stream.WriteLine(w);
}
}
}
}
반응형