summaryrefslogtreecommitdiff
path: root/1_anno/Programmazione_2/coding_contest/stazioni.cpp
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2021-02-06 19:56:36 +0100
committerSanto Cariotti <santo@dcariotti.me>2021-02-06 19:56:36 +0100
commitd2edbc38cac8da52f58c5cd3da6c0c625fa05736 (patch)
treea51e9a4e56fc9d4c7c9e37576dceedca3a0c72b4 /1_anno/Programmazione_2/coding_contest/stazioni.cpp
parent98f34040820dc3a964b7be59a698323e8cc6c8a3 (diff)
conf: rename
Diffstat (limited to '1_anno/Programmazione_2/coding_contest/stazioni.cpp')
-rw-r--r--1_anno/Programmazione_2/coding_contest/stazioni.cpp82
1 files changed, 0 insertions, 82 deletions
diff --git a/1_anno/Programmazione_2/coding_contest/stazioni.cpp b/1_anno/Programmazione_2/coding_contest/stazioni.cpp
deleted file mode 100644
index 29ede44..0000000
--- a/1_anno/Programmazione_2/coding_contest/stazioni.cpp
+++ /dev/null
@@ -1,82 +0,0 @@
-#include<iostream>
-#include<fstream>
-#include<algorithm>
-#include<vector>
-
-using namespace std;
-
-int main() {
- ifstream in("input.txt");
- ofstream out("output.txt");
-
- for(int ts = 0; ts < 1; ++ts) {
- int N, S;
- in >> N >> S;
- vector<long> st;
- vector<vector<long>> paths;
- vector<vector<long>> paths2;
- vector<vector<long>> paths3;
-
- int e;
- for(int i = 0; i < N; ++i) {
- in >> e;
- st.push_back(e);
- }
-
- int index{};
- for(int i = 0; i < N-S+1; ++i) {
- for(int j = 0; j < N; ++j) {
- paths.push_back(vector<long>{});
- paths[index].push_back(i);
- for(int k = j; paths[index].size() < S; ++k) {
- int t = (k == N) ? 0 : k;
- if(k > N) break;
- paths[index].push_back(t);
- }
- sort(begin(paths[index]), end(paths[index]));
- if(paths[index].size() == S)
- paths2.push_back(paths[index]);
- ++index;
- }
- }
- for(int i = 0; i < paths2.size(); ++i) {
- bool check{true};
- if(paths2[i].size() != S) continue;
- for(int j = 0; j < paths2[i].size()-1; ++j) {
- if(paths2[i].at(j) == paths2[i].at(j+1)) {
- check = false;
- break;
- }
- }
- if(check)
- paths3.push_back(paths2[i]);
- }
-
- for(auto const& i : paths3) {
- for(auto const& j : i)
- cout << st[j] << ' ';
-
- cout << endl;
- }
- cout << endl;
-
- int major{};
- for(int i = 0; i < paths3.size(); ++i) {
- vector<long> diffs;
- for(int j = 0; j < paths3[i].size()-1; ++j) {
- int p1 = st[paths3[i][j+1]];
- int p2 = st[paths3[i][j]];
- diffs.push_back(p1 - p2);
- }
- int miner = *min_element(begin(diffs), end(diffs));
- if(miner > major)
- major = miner;
- }
- cout << ts << ' ' << major << endl;
- out << major << endl;
- }
-
- in.close();
- out.close();
- return 0;
-}