Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- int main() {
- ifstream input;
- ofstream output;
- input.open("input.txt");
- output.open("output.txt");
- int number;
- input >> number;
- for (int i = 0; i < number; i++) {
- int len;
- input >> len;
- int *buf = new int[len];
- input >> buf[0];
- int exp_id = 0;
- int max_id = 0;
- int raz_id = len - 1;
- bool flag = true;
- int j;
- for (j = 1; j < len; j++) {
- input >> buf[j];
- if ((buf[exp_id] == buf[j]) && (j - exp_id == 1)) {
- exp_id = j;
- }
- if (buf[j] != buf[exp_id]) {
- if (buf[max_id] < buf[j]) {
- max_id = j;
- }
- }
- }
- for (j = len - 1; j > max_id; j--) {
- if ((buf[raz_id] == buf[j]) && (raz_id - j == 1)) {
- raz_id = j;
- }
- }
- for (j = exp_id + 1; j < max_id; j++) {
- if (buf[j] >= buf[j + 1]) {
- output << "Nein";
- flag = false;
- break;
- }
- }
- if (j == max_id) {
- for (j = raz_id; j > max_id; j--) {
- if (buf[j] >= buf[j - 1]) {
- output << "Nein";
- flag = false;
- break;
- }
- }
- }
- if (exp_id + 1 == len ||exp_id > max_id || max_id > raz_id || max_id == raz_id || exp_id == max_id) {
- output << "Nein";
- flag = false;
- }
- if (flag) {
- output << "Freytag " << exp_id + 1 << " " << max_id + 1 << " " << raz_id + 1;
- }
- output << endl;
- delete[] buf;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement