You are viewing a single comment's thread. Return to all comments →
C++
vector<vector<pair<int,int>>> getmax(pair<int,int> x1, pair<int,int> x2, pair<int,int> x3, pair<int,int> x4, map<pair<int,int>, bool> mp, int x, int y){ int ans = 1; vector<vector<pair<int,int>>> alllocs; vector<pair<int,int>> locs = {x1}; while(true){ alllocs.push_back(locs); if(x1.first > 0 && mp[{x1.first-1, x1.second}] == true){ x1.first-=1; } else break; if(x2.first < x - 1 && mp[{x2.first+1, x2.second}] == true){ x2.first+=1; } else break; if(x3.second > 0 && mp[{x3.first, x3.second-1}] == true){ x3.second-=1; } else break; if(x4.second < y - 1 && mp[{x4.first, x4.second+1}] == true){ x4.second+=1; } else break; locs.push_back({x1.first, x1.second}); locs.push_back({x2.first, x2.second}); locs.push_back({x3.first, x3.second}); locs.push_back({x4.first, x4.second}); ans+=4; } return alllocs; } int main(){ int x, y; cin >> x >> y; map<pair<int,int>, bool> v; for(int i = 0; i < x; i++){ for(int j = 0; j < y; j++){ char x; cin >> x; if(x == 'G'){ v[{i,j}] = 1; } } } map<int, vector<pair<int,int>>> mp; int a = 0; vector<vector<pair<int,int>>> bu; for(auto itr: v){ vector<vector<pair<int,int>>> buff = getmax({itr.first.first, itr.first.second},{itr.first.first, itr.first.second},{itr.first.first, itr.first.second},{itr.first.first, itr.first.second}, v, x, y); for(int i = 0; i < buff.size(); i++){ bu.push_back(buff[i]); } } int ans = 0; for(int i = 0; i < bu.size(); i++){ for(int j = i+1; j < bu.size(); j++){ if(ans < (bu[i].size() * bu[j].size())){ bool isavail = true; for(int k = 0; k < bu[i].size(); k++){ if(count(bu[j].begin(), bu[j].end(), bu[i][k])){ isavail = false; break; } } if(isavail){ ans = (bu[i].size() * bu[j].size()); } } } } cout << ans; return 0; }
Ema's Supercomputer
You are viewing a single comment's thread. Return to all comments →
C++