#include <cstdio> #include <vector> using std::vector;
vector< vector<int> > major; // data array int x, y; // size of arraiy int limit; // if value in diagonal is more than this remove it's row
void print () { int ix, iy (0); do { ix = 0; do { printf ("%d ", major[iy][ix]); } while (++ix != x); putchar ('\n'); } while (++iy != y); };
void reading () { scanf ("%d%d%d", &limit, &x, &y); major.resize (y); int ix, iy (0); // help variables do { major[iy].resize (x); ix = 0; do { scanf ("%d", &major[iy][ix]); } while (++ix != x); } while (++iy != y); };
vector<int> moving () { int itd (0); // iterator diagonal int ith; // iterator horizontal int max (0); // maiximum value in horizontal vector<int> result; // array with maximum elements from columns do { if (major[itd][itd] > limit) { // search for value greater than limit ith = 0; max = 0; do { if (major[ith][itd] > max) { max = major[ith][itd]; }; } while (++ith != y); result.push_back (max); major.erase (major.begin() + itd); --y; } else { ++itd; // if we remove some row, next one received it's index }; } while ( (itd < x) && (itd < y) ); return result; };
int main() { // 1 machen freopen ("sol.in", "r", stdin); // use your input file within "sol.in" reading (); vector<int> first (moving()); if (first.size() < x) { first.insert (first.end(), x - first.size(), 0); }; // adding zeros in end if need major.insert (major.begin(), first); ++y; print (); // 0 machen */ return 0; };
|