-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
131 lines (116 loc) · 4.65 KB
/
Copy pathmain.cpp
File metadata and controls
131 lines (116 loc) · 4.65 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
//
// main.cpp
// March Madness Bracket Predictor
//
// Created by Antonio Thomas Atkinson on 6/3/17.
// Copyright © 2017 Antonio Thomas Atkinson. All rights reserved.
//
#include <iostream>
#include <unordered_map>
#include "Bracket.h"
#include <vector>
#include <string>
#include <getopt.h>
using namespace std;
void readData(vector<TeamInfo> &vec,unordered_map<string,int> &teamIndex);
void calcInitialData(vector<TeamInfo> &vec,unordered_map<string, int> &teamIndex);
void determineRegion(vector<TeamInfo> &vec,char region,int i);
void runProgram(vector<TeamInfo> &vec,unordered_map<string, int> &teamIndex);
void testPrint(vector<TeamInfo> &vec,unordered_map<string,int> &teamIndex);
int main(int argc, char * argv[]) {
ios_base::sync_with_stdio(false);
if (getenv("INPUT")) { freopen(getenv("INPUT"), "r", stdin); freopen(getenv("OUTPUT"), "w", stdout); }
/*opterr = true; // Give us help with errors
static struct option longOpts[] =
{
{"stack",no_argument,nullptr,'s'},
{"help", no_argument, nullptr, 'h'},
{nullptr, 0, nullptr, 0}
};
int idx = 0; // getopt_long stores the option index here
int c; // The single character for the option, but stored as int
//string dArg;
while ((c = getopt_long(argc, argv, "sqcplo:b:e:h", longOpts, &idx))!=-1)
{
switch (c) {
case 's':
break;
case 'h':
cout << "-s --stack: Stack based routing scheme\n";
cout << "-q --queue: Queue based routing scheme\n";
cout << "-c --change: Letterman Allowed to change one letter to another\n";
cout << "-p --swap: Letterman allowed to swap two adjacent characters\n";
cout << "-l --length: Allowed to modify length of word by adding or deleting a letter\n";
cout << "-o(W|M) --output(W|M): Specifies output\n";
cout << "-b --begin: Beginning word\n";
cout << "-e --end: Ending word\n";
cout << "-h --help: Help\n";
c1.help = true;
exit(0);
default:
cerr << "Unknown option " << c << endl;
exit(1);
}
}*/
int numOfTeams=0;
cin>>numOfTeams;
vector<TeamInfo> vec;
vec.resize(numOfTeams);
unordered_map<string, int> teamIndex;
string input;
cin>>input>>input>>input>>input>>input>>input>>input>>input>>input>>input>>input>>input>>input;
readData(vec, teamIndex);
calcInitialData(vec, teamIndex);
runProgram(vec, teamIndex);
//testPrint(vec, teamIndex);
return 0;
}
void readData(vector<TeamInfo> &vec,unordered_map<string, int> &teamIndex){
string region;
for(int i=0;i<(int)vec.size();++i){
cin>>vec[i].name>>vec[i].seed>>region;//Could make more efficient or remove completly
vec[i].regionName=region;
determineRegion(vec, region[0],i);
cin>>vec[i].RPI>>vec[i].RPIRank>>vec[i].BPI>>vec[i].BPIRank>>vec[i].kenpom>>vec[i].kenpomRank>>vec[i].sagarin>>vec[i].sagarinRank>>vec[i].initialOpponent>>vec[i].matchupNumber;
teamIndex[vec[i].name] = i;
}
}
void calcInitialData(vector<TeamInfo> &vec,unordered_map<string, int> &teamIndex){
for(int i=0;i<(int)vec.size();++i){
vec[i].avgRankWeight = (1*vec[i].sagarinRank+2*vec[i].kenpomRank+3*vec[i].BPIRank+4*vec[i].RPIRank)/10;
vec[i].avgScoreWeight = (4*vec[i].sagarin+3*vec[i].kenpom+2*vec[i].BPI+1*vec[i].RPI)/10;
}
}
void runProgram(vector<TeamInfo> &vec,unordered_map<string, int> &teamIndex){
Bracket bracket(vec,teamIndex);
bracket.RunFirstRound();
bracket.RunSecondRound();
bracket.RunSweetSixteen();
bracket.RunEliteEight();
bracket.RunFinalFour();
bracket.RunNationalChampionship();
}
void determineRegion(vector<TeamInfo> &vec,char region,int i){
switch (region) {
case 'W':
vec[i].region=West;
break;
case 'E':
vec[i].region=East;
break;
case 'M':
vec[i].region=Midwest;
break;
case 'S':
vec[i].region=South;
break;
default:
break;
}
}
void testPrint(vector<TeamInfo> &vec,unordered_map<string,int> &teamIndex){
for(int i=0;i<(int)vec.size();++i){
cout<<vec[i].name<<" "<<vec[i].seed<<" "<<vec[i].region<<" "<<vec[i].RPI<<" "<<vec[i].RPIRank<<" "<<vec[i].BPI<<" "<<
vec[i].BPIRank<<" "<<vec[i].kenpom<<" "<<vec[i].kenpomRank<<" "<<vec[i].sagarin<<" "<<vec[i].sagarinRank<<" "<<vec[i].initialOpponent<<" "<<vec[i].matchupNumber<<"\n";
}
}