getting gnu_cxx::concurrence_lock_error

Revision en1, by carlosramirez, 2020-05-03 08:32:53

/*BISMILLAH UR RAHMAN*/ /* AUTHOR -CARLOSRAMIREZ *///Perfection is achieved only on the point of collapse

include <bits/stdc++.h>

define endl "\n"

define pb push_back

define all(v) v.begin(),v.end()

define debug(x) std::cerr << #x << ": " << (x) << '\n';

define sz(x) int(x.size())

define INF INT_MAX;

using namespace std; typedef long long int ll; vector<tuple<int,int,int>> v(int(1e5+10)); int store[4][int(1e5+10)]; int dp(int n,int pre) { if(n<=0)return 0; if(store[pre][n])return store[pre][n]; int ans=0,a,b,c; tie(a,b,c)=v[n]; if(pre==1) ans=max(b+dp(n-1,2),c+dp(n-1,3)); else if(pre==2) ans=max(a+dp(n-1,1),c+dp(n-1,3)); else ans=max(a+dp(n-1,1),b+dp(n-1,2)); return store[pre][n]=ans; } int main() { int n;cin>>n; for(int i=1,x,y,z;i<=n;++i) { cin>>x>>y>>z;v[i]=make_tuple(x,y,z); } int ans=INT_MIN; int a,b,c; tie(a,b,c)=v[n]; vector v1{a,b,c}; for(int i=1;i<=3;++i) ans=max(ans,v1[i-1]+dp(n-1,i)); cout<<ans<<endl; }

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en4 English carlosramirez 2020-05-03 12:06:42 336
en3 English carlosramirez 2020-05-03 12:04:15 46 well,posting it 2nd time after minor editing (published)
en2 English carlosramirez 2020-05-03 11:58:38 71 (saved to drafts)
en1 English carlosramirez 2020-05-03 08:32:53 1087 although i have got AC(by modifying the above) but i am not able to understand why this solution is throwing "terminate called after throwing an instance of__gnu_cxx::__concurrence_lock_error" error on inputs like( 1 100 10 1).FYI the problem is of atcoder dp contest (C).sorry for asking doubts from other platfrom .thanks in advance! (published)