Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream in("colorfulconflict.in");
- ofstream out("colorfulconflict.out");
- vector <pair <int, int> > v[40005];
- int s[205][205];
- int c[205][205];
- int main()
- {
- int n;
- in >> n;
- if(n > 200)
- {
- out << "-1";
- return 0;
- }
- int mx = 0;
- for(int i = 1; i <= n; i ++)
- {
- for(int j = 1; j <= n; j ++)
- {
- int a;
- in >> a;
- mx = max(mx, a);
- v[a].push_back(make_pair(i, j));
- }
- }
- for(int x = 1; x <= mx; x ++)
- {
- int mn = (1 << 30);
- int pozx1 = 0, pozx2 = 0, pozy1 = 0, pozy2 = 0;
- int mxx = 0, okj = 0, oki = 0;
- for(int i = 0; i < v[x].size(); i ++)
- {
- for(int j = i + 1; j < v[x].size(); j ++)
- {
- int a = max(v[x][j].second, v[x][i].second) - min(v[x][j].second, v[x][i].second) + 1;
- int b = max(v[x][j].first, v[x][i].first) - min(v[x][j].first, v[x][i].first) + 1;
- if(mxx < a * b)
- mxx = a * b, okj = j, oki = i;
- }
- }
- if(mn > mxx && mxx)
- {
- pozx1 = v[x][oki].first;
- pozy1 = v[x][oki].second;
- pozx2 = v[x][okj].first;
- pozy2 = v[x][okj].second;
- mn = min(mn, mxx);
- }
- cout << x << " " << pozx1 << " " << pozy1 << " " << pozx2 << " " << pozy2 << '\n';
- for(int i = min(pozx1, pozx2); i <= max(pozx1, pozx2); i ++)
- {
- for(int j = min(pozy1, pozy2); j <= max(pozy1, pozy2); j ++)
- s[i][j] ++;
- }
- ///s[pozx1][pozy1] ++;
- ///s[pozx1][pozy2 + 1] --;
- ///s[pozx2][pozy1 + 1] --;
- ///s[pozx2 + 1][pozy2 + 1] ++;
- }
- for(int i = 1; i <= n; i ++)
- {
- for(int j = 1; j <= n; j ++)
- {
- ///s[i][j] += s[i - 1][j] + s[i][j - 1] - s[i - 1][j - 1];
- cout << s[i][j] << " ";
- }
- cout << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement