This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
//In His Name
#include <bits/stdc++.h>
//#pragma GCC optimization("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx2")
using namespace std;
#define ll long long
#define int ll
typedef pair<int, int> pii;
#define F first
#define S second
#define pb push_back
#define bug(x) cout << "Ah shit , here we go again : " << x <<endl
#define all(x) x.begin() , x.end()
const int maxn = 14 , MOD = 1e9 + 7;
const ll INF = 1e18;
int n , val[2*maxn];
vector<string> v;
void Solve(string& a, int l, int r) {
if(l == r) v.pb(a);
else {
for (int i = l; i <= r; i++) {
swap(a[l], a[i]);
Solve(a, l + 1, r);
swap(a[l], a[i]);
}
}
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin >> n;
for(int i = 1 ; i <= n ; i++){
int x;
cin >> x;
val[x] = 1;
}
int ans = 0;
string s = "";
for(int i = 1 ; i <= 2*n ; i++) s += to_string(i);
Solve(s , 0 , s.size()-1);
for(string j : v){
string x = "";
for(int i = 0 ; i < j.size() ; i++) x += to_string(((j[i] - '0' + 1)/2));
for(int i = 1 ; i <= n ; i++){
bool mark[15];
memset(mark , 0 , sizeof mark);
for(int k = 0 ; k < x.size() ; k++) {
if (!mark[x[k] - '0']) x[k]--, mark[x[k] - '0' +1] = true;
if(x[k] < '0') x[k] = '0';
}
}
for(int i = 0 ; i < x.size() ; i++) {
if (x[i] > '0' and val[i + 1] == 0) {
ans--;
break;
}
if(x[i] <= '0' and val[i + 1] == 1){
ans--;
break;
}
}
ans++;
ans %= MOD;
}
cout << ans ;
}
Compilation message (stderr)
ruins3.cpp: In function 'int32_t main()':
ruins3.cpp:47:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | for(int i = 0 ; i < j.size() ; i++) x += to_string(((j[i] - '0' + 1)/2));
| ~~^~~~~~~~~~
ruins3.cpp:51:31: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
51 | for(int k = 0 ; k < x.size() ; k++) {
| ~~^~~~~~~~~~
ruins3.cpp:56:27: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
56 | for(int i = 0 ; i < x.size() ; i++) {
| ~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |