### SuryaManikanta's blog

By SuryaManikanta, history, 18 months ago,

 #include<bits/stdc++.h>
using namespace std;
#define SPEED() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define MOD 1000000007

vector<ll> topo;
vector<ll> vis (1e5+1);

if(vis[x]){
return;
}
vis[x]=1;
}

topo.push_back(x);
}

int main(){
ll n,m;cin>>n>>m;
vector<vector<ll>> rev (n+1);

ll a,b,ans=0;
for(int i=0;i<m;i++){
cin>>a>>b;
rev[b].push_back(a);
}
vector<ll> dp (n+1);
dp[1]=1;
// for(auto ele:topo)
//   cout<<ele<<" ";

reverse(topo.begin(),topo.end());
// for(auto ele: topo)
// cout<<ele<<" ";

for(auto ele:topo){
if (ele>1)
{
for(auto elee:rev[ele]){

dp[ele]+=dp[elee];
dp[ele]%=MOD;

}
}

}

cout<<dp[n]<<endl;
// for(int i=1;i<=n;i++){
//   cout<<dp[i]<<endl;
// }

}


getting runtime error for large inputs.

• -8

By SuryaManikanta, history, 22 months ago,

Yesterday, I gave codeforces round 801. I read first problem, I am the guy who expects clear problem statements any how I end up skipping first problem(I solved it later after contest dedicating 5 min for reading clearly and understand the problem),We do expect a clean and neat problem statement. Went ahead to solve problem B It's my fault I read the question wrong(Mike starts picking always from pile 1, I have not noticed that and solved for problem where Mike can start with any pile) My wrong observation code passed Test cases, So they can take some time and design sample test cases in a way such that many can clear their doubts about the problem from them(although I agree they can't show a way to solve the problem but adding few extra cases which don't direct to solution will definitely help readers/solvers to get good idea of the problem and avoids many mistakes.

• +11