Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #include <ext/pb_ds/assoc_container.hpp>
- #include <ext/pb_ds/tree_policy.hpp>
- using namespace std;
- using namespace __gnu_pbds;
- #pragma GCC optimize("Ofast")
- #define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
- #define mset(d,val) memset(d,val,sizeof(d))
- #define setp(x) cout<<fixed<<setprecision(x)
- #define forn(i,a,b) for(int i=(a);i<(b);i++)
- #define fore(i,a,b) for(int i=(a);i<=(b);i++)
- #define pb push_back
- #define F first
- #define S second
- #define pqueue priority_queue
- #define fbo find_by_order
- #define ook order_of_key
- typedef long long ll;
- typedef pair<ll,ll> ii;
- typedef vector<ll> vi;
- typedef vector<ii> vii;
- typedef long double ld;
- template<typename T>
- using pbds = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
- void amin(ll &a, ll b){ a=min(a,b); }
- void amax(ll &a, ll b){ a=max(a,b); }
- void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
- void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
- const ll INF = ll(1e18);
- const int MOD = 998244353;
- const bool DEBUG = 0;
- const int MAXN = 100005;
- int main()
- {
- ios_base::sync_with_stdio(0); cin.tie(0);
- int n; cin>>n;
- vector<int> a(n);
- forn(i,0,n) a[i]=i;
- map<pair<vector<int>,vector<int>>, vector<int>> mp;
- do
- {
- vector<int> mn(n), mx(n);
- for(int i=0;i<n;i++)
- {
- bool left=i==0, right=i==n-1;
- for(int j=i-1;j>=0;j--)
- {
- if(a[j]<a[i]) left=1;
- }
- for(int j=1+1;j<n;j++)
- {
- if(a[i]<a[j]) right=1;
- }
- mn[i]=left && right;
- }
- for(int i=0;i<n;i++)
- {
- bool left=i==0, right=i==n-1;
- for(int j=i-1;j>=0;j--)
- {
- if(a[j]>a[i]) left=1;
- }
- for(int j=1+1;j<n;j++)
- {
- if(a[i]>a[j]) right=1;
- }
- mx[i]=left && right;
- }
- if(mp.find({mn,mx})!=mp.end())
- {
- vector<int> dup=mp[{mn,mx}];
- cout<<"FAIL: a=";
- forn(i,0,n) cout<<a[i]<<" ";
- cout<<"dup=";
- forn(i,0,n) cout<<dup[i]<<" ";
- cout<<'\n';
- }
- mp[{mn,mx}]=a;
- }
- while(next_permutation(a.begin(),a.end()));
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement