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>
using namespace std;
const int nmax = 1e4;
int nr = 0;
int n;
int v[nmax + 5], sol[nmax + 5];
bool done = false;
void Back(int k, int Max = 0)
{
if(done)
{
return;
}
if(k > n)
{
++nr;
done = true;
for(int i=1; i<=n; i++)
{
if(sol[i] != v[i])
{
done = false;
}
}
return;
}
for(int i=1; i<=Max+1 && !done; i++)
{
sol[k] = i;
Back(k + 1, max(Max, i));
}
}
int main()
{
#ifdef home
freopen("nr.in","r",stdin);
freopen("nr.out","w",stdout);
#endif // home
cin>>n;
for(int i=1; i<=n; i++)
{
cin>>v[i];
}
nr = 0;
Back(1);
cout<<nr<<'\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |