#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > vec, vec2;
int a[2][35], n, p, ans;
void recur(int ind)
{
if (ind>n*2)
{
vec.clear();
vec2.clear();
for (int i=1; i<=n; i++)
{
vec.push_back({a[0][i], a[1][i]});
vec2.push_back({a[1][i], a[0][i]});
}
sort(vec.begin(), vec.end());
sort(vec2.begin(), vec2.end());
int res=0, res2=0, pre=0, pre2=0;
for (int i=0; i<vec.size(); i++)
{
if (pre<vec[i].first)
{
pre=vec[i].second;
res++;
}
}
for (int i=0; i<vec2.size(); i++)
{
if (pre2<vec2[i].second)
{
pre2=vec2[i].first;
res2++;
}
}
if (res<res2)
ans++;
return;
}
for (int i=1; i<=n; i++)
{
if ((i==1 || a[0][i-1]) && !a[0][i])
{
a[0][i]=ind;
recur(ind+1);
a[0][i]=0;
}
}
for (int i=1; i<=n; i++)
{
if (a[0][i] && !a[1][i])
{
a[1][i]=ind;
recur(ind+1);
a[1][i]=0;
}
}
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
recur(1);
cout << ans; // remember to put p back here later
}
Compilation message
festival2.cpp: In function 'void recur(int)':
festival2.cpp:19:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
19 | for (int i=0; i<vec.size(); i++)
| ~^~~~~~~~~~~
festival2.cpp:27:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
27 | for (int i=0; i<vec2.size(); i++)
| ~^~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
504 ms |
300 KB |
Output is correct |
9 |
Correct |
523 ms |
300 KB |
Output is correct |
10 |
Correct |
501 ms |
300 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
30 ms |
212 KB |
Output is correct |
13 |
Correct |
31 ms |
300 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
504 ms |
300 KB |
Output is correct |
9 |
Correct |
523 ms |
300 KB |
Output is correct |
10 |
Correct |
501 ms |
300 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
30 ms |
212 KB |
Output is correct |
13 |
Correct |
31 ms |
300 KB |
Output is correct |
14 |
Execution timed out |
9072 ms |
212 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
504 ms |
300 KB |
Output is correct |
9 |
Correct |
523 ms |
300 KB |
Output is correct |
10 |
Correct |
501 ms |
300 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
30 ms |
212 KB |
Output is correct |
13 |
Correct |
31 ms |
300 KB |
Output is correct |
14 |
Execution timed out |
9072 ms |
212 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
504 ms |
300 KB |
Output is correct |
9 |
Correct |
523 ms |
300 KB |
Output is correct |
10 |
Correct |
501 ms |
300 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
30 ms |
212 KB |
Output is correct |
13 |
Correct |
31 ms |
300 KB |
Output is correct |
14 |
Execution timed out |
9072 ms |
212 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
316 KB |
Output is correct |
5 |
Correct |
1 ms |
320 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
504 ms |
300 KB |
Output is correct |
9 |
Correct |
523 ms |
300 KB |
Output is correct |
10 |
Correct |
501 ms |
300 KB |
Output is correct |
11 |
Correct |
3 ms |
212 KB |
Output is correct |
12 |
Correct |
30 ms |
212 KB |
Output is correct |
13 |
Correct |
31 ms |
300 KB |
Output is correct |
14 |
Execution timed out |
9072 ms |
212 KB |
Time limit exceeded |
15 |
Halted |
0 ms |
0 KB |
- |