-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshoes_companies.cpp
More file actions
65 lines (60 loc) · 1.95 KB
/
shoes_companies.cpp
File metadata and controls
65 lines (60 loc) · 1.95 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
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
struct Color{
map<string,string> map_type;
} ;
struct ShoeSize{
map<string,Color*> map_color;
};
struct Companies{
map<int,ShoeSize*> map_size;
};
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
map<string, Companies*> map_company;
int N,pairs;
cin>>N;
while(N>0){
int size;
string company,color,type;
cin>>company>>size>>color>>type;
map<string,Companies*>::iterator it_company = map_company.find(company);
if(it_company!=map_company.end()){
map<int,ShoeSize*>::iterator it_shoesize = it_company->second->map_size.find(size);
if(it_shoesize!=it_company->second->map_size.end()){
map<string,Color*>::iterator it_color = it_shoesize->second->map_color.find(color);
if(it_color != it_shoesize->second->map_color.end() ){
map<string,string>::iterator it_type = it_color->map_type.find(type);
if(it_type != it_color)
}
else{
Color *new_color = new Color;
it_shoesize->second->map_color[color] = new_color;
new_color->map_type[type] = type;
}
}
else{
ShoeSize *new_size = new ShoeSize;
Color *new_color = new Color;
it_company->second->map_size[size] = new_size;
new_size->map_color[color] = new_color;
new_color->map_type[type] = type;
}
}
else{
Companies *new_comp = new Companies;
ShoeSize *new_size = new ShoeSize;
Color *new_color = new Color;
map_company[company] = new_comp;
new_comp->map_size[size] = new_size;
new_size->map_color[color] = new_color;
new_color->map_type[type] = type;
}
}
return 0;
}