48982023-04-06 02:07:46SleepyOverlordKövetkező permutáció (50 pont)cpp17Time limit exceeded 12/50280ms4996 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

const int LIMIT = CLOCKS_PER_SEC / 4.1;

int n;
VI a;

int main()
{
	clock_t start = clock();

	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;
		if (clock() - start > LIMIT) 
		{
			cout << -1;
			return 0;
		}
	}

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

	return 0;
}
SubtaskSumTestVerdictTimeMemory
base12/50
1Accepted0/03ms1876 KiB
2Time limit exceeded0/0270ms2112 KiB
3Accepted1/13ms2476 KiB
4Accepted1/13ms2412 KiB
5Accepted1/13ms2612 KiB
6Accepted1/13ms2780 KiB
7Accepted2/23ms2988 KiB
8Accepted2/2228ms3100 KiB
9Accepted2/23ms3316 KiB
10Accepted2/23ms3556 KiB
11Wrong answer0/1246ms3608 KiB
12Wrong answer0/1246ms3740 KiB
13Wrong answer0/1246ms3836 KiB
14Wrong answer0/1246ms3956 KiB
15Wrong answer0/3246ms4056 KiB
16Wrong answer0/3246ms4148 KiB
17Wrong answer0/3246ms4360 KiB
18Wrong answer0/3246ms4448 KiB
19Time limit exceeded0/3280ms4440 KiB
20Time limit exceeded0/3263ms4444 KiB
21Time limit exceeded0/3252ms3956 KiB
22Time limit exceeded0/3259ms4916 KiB
23Time limit exceeded0/3270ms4996 KiB
24Time limit exceeded0/3270ms4692 KiB
25Wrong answer0/2246ms4868 KiB
26Time limit exceeded0/2273ms4676 KiB