Evirir

Untitled

Mar 1st, 2021
640
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <bits/stdc++.h>
  2. #include <ext/pb_ds/assoc_container.hpp>
  3. #include <ext/pb_ds/tree_policy.hpp>
  4. using namespace std;
  5. using namespace __gnu_pbds;
  6.  
  7. #pragma GCC optimize("Ofast")
  8. #define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
  9. #define mset(d,val) memset(d,val,sizeof(d))
  10. #define setp(x) cout<<fixed<<setprecision(x)
  11. #define forn(i,a,b) for(int i=(a);i<(b);i++)
  12. #define fore(i,a,b) for(int i=(a);i<=(b);i++)
  13. #define pb push_back
  14. #define F first
  15. #define S second
  16. #define pqueue priority_queue
  17. #define fbo find_by_order
  18. #define ook order_of_key
  19. typedef long long ll;
  20. typedef pair<ll,ll> ii;
  21. typedef vector<ll> vi;
  22. typedef vector<ii> vii;
  23. typedef long double ld;
  24. template<typename T>
  25. using pbds = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  26. void amin(ll &a, ll b){ a=min(a,b); }
  27. void amax(ll &a, ll b){ a=max(a,b); }
  28. void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
  29. void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
  30. const ll INF = ll(1e18);
  31. const int MOD = 998244353;
  32.  
  33. const bool DEBUG = 0;
  34. const int MAXN = 100005;
  35.  
  36. int main()
  37. {
  38.     ios_base::sync_with_stdio(0); cin.tie(0);
  39.    
  40.     int n; cin>>n;
  41.     vector<int> a(n);
  42.     forn(i,0,n) a[i]=i;
  43.     map<pair<vector<int>,vector<int>>, vector<int>> mp;
  44.    
  45.     do
  46.     {
  47.         vector<int> mn(n), mx(n);
  48.         for(int i=0;i<n;i++)
  49.         {
  50.             bool left=i==0, right=i==n-1;
  51.             for(int j=i-1;j>=0;j--)
  52.             {
  53.                 if(a[j]<a[i]) left=1;
  54.             }
  55.             for(int j=1+1;j<n;j++)
  56.             {
  57.                 if(a[i]<a[j]) right=1;
  58.             }
  59.             mn[i]=left && right;
  60.         }
  61.         for(int i=0;i<n;i++)
  62.         {
  63.             bool left=i==0, right=i==n-1;
  64.             for(int j=i-1;j>=0;j--)
  65.             {
  66.                 if(a[j]>a[i]) left=1;
  67.             }
  68.             for(int j=1+1;j<n;j++)
  69.             {
  70.                 if(a[i]>a[j]) right=1;
  71.             }
  72.             mx[i]=left && right;
  73.         }
  74.        
  75.         if(mp.find({mn,mx})!=mp.end())
  76.         {
  77.             vector<int> dup=mp[{mn,mx}];
  78.             cout<<"FAIL: a=";
  79.             forn(i,0,n) cout<<a[i]<<" ";
  80.             cout<<"dup=";
  81.             forn(i,0,n) cout<<dup[i]<<" ";
  82.             cout<<'\n';
  83.         }
  84.         mp[{mn,mx}]=a;
  85.     }
  86.     while(next_permutation(a.begin(),a.end()));
  87.    
  88.     return 0;
  89. }
  90.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×