AlgoLensArena
ContestlərProblemlərOtaqlar
Vizualizator
← Məsələlər

BAPC23-041.Democratic Naming

Medium · 1 s · 256 MB

  • icpc
  • bapc
  • 2023

A new county has been created on artificially created land out from the coast, with code name “Built Anew Peninsula County”, but the final name still needs to be chosen. To establish a new name, the cities within the county get to vote on the individual letters of the name.

As it happens, all cities in the county have a name with exactly mmm letters, and so they decide the name of the county will also have exactly mmm letters. Naturally, each city prefers their own name, and thus votes that the iiith letter of the county name should match theirs. For each of the mmm positions, the letter that received the most votes across all cities gets picked. In case of a tie between multiple letters, the one occurring earliest in the English alphabet gets picked.

Given the list of the city names, determine the result of the vote for the new county's name.

Giriş formatı

The input consists of:

• One line with two integers nnn and mmm (1≤n≤10001\leq n\leq 10001≤n≤1000, 1≤m≤10001 \leq m \leq 10001≤m≤1000), the number of cities and the number of letters in each city name.

• nnn lines, each with a string of length mmm, the name of a city.

The city names only consist of lowercase English letters (a-z).

Çıxış formatı

Output the name of the new county.

Qeyd

Source: Benelux Algorithm Programming Contest 2023 · Author: Ivan Fever · License: CC BY-SA 4.0 · Original: https://bapc.eu · Statement adapted for AlgoLens and shared under the same license. · 13 of the 46 original test cases (the largest) are omitted here to keep the problem lightweight.

Nümunələr

Giriş #1

3 5
apple
maple
alpha

Çıxış #1

aaple

Giriş #2

3 4
icpc
back
laps

Çıxış #2

bapc