-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlineup.cpp
60 lines (53 loc) · 1.21 KB
/
lineup.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
* @file lineup.cpp
* @author William Weston
* @brief Line Them Up Problem from Kattis
* @version 0.1
* @date 2023-06-16
*
* @copyright Copyright (c) 2023
*
* Source: https://open.kattis.com/problems/lineup
*/
#include <algorithm>
#include <cstdlib>
#include <functional>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
auto alphabetized( std::vector<std::string> const& players ) -> void;
auto
main() -> int
{
int team_size;
while ( std::cin >> team_size )
{
auto players = std::vector<std::string>();
players.reserve( team_size );
for ( auto player_number = 0; player_number < team_size; ++player_number)
{
auto name = std::string();
std::cin >> name;
players.push_back( std::move( name ) );
}
alphabetized( players );
}
return EXIT_SUCCESS;
}
auto
alphabetized( std::vector<std::string> const& players ) -> void
{
if ( std::is_sorted( players.begin(), players.end() ) )
{
std::cout << "INCREASING\n";
}
else if ( std::is_sorted( players.begin(), players.end(), std::greater{} ) )
{
std::cout << "DECREASING\n";
}
else
{
std::cout << "NEITHER\n";
}
}