Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //I was going somewhere, but I was going somewhere for so long that I got tired of this. May have been able to finish it if I'd given it a few more hours./s
- #include <iostream> //cin, cout
- #include <set>
- #include <map>
- using namespace std;
- struct p { int ij; int v; };
- typedef map<int, map<int, int>> bleh;
- typedef map<int, set<int>> ughh;
- typedef map<int, p> barf;
- class Solution {
- private:
- int N;
- bleh m;
- ughh mAvj; //val, {j}
- ughh mBvi; //val, {i}
- barf maxI; //i, {j, val}
- barf maxJ; //j, {i, val}
- int numInvisible = 0;
- public:
- Solution(int n) : N(n) {
- //get input
- for (int i = 0; i < N; ++i) {
- for (int j = 0; j < N; ++j) {
- int x; cin >> x;
- m[i][j] = x;
- mAvj[x].insert(j);
- mBvi[x].insert(i);
- if (maxI[i].v < x) { maxI[i] = {j, x}; }
- if (maxJ[j].v < x) { maxJ[j] = {i, x}; }
- }
- }
- //
- int imaxprev = -1, jmaxprev = -1;
- int imaxnext = -1, jmaxnext = -1;
- for (int i = 0; i < N; ++i) {
- for (int j = 0; j < N; ++j) {
- int x = m[i][j];
- uggh::reverse_iterator irit = mAvj.begin();
- while ((*irit).first != x) { //the value of the last element of mAvj
- irit--;
- }
- }
- }
- }
- int getNumVisible() { return N - numInvisible; }
- };
- int main() {
- int N;
- cin >> N;
- Solution solution(N);
- int nvisible = solution.getNumVisible();
- cout << nvisible << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment