This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main()
{
int n;
cin>>n;
vector<pair<int,int>> city(n);
for(int i=0;i<n;i++)
{
int a,b;
cin>>a>>b;
city[i]={a,b};
}
int ans=0;
for(int i=0;i<1<<(n-1);i++)
{
int last=0;
int flag=1;
for(int j=0;j<n-1;j++)
{
int d=city[last].first;
int x=city[last].second;
if((i>>j)%2)
{
if(d!=0 && !((j+1-last)%d) && (j+1-last)/d<=x && (j+1-last)/d>=1 )
last=j+1;
else
flag=0;
}
}
if(flag)
ans++;
}
cout<<ans;
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... |