Advertisement
Guest User

EZ EZ EZ, DOMOYYYYY

a guest
May 25th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.25 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <fstream>
  4. #include <string>
  5. #include <map>
  6. #include <algorithm>
  7. #include <cmath>
  8.  
  9. using namespace std;
  10.  
  11. #define For(i, x, n) for (int i = 0; i < n; ++i)
  12. #define ll long long
  13. #define ld long double
  14.  
  15. ifstream cin_gr("groups.txt");
  16. ifstream cin_au("audit.txt");
  17. ifstream predmet("predmet.txt");
  18. ofstream ccout("output.txt");
  19.  
  20.  
  21. struct grp {
  22. string name; //name
  23. int N; //кол-во человек
  24. int num; // nomer grouppy
  25. string potok; // potok
  26. };
  27.  
  28. struct aud {
  29. int mest; //кол-во мест в аудитории
  30. int num; //номер аудитории
  31. int vid; // 1 - lecture; 2 - practice; 3 - working in laboratory
  32. };
  33.  
  34. map <string, int> mathem;
  35. map <string, int> program;
  36. map <string, int> phys;
  37. map <string, int> english;
  38. map <string, int> econom;
  39. map <string, int> mathem_l;
  40. map <string, int> program_l;
  41. map <string, int> phys_l;
  42. map <string, int> english_l;
  43. map <string, int> econom_l;
  44. map <string, int> mathem_la;
  45. map <string, int> program_la;
  46. map <string, int> phys_la;
  47. map <string, int> english_la;
  48. map <string, int> econom_la;
  49. map <string, vector<string>> potok;
  50. vector<aud> Aud;
  51. vector<grp> Group;
  52.  
  53. vector <map <string, int>> pre;
  54.  
  55. const int max_hours_per_day = 2;
  56. const int max_paras_per_week = 1;
  57. vector <int> zanyt;
  58.  
  59. bool zanit(int Aud)
  60. {
  61. for (int i = 0; i < zanyt.size(); ++i)
  62. {
  63. if (Aud == zanyt[i])
  64. return true;
  65. }
  66. return false;
  67. }
  68.  
  69. aud get_aud()
  70. {
  71. for (int i = 0; i < Aud.size(); ++i)
  72. {
  73. if (!zanit(Aud[i].num))
  74. {
  75. return Aud[i];
  76. }
  77. }
  78. }
  79.  
  80.  
  81. vector <map<string, int>> Prac;
  82. vector <map<string, int>> Lab;
  83. vector <map<string, int>> Lec;
  84.  
  85. struct str {
  86. string name;
  87. int type;
  88. int how_many;
  89. };
  90. vector <vector<str>> bil;
  91. vector <string> Group_Not_Free;
  92.  
  93. bool is_Free(string name)
  94. {
  95. for (int i = 0; i < Group_Not_Free.size(); ++i)
  96. {
  97. if (Group_Not_Free[i] == name)
  98. return false;
  99. }
  100. return true;
  101. }
  102.  
  103.  
  104. int check(string name, int type, int predmett) //predmett - номер предмета(0 - матан)
  105. {
  106. for (int i = 0; i < bil[predmett].size(); ++i)
  107. {
  108. if (bil[predmett][i].name == name && type == 1 && bil[predmett][i].type == type && bil[predmett][i].how_many < 2)
  109. {
  110. bil[predmett][i].how_many++;
  111. return 1;
  112. }
  113. else if (bil[predmett][i].name == name && type == 2 && bil[predmett][i].type == type && bil[predmett][i].how_many < 1)
  114. {
  115. bil[predmett][i].how_many++;
  116. return 2;
  117. }
  118. else if (bil[predmett][i].name == name && type == 3 && bil[predmett][i].type == type && bil[predmett][i].how_many < 1)
  119. {
  120. bil[predmett][i].how_many++;
  121. return 3;
  122. }
  123.  
  124. }
  125. return -1;
  126. }
  127.  
  128. void print_predmet(int p) {
  129. if (p == 0)
  130. ccout << " " << " " << "Math" << "\n";
  131. else if (p == 1)
  132. ccout << " " << " " << "Program" << "\n";
  133. else if (p == 2)
  134. ccout << " " << " " << "Phys" << "\n";
  135. else if (p == 3)
  136. ccout << " " << " " << "English" << "\n";
  137. else if (p == 4)
  138. ccout << " " << " " << "Economic" << "\n";
  139. else if (p == 5)
  140. ccout << " " << " " << "Economic" << "\n";
  141. else if (p == 6)
  142. ccout << " " << " " << "Linal" << "\n";
  143. else if (p == 7)
  144. ccout << " " << " " << "Diskret" << "\n";
  145. else if (p == 8)
  146. ccout << " " << " " << "Extrem" << "\n";
  147. }
  148.  
  149.  
  150. int main()
  151. {
  152. int Npredmet = 9;
  153. vector <string> Npotok;
  154. while (!cin_gr.eof())
  155. {
  156. grp s;
  157. cin_gr >> s.N >> s.num >> s.name >> s.potok;
  158. if (potok[s.potok].size() < 1)
  159. Npotok.push_back(s.potok);
  160. potok[s.potok].push_back(s.name);
  161. Group.push_back(s);
  162. }
  163.  
  164. while (!cin_au.eof())
  165. {
  166. aud s;
  167. cin_au >> s.mest >> s.num >> s.vid;
  168. Aud.push_back(s);
  169. }
  170. Lec.resize(Npredmet);
  171. Prac.resize(Npredmet);
  172. Lab.resize(Npredmet);
  173.  
  174. for (int j = 0; j < Npredmet; ++j) {
  175. for (int i = 0; i < Group.size(); ++i)
  176. {
  177. mathem[Group[i].name] = 2;
  178. program[Group[i].name] = 2;
  179. phys[Group[i].name] = 2;
  180. english[Group[i].name] = 2;
  181. econom[Group[i].name] = 2;
  182. mathem_l[Group[i].name] = 2;
  183. program_l[Group[i].name] = 2;
  184. phys_l[Group[i].name] = 2;
  185. english_l[Group[i].name] = 2;
  186. econom_l[Group[i].name] = 2;
  187. Prac[j][Group[i].name] = 2;
  188. Lab[j][Group[i].name] = 2;
  189. Lec[j][Group[i].name] = 2;
  190. }
  191. }
  192. /* Что используем:
  193. -Group(Характеристики групп)
  194. -bil(дыумерный массив на колличество предметов и на колличество групп)
  195. -Lec
  196. -Prac
  197. -lab
  198. */
  199. int WEEK = 1, day = 1, para = 1;
  200. /// week
  201. for (int w = 0; w < 2; ++w)
  202. {
  203. /// обнуляем максимальную посещаемость за неделю
  204. bil.resize(Npredmet, vector<str>(0));
  205. /// тут для каждого предмета
  206. for (int i = 0; i < Npredmet; ++i) {
  207. for (int j = 0; j < Group.size(); ++j){
  208. str temp;
  209. temp.name = Group[j].name;
  210. temp.how_many = 0;
  211. temp.type = 1;
  212. bil[i].push_back(temp);
  213. temp.type = 2;
  214. bil[i].push_back(temp);
  215. temp.type = 3;
  216. bil[i].push_back(temp);
  217. }
  218. for (int j = 0; j < Npotok.size(); ++j) {
  219. str temp;
  220. temp.name = Npotok[j];
  221. temp.how_many = 0;
  222. temp.type = 1;
  223. bil[i].push_back(temp);
  224. temp.type = 2;
  225. bil[i].push_back(temp);
  226. temp.type = 3;
  227. bil[i].push_back(temp);
  228. }
  229. }
  230. day = 1;
  231. ccout << " week nuber: " << WEEK << "\n";
  232.  
  233. ////day
  234. for (int k = 0; k < 6; ++k)
  235. {
  236.  
  237. ccout << " day nuber: " << day << "\n";
  238. para = 1;
  239.  
  240. //////lesson
  241. for (int i = 0; i < 5; ++i)
  242. {
  243. Group_Not_Free.resize(0);
  244. zanyt.resize(0);
  245. ccout << " para nuber: " << para << "\n";
  246. //Для каждого предмета
  247. for (int p = 0; p < Npredmet; ++p) {
  248. ///Проверяем все группы
  249. for (int j = 0; j < Group.size(); ++j)
  250. {
  251. aud audit = get_aud();
  252. if (is_Free(Group[j].name) && Lec[p][Group[j].name] > 0 && check(Group[j].potok, 1, p/*0 - матан*/) == 1) {
  253. for (int d = 0; d < potok[Group[j].potok].size(); ++d) {
  254. Lec[p][potok[Group[j].potok][d]]--;
  255. Group_Not_Free.push_back(potok[Group[j].potok][d]);
  256. ccout << "№:" << audit.num << " " << " Count of places: " << audit.mest << " Type: Lecture" << " " << "Stream: " << Group[j].potok << " , " << potok[Group[j].potok][d];
  257. print_predmet(p);
  258. }
  259. zanyt.push_back(audit.num);
  260. }
  261. else if (is_Free(Group[j].name) && Prac[p][Group[j].name] > 0 && check(Group[j].name, 2, p/*0 - матан*/) == 2)
  262. {
  263. Prac[p][Group[j].name]--;
  264. Group_Not_Free.push_back(Group[j].name);
  265. zanyt.push_back(audit.num);
  266. ccout << "№:" << audit.num << " " << " Count of places: " << audit.mest << " Type: Practice" << " " << "Group: " << Group[j].name;
  267. print_predmet(p);
  268.  
  269. }
  270. else if (is_Free(Group[j].name) && Lab[p][Group[j].name] > 0 && check(Group[j].name, 3, p/*0 - матан*/) == 3)
  271. {
  272. zanyt.push_back(audit.num);
  273. Group_Not_Free.push_back(Group[j].name);
  274. Lab[p][Group[j].name]--;
  275. ccout << "№:" << audit.num << " " << " Count of places: " << audit.mest << " Type: Laboratory" << " " << "Group: " << Group[j].name;
  276. print_predmet(p);
  277. }
  278. }
  279. }
  280. para++;
  281. }
  282. day++;
  283.  
  284. }
  285. WEEK++;
  286.  
  287. }
  288. return 0;
  289. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement