48962023-04-05 23:55:46SleepyOverlordKövetkező permutáció (50 pont)cpp17Time limit exceeded 12/50300ms4540 KiB
#include <vector>
#include <string> 
#include <set> 
#include <map> 
#include <unordered_set>
#include <unordered_map>
#include <queue> 
#include <bitset> 
#include <stack>
#include <list>

#include <numeric> 
#include <algorithm> 
#include <random>
#include <chrono>

#include <cstdio>
#include <fstream>
#include <iostream> 
#include <sstream> 
#include <iomanip>
#include <climits>

#include <cctype>
#include <cmath> 
#include <ctime>
#include <cassert>

using namespace std;

#define ULL unsigned long long
#define LL long long
#define PII pair <int, int>
#define VB vector <bool>
#define VI vector <int>
#define VLL vector <LL>
#define VD vector <double>
#define VS vector <string>
#define VPII vector <pair <int, int> >
#define VVI vector < VI >
#define VVB vector < VB >
#define SI set < int >
#define USI unordered_set <int>
#define MII map <int, int>
#define UMII unordered_map <int, int>
#define MS multiset
#define US unordered_set
#define UM unordered_map
#define UMS unordered_multiset
#define UMM unordered_multimap

#define FORN(i, n) for(int i = 0; i < (n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for(int i = (a); i >= (b); --i)

#define SZ size()
#define BG begin() 
#define EN end() 
#define CL clear()
#define X first
#define Y second
#define RS resize
#define PB push_back
#define MP make_pair
#define ALL(x) x.begin(), x.end()
#define INS insert
#define ER erase
#define CNT count

int n;
VI a;

int main()
{
	cin >> n;
	a.RS(n + 1);
	FOR(i, 1, n) cin >> a[i];

	while (1)
	{
		next_permutation(a.BG + 1, a.EN);
		bool ok = true;
		FOR(i, 1, n - 2)
		{
			FOR(j, i + 1, n - 1)
			{
				if (a[i] > a[j])
					FOR(k, j + 1, n)
						if (a[j] < a[k] && a[i] > a[k])
						{
							ok = false;
							break;
						}
			}
		}
		if (ok) break;
	}

	FOR(i, 1, n) cout << a[i] << " ";

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base12/50
1Accepted0/03ms1752 KiB
2Time limit exceeded0/0300ms1984 KiB
3Accepted1/13ms2212 KiB
4Accepted1/13ms2384 KiB
5Accepted1/13ms2584 KiB
6Accepted1/13ms2736 KiB
7Accepted2/23ms2956 KiB
8Accepted2/2137ms3060 KiB
9Accepted2/23ms3160 KiB
10Accepted2/23ms3284 KiB
11Time limit exceeded0/1298ms3472 KiB
12Time limit exceeded0/1254ms3448 KiB
13Time limit exceeded0/1254ms3684 KiB
14Time limit exceeded0/1266ms3920 KiB
15Time limit exceeded0/3259ms3848 KiB
16Time limit exceeded0/3275ms3088 KiB
17Time limit exceeded0/3266ms3968 KiB
18Time limit exceeded0/3270ms3972 KiB
19Time limit exceeded0/3266ms4000 KiB
20Time limit exceeded0/3280ms4024 KiB
21Time limit exceeded0/3254ms4120 KiB
22Time limit exceeded0/3259ms4376 KiB
23Time limit exceeded0/3259ms4452 KiB
24Time limit exceeded0/3266ms4540 KiB
25Time limit exceeded0/2263ms4504 KiB
26Time limit exceeded0/2254ms3828 KiB