// try.cpp : This file contains the 'main' function. Program execution begins and ends there. //Mateusz Wasilewski #include <bits/stdc++.h> #define ll long long using namespace std; int t, N, M; ll x11, x21, y11, y21; ll wynik = 0; ll pole; string work; map <string, ll> mapa; class obj { public: ll x1; ll x2; ll y1; ll y2; bool add(){ if (x2 > x1&& y2 > y1) { return 1; } else { return 0; } } ll pole() { return (x2 - x1) * (y2 - y1); } }; vector<pair<obj, string> > tab; vector<pair<obj, string> > sp; obj start; obj now; void poziom(){ now.x1 = max(start.x1, x11); now.x2 = min(start.x2, x21); } void pion() { now.y1 = max(start.y1, y11); now.y2 = min(start.y2, y21); } void lewo() { now.x1 = start.x1; now.x2 = min(start.x2, x11); } void prawo() { now.x1 = max(start.x1, x21); now.x2 = start.x2; } void dol() { now.y1 = start.y1; now.y2 = min(start.y2, y11); } void gora() { now.y1 = max(start.y1, y21); now.y2 = start.y2; } void func(string word) { //bazowy poziom(); pion(); if (now.add()) sp.push_back(make_pair(now, word + '0')); //poziomy lewo(); pion(); if (now.add()) sp.push_back(make_pair(now, word + '1')); //lewo prawo(); pion(); if (now.add()) sp.push_back(make_pair(now, word + '1')); //prawo //pionowy dol(); poziom(); if (now.add()) sp.push_back(make_pair(now, word + '2')); //dol gora(); poziom(); if (now.add()) sp.push_back(make_pair(now, word + '2')); //gora //poziomy i pionowy lewo(); dol(); if (now.add()) sp.push_back(make_pair(now, word + '3')); //lewy dolny prawo(); dol(); if (now.add()) sp.push_back(make_pair(now, word + '3')); //prawy dolny lewo(); gora(); if (now.add()) sp.push_back(make_pair(now, word + '3')); //lewy gorny prawo(); gora(); if (now.add()) sp.push_back(make_pair(now, word + '3')); //prawy gorny } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> t >> N >> M; start.x1 = 0; start.x2 = N; start.y1 = 0; start.y2 = M; tab.push_back(make_pair(start, work)); for (int i = 0; i < t; i++) { cin >> x11 >> y11 >> x21 >> y21; if (y11 > y21) { swap(y11, y21); } if (x11 > x21) { swap(x11, x21); } sp.clear(); for (int z = 0; z < tab.size(); z++) { start = tab[z].first; func(tab[z].second); } tab = sp; } for (int i = 0; i < tab.size(); i++) { auto poz = mapa.find(tab[i].second); start = tab[i].first; pole = start.pole(); if (poz == mapa.end()) { mapa[tab[i].second] = pole; } else { mapa[tab[i].second] += pole; } } for (auto poz = mapa.begin(); poz != mapa.end(); poz++) { wynik = max(wynik, poz->second); } cout << wynik; } // Run program: Ctrl + F5 or Debug > Start Without Debugging menu // Debug program: F5 or Debug > Start Debugging menu
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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | // try.cpp : This file contains the 'main' function. Program execution begins and ends there. //Mateusz Wasilewski #include <bits/stdc++.h> #define ll long long using namespace std; int t, N, M; ll x11, x21, y11, y21; ll wynik = 0; ll pole; string work; map <string, ll> mapa; class obj { public: ll x1; ll x2; ll y1; ll y2; bool add(){ if (x2 > x1&& y2 > y1) { return 1; } else { return 0; } } ll pole() { return (x2 - x1) * (y2 - y1); } }; vector<pair<obj, string> > tab; vector<pair<obj, string> > sp; obj start; obj now; void poziom(){ now.x1 = max(start.x1, x11); now.x2 = min(start.x2, x21); } void pion() { now.y1 = max(start.y1, y11); now.y2 = min(start.y2, y21); } void lewo() { now.x1 = start.x1; now.x2 = min(start.x2, x11); } void prawo() { now.x1 = max(start.x1, x21); now.x2 = start.x2; } void dol() { now.y1 = start.y1; now.y2 = min(start.y2, y11); } void gora() { now.y1 = max(start.y1, y21); now.y2 = start.y2; } void func(string word) { //bazowy poziom(); pion(); if (now.add()) sp.push_back(make_pair(now, word + '0')); //poziomy lewo(); pion(); if (now.add()) sp.push_back(make_pair(now, word + '1')); //lewo prawo(); pion(); if (now.add()) sp.push_back(make_pair(now, word + '1')); //prawo //pionowy dol(); poziom(); if (now.add()) sp.push_back(make_pair(now, word + '2')); //dol gora(); poziom(); if (now.add()) sp.push_back(make_pair(now, word + '2')); //gora //poziomy i pionowy lewo(); dol(); if (now.add()) sp.push_back(make_pair(now, word + '3')); //lewy dolny prawo(); dol(); if (now.add()) sp.push_back(make_pair(now, word + '3')); //prawy dolny lewo(); gora(); if (now.add()) sp.push_back(make_pair(now, word + '3')); //lewy gorny prawo(); gora(); if (now.add()) sp.push_back(make_pair(now, word + '3')); //prawy gorny } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> t >> N >> M; start.x1 = 0; start.x2 = N; start.y1 = 0; start.y2 = M; tab.push_back(make_pair(start, work)); for (int i = 0; i < t; i++) { cin >> x11 >> y11 >> x21 >> y21; if (y11 > y21) { swap(y11, y21); } if (x11 > x21) { swap(x11, x21); } sp.clear(); for (int z = 0; z < tab.size(); z++) { start = tab[z].first; func(tab[z].second); } tab = sp; } for (int i = 0; i < tab.size(); i++) { auto poz = mapa.find(tab[i].second); start = tab[i].first; pole = start.pole(); if (poz == mapa.end()) { mapa[tab[i].second] = pole; } else { mapa[tab[i].second] += pole; } } for (auto poz = mapa.begin(); poz != mapa.end(); poz++) { wynik = max(wynik, poz->second); } cout << wynik; } // Run program: Ctrl + F5 or Debug > Start Without Debugging menu // Debug program: F5 or Debug > Start Debugging menu |