diff options
author | Santo Cariotti <dcariotti24@gmail.com> | 2020-10-18 18:56:43 +0200 |
---|---|---|
committer | Santo Cariotti <dcariotti24@gmail.com> | 2020-10-20 09:08:52 +0200 |
commit | f279107065146a4940f5e73602a1c3c09e58b31d (patch) | |
tree | fd892749637a8b6c5c31ccb80bba04ade76ab87a /I_anno/Programmazione_2/exercises/exam_20_07_20/ex2.cpp | |
parent | 4e063e32250312c38d5646840719b62429362b21 (diff) |
chore: name of first year folder
Diffstat (limited to 'I_anno/Programmazione_2/exercises/exam_20_07_20/ex2.cpp')
-rw-r--r-- | I_anno/Programmazione_2/exercises/exam_20_07_20/ex2.cpp | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/I_anno/Programmazione_2/exercises/exam_20_07_20/ex2.cpp b/I_anno/Programmazione_2/exercises/exam_20_07_20/ex2.cpp deleted file mode 100644 index aed25e4..0000000 --- a/I_anno/Programmazione_2/exercises/exam_20_07_20/ex2.cpp +++ /dev/null @@ -1,63 +0,0 @@ -#include<iostream> -#include<sstream> -#include<fstream> -#include<queue> - -using namespace std; -using pi = tuple<int, int, vector<int>>; - -class comp { -public: - bool operator()(const pi& lhs, const pi& rhs) const { - auto xl = get<0>(lhs); - auto yl = get<0>(rhs); - - auto il = get<1>(lhs); - auto jl = get<1>(rhs); - if(xl == yl) - return il > jl; - return xl > yl; - } -}; - -int main() { - ifstream in("input.txt"); - ofstream out("output.txt"); - - for(int ts = 0; ts < 100; ++ts) { - int R, C; - in >> R >> C; - vector<vector<int>> v; - priority_queue<pi, vector<pi>, comp> pq; - int k; - for(int i = 0; i < R; ++i) { - v.push_back(vector<int>{}); - for(int j = 0; j < C; ++j) { - in >> k; - v[i].push_back(k); - } - } - - int index = 0; - for(auto const& i : v) { - int s = 0; - pi qq; - for(auto const& j : i) - s += j; - get<0>(qq) = s; - get<1>(qq) = index++; - get<2>(qq) = i; - pq.push(qq); - } - while(!pq.empty()) { - auto q = pq.top(); - pq.pop(); - for(auto const& i : get<2>(q)) - out << i << ' '; - } - out << endl; - } - in.close(); - out.close(); - return 0; -} |