Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <fstream>
- #include <string>
- #include <map>
- #include <algorithm>
- #include <cmath>
- using namespace std;
- #define For(i, x, n) for (int i = 0; i < n; ++i)
- #define ll long long
- #define ld long double
- ifstream cin_gr("groups.txt");
- ifstream cin_au("audit.txt");
- ifstream predmet("predmet.txt");
- ofstream ccout("output.txt");
- struct grp {
- string name; //name
- int N; //кол-во человек
- int num; // nomer grouppy
- string potok; // potok
- };
- struct aud {
- int mest; //кол-во мест в аудитории
- int num; //номер аудитории
- int vid; // 1 - lecture; 2 - practice; 3 - working in laboratory
- };
- map <string, int> mathem;
- map <string, int> program;
- map <string, int> phys;
- map <string, int> english;
- map <string, int> econom;
- map <string, int> mathem_l;
- map <string, int> program_l;
- map <string, int> phys_l;
- map <string, int> english_l;
- map <string, int> econom_l;
- map <string, int> mathem_la;
- map <string, int> program_la;
- map <string, int> phys_la;
- map <string, int> english_la;
- map <string, int> econom_la;
- map <string, vector<string>> potok;
- vector<aud> Aud;
- vector<grp> Group;
- vector <map <string, int>> pre;
- const int max_hours_per_day = 2;
- const int max_paras_per_week = 1;
- vector <int> zanyt;
- bool zanit(int Aud)
- {
- for (int i = 0; i < zanyt.size(); ++i)
- {
- if (Aud == zanyt[i])
- return true;
- }
- return false;
- }
- aud get_aud()
- {
- for (int i = 0; i < Aud.size(); ++i)
- {
- if (!zanit(Aud[i].num))
- {
- return Aud[i];
- }
- }
- }
- vector <map<string, int>> Prac;
- vector <map<string, int>> Lab;
- vector <map<string, int>> Lec;
- struct str {
- string name;
- int type;
- int how_many;
- };
- vector <vector<str>> bil;
- vector <string> Group_Not_Free;
- bool is_Free(string name)
- {
- for (int i = 0; i < Group_Not_Free.size(); ++i)
- {
- if (Group_Not_Free[i] == name)
- return false;
- }
- return true;
- }
- int check(string name, int type, int predmett) //predmett - номер предмета(0 - матан)
- {
- for (int i = 0; i < bil[predmett].size(); ++i)
- {
- if (bil[predmett][i].name == name && type == 1 && bil[predmett][i].type == type && bil[predmett][i].how_many < 2)
- {
- bil[predmett][i].how_many++;
- return 1;
- }
- else if (bil[predmett][i].name == name && type == 2 && bil[predmett][i].type == type && bil[predmett][i].how_many < 1)
- {
- bil[predmett][i].how_many++;
- return 2;
- }
- else if (bil[predmett][i].name == name && type == 3 && bil[predmett][i].type == type && bil[predmett][i].how_many < 1)
- {
- bil[predmett][i].how_many++;
- return 3;
- }
- }
- return -1;
- }
- void print_predmet(int p) {
- if (p == 0)
- ccout << " " << " " << "Math" << "\n";
- else if (p == 1)
- ccout << " " << " " << "Program" << "\n";
- else if (p == 2)
- ccout << " " << " " << "Phys" << "\n";
- else if (p == 3)
- ccout << " " << " " << "English" << "\n";
- else if (p == 4)
- ccout << " " << " " << "Economic" << "\n";
- else if (p == 5)
- ccout << " " << " " << "Economic" << "\n";
- else if (p == 6)
- ccout << " " << " " << "Linal" << "\n";
- else if (p == 7)
- ccout << " " << " " << "Diskret" << "\n";
- else if (p == 8)
- ccout << " " << " " << "Extrem" << "\n";
- }
- int main()
- {
- int Npredmet = 9;
- vector <string> Npotok;
- while (!cin_gr.eof())
- {
- grp s;
- cin_gr >> s.N >> s.num >> s.name >> s.potok;
- if (potok[s.potok].size() < 1)
- Npotok.push_back(s.potok);
- potok[s.potok].push_back(s.name);
- Group.push_back(s);
- }
- while (!cin_au.eof())
- {
- aud s;
- cin_au >> s.mest >> s.num >> s.vid;
- Aud.push_back(s);
- }
- Lec.resize(Npredmet);
- Prac.resize(Npredmet);
- Lab.resize(Npredmet);
- for (int j = 0; j < Npredmet; ++j) {
- for (int i = 0; i < Group.size(); ++i)
- {
- mathem[Group[i].name] = 2;
- program[Group[i].name] = 2;
- phys[Group[i].name] = 2;
- english[Group[i].name] = 2;
- econom[Group[i].name] = 2;
- mathem_l[Group[i].name] = 2;
- program_l[Group[i].name] = 2;
- phys_l[Group[i].name] = 2;
- english_l[Group[i].name] = 2;
- econom_l[Group[i].name] = 2;
- Prac[j][Group[i].name] = 2;
- Lab[j][Group[i].name] = 2;
- Lec[j][Group[i].name] = 2;
- }
- }
- /* Что используем:
- -Group(Характеристики групп)
- -bil(дыумерный массив на колличество предметов и на колличество групп)
- -Lec
- -Prac
- -lab
- */
- int WEEK = 1, day = 1, para = 1;
- /// week
- for (int w = 0; w < 2; ++w)
- {
- /// обнуляем максимальную посещаемость за неделю
- bil.resize(Npredmet, vector<str>(0));
- /// тут для каждого предмета
- for (int i = 0; i < Npredmet; ++i) {
- for (int j = 0; j < Group.size(); ++j){
- str temp;
- temp.name = Group[j].name;
- temp.how_many = 0;
- temp.type = 1;
- bil[i].push_back(temp);
- temp.type = 2;
- bil[i].push_back(temp);
- temp.type = 3;
- bil[i].push_back(temp);
- }
- for (int j = 0; j < Npotok.size(); ++j) {
- str temp;
- temp.name = Npotok[j];
- temp.how_many = 0;
- temp.type = 1;
- bil[i].push_back(temp);
- temp.type = 2;
- bil[i].push_back(temp);
- temp.type = 3;
- bil[i].push_back(temp);
- }
- }
- day = 1;
- ccout << " week nuber: " << WEEK << "\n";
- ////day
- for (int k = 0; k < 6; ++k)
- {
- ccout << " day nuber: " << day << "\n";
- para = 1;
- //////lesson
- for (int i = 0; i < 5; ++i)
- {
- Group_Not_Free.resize(0);
- zanyt.resize(0);
- ccout << " para nuber: " << para << "\n";
- //Для каждого предмета
- for (int p = 0; p < Npredmet; ++p) {
- ///Проверяем все группы
- for (int j = 0; j < Group.size(); ++j)
- {
- aud audit = get_aud();
- if (is_Free(Group[j].name) && Lec[p][Group[j].name] > 0 && check(Group[j].potok, 1, p/*0 - матан*/) == 1) {
- for (int d = 0; d < potok[Group[j].potok].size(); ++d) {
- Lec[p][potok[Group[j].potok][d]]--;
- Group_Not_Free.push_back(potok[Group[j].potok][d]);
- ccout << "№:" << audit.num << " " << " Count of places: " << audit.mest << " Type: Lecture" << " " << "Stream: " << Group[j].potok << " , " << potok[Group[j].potok][d];
- print_predmet(p);
- }
- zanyt.push_back(audit.num);
- }
- else if (is_Free(Group[j].name) && Prac[p][Group[j].name] > 0 && check(Group[j].name, 2, p/*0 - матан*/) == 2)
- {
- Prac[p][Group[j].name]--;
- Group_Not_Free.push_back(Group[j].name);
- zanyt.push_back(audit.num);
- ccout << "№:" << audit.num << " " << " Count of places: " << audit.mest << " Type: Practice" << " " << "Group: " << Group[j].name;
- print_predmet(p);
- }
- else if (is_Free(Group[j].name) && Lab[p][Group[j].name] > 0 && check(Group[j].name, 3, p/*0 - матан*/) == 3)
- {
- zanyt.push_back(audit.num);
- Group_Not_Free.push_back(Group[j].name);
- Lab[p][Group[j].name]--;
- ccout << "№:" << audit.num << " " << " Count of places: " << audit.mest << " Type: Laboratory" << " " << "Group: " << Group[j].name;
- print_predmet(p);
- }
- }
- }
- para++;
- }
- day++;
- }
- WEEK++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement