# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
894947 |
2023-12-29T09:31:31 Z |
vjudge1 |
Ruins 3 (JOI20_ruins3) |
C++17 |
|
0 ms |
344 KB |
//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
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 |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |