i have written i<A.size().....not i<=A.size().... i think thats not error..and i have tried it also
On May 28, 5:35 pm, Bharath Raghavendran <[email protected]> wrote: > I dont know what the question is or what the algo is supposd to do. But i > guess the error is happening at this point : > A.at(A.size()) > > maybe you need to do A.at(A.size()-1) ? > > On 28 May 2010 17:49, Aamir Khan <[email protected]> wrote: > > > I was doing some practice for codeforces round 15 to be held in around > > 27 hours from now.... > > I have written the C++ source code for codeforces round 14/A problem > > (Letter)... > > I am getting runtime error which i am not able to understand... > > Please help.. > > > Error: > > > terminate called after throwing an instance of 'std::out_of_range' > > what(): vector::_M_range_check > > Aborted > > > Source Code: > > /************** > > Header Files > > **************/ > > > #include <iostream> > > #include <vector> > > #include <cstdio> > > #include <cstdlib> > > #include <stdexcept> > > #include <string> > > #include <iomanip> > > > using namespace std; > > > typedef vector<int> vi; > > > int main() > > { > > int row,col; > > cin>>row>>col; > > const int cols=col; > > const int rows=row; > > char Array[rows][cols]; > > string sentence; > > vi A; > > vi B; > > > for(int i=0;i<rows;i++) > > { cin>>sentence; > > for (int j=0;j<cols;j++) > > { Array[i][j]=sentence[j]; > > if (Array[i][j]=='*') > > { A.push_back(i); > > B.push_back(j); } > > > } > > } > > > for(int i=A.at(0);i<A.at(A.size());i++) > > { > > int max_B=0; > > int min_B=row-1; > > for ( unsigned l=0;l<B.size();l++) > > { > > if(max_B < B.at(l)) > > max_B=B.at(l); > > if(min_B > B.at(l)) > > min_B=B.at(l); > > } > > > for (int j=min_B;j<max_B;j++) > > { cout<<Array[i][j]; > > } > > } > > > cin.get(); > > cin.ignore(); > > return 0; > > } > > > And if you have better algorithm to solve the problem then please > > share it here.... > > > -- > > You received this message because you are subscribed to the Google Groups > > "google-codejam" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]<google-code%[email protected]> > > . > > For more options, visit this group at > >http://groups.google.com/group/google-code?hl=en. -- You received this message because you are subscribed to the Google Groups "google-codejam" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-code?hl=en.
