Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <vector>
- #include <queue>
- #include <algorithm>
- #include <string>
- #include <stack>
- #include <set>
- #include <map>
- #define pii pair <int, int>
- #define pb(x) push_back(x)
- using namespace std;
- using ll = long long;
- using ld = long double;
- using db = double;
- void cv(vector <int> &v) {
- for (auto x : v) cout << x << ' ';
- cout << "\n";
- }
- void cvl(vector <ll> &v) {
- for (auto x : v) cout << x << ' ';
- cout << "\n";
- }
- void cvv(vector <vector <int> > &v) {
- for (auto x : v) cv(x);
- cout << "\n";
- }
- void cvb(vector <bool> v) {
- for (bool x : v) cout << x << ' ';
- cout << "\n";
- }
- void cvs(vector <string> v) {
- for (auto a : v) {
- cout << a << "\n";
- }
- }
- void cvp(vector <pii> a) {
- for (auto p : a) {
- cout << p.first << ' ' << p.second << "\n";
- }
- cout << "\n";
- }
- struct obj {
- int id;
- string name;
- vector <int> link;//ведь изначально объявляется в структуре пустым или это не так работает?
- };
- void add(map <int, obj> &mp, obj el) {
- mp[el.id] = el;
- }
- int main() {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- map <int, obj> school, clas, student;
- int S, C, P;
- cin >> S;
- for (int i = 0; i < S; ++i) {
- obj school_now;
- cin >> school_now.id >> school_now.name;
- add(school, school_now);
- }
- cin >> C;
- for (int i = 0; i < C; ++i) {
- obj clas_now;
- int school_id;
- cin >> clas_now.id >> school_id >> clas_now.name;
- add(clas, clas_now);
- school[school_id].link.pb(clas_now.id);
- }
- cin >> P;
- for (int i = 0; i < P; ++i) {
- obj student_now;
- int clas_id;
- cin >> student_now.id >> clas_id >> student_now.name;
- add(student, student_now);
- clas[clas_is].link.pb(student_now.id);
- }
- //сортим все id
- for (obj el: school) {
- sort(el.link.begin(), el.link.end());
- }
- for (obj el: clas) {
- sort(el.link.begin(), el.link.end());
- }
- for (obj el: student) {
- sort(el.link.begin(), el.link.end());
- }
- //выводим
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement