This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define N 200005
using namespace std;
void solve(){
int n;
cin >> n;
vector<int> v;
for(int i = 0;i<n;i++){
int x;
cin >> x;
v.push_back(x);
}
sort(v.begin(),v.end());
int ans = 0;
do{
int cnt = 0;
int last = -1;
for(int i = 1;i<n;i++){
if(v[i] == v[i-1])continue;
int now = (v[i] > v[i-1]);
if(now != last){
if(last == -1 && now == 1){
break;
}
cnt++;
last = now;
}
}
if(cnt == 4){
ans++;
}
//if(cnt == 4){
// for(auto u:v){
// cout << u << " ";
// }
// cout << endl;
//}
}while(next_permutation(v.begin(),v.end()));
cout << ans << endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
#ifdef Local
freopen("in.txt","r",stdin);
freopen("out.txt","w",stdout);
#endif
int t = 1;
//cin >> t;
while(t--){
solve();
}
#ifdef Local
cout << endl << fixed << setprecision(2) << 1000.0*clock()/CLOCKS_PER_SEC << " milliseconds.";
#endif
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |