6 November 2011 Comments Off

Video Tutorial – ACM -ICPC at UWA, Australia

Problem solving tactics for the ACM ICPC programming competition: search and optimisation from Evgeni Sergeev on Vimeo.

27 February 2011 Comments Off

Power up C++ with the Standard Template Library: Part II: Advanced Uses

Power up C++ with the Standard Template Library: Part II: Advanced Uses

We will love to quote Topcoder’s STL tutorial by DmitryKorolev here:

“Creating Vector from Map
As you already know, map actually contains pairs of element. So you can write it in like this:

 map<string, int> M;
 // ...
 vector< pair<string, int> > V(all(M)); // remember all(c) stands for

Now vector will contain the same elements as map. Of course, vector will be sorted, as is map. This feature may be useful if you are not planning to change elements in map any more but want to use indices of elements in a way that is impossible in map.

Copying data between containers
Let’s take a look at the copy(…) algorithm. The prototype is the following:

 copy(from_begin, from_end, to_begin);

This algorithm copies elements from the first interval to the second one. The second interval should have enough space available. See the following code:

 vector<int> v1;
 vector<int> v2; 

 // ... 

 // Now copy v2 to the end of v1
 v1.resize(v1.size() + v2.size());
 // Ensure v1 have enough space
 copy(all(v2), v1.end() - v2.size());
 // Copy v2 elements right after v1 ones

Another good feature to use in conjunction with copy is inserters. I will not describe it here due to limited space but look at the code:

 vector<int> v;
 // ...
 set<int> s;
 // add some elements to set
 copy(all(v), inserter(s));

The last line means:

 tr(v, it) {
// remember traversing macros from Part I

But why use our own macros (which work only in gcc) when there is a standard function? It’s a good STL practice to use standard algorithms like copy, because it will be easy to others to understand your code.”

Full tutorial here: http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=standardTemplateLibrary2

4 January 2011 Comments Off

How Install C/C++ Compiler by Max Berger

Max Berger, who is currently a Software Developer at Amazon EU, has written a nice tutorial about installing C/C++ compiler. Here we quote this tutorial:

“(…)Setting up a compiler

Unfortunately Eclipse only provides the Integrated Development Environment (IDE) but it is missing the actual compiler. To install a compiler, please follow the instructions for your operating system.

Windows compiler

Windows doesn’t come with a build-in compiler. You could try to install Visual Studio, but it is tricky to get that working with Eclipse. Therefore we will install MSYS. MSYS is part of the MinGW suite, which provides free development tools for Windows.

You will have to follow these 4 steps:

  • Download and install MinGW
  • Download and install MSYS
  • Set your path environment variable
  • Restart Eclipse if it was started.


First, you need to download MinGW. You can either click through the websites mentioned above or go directly to the MinGW download area. Look for the Package “Automated MinGW Installer”. There, download the file ending in .exe. The file name should be something like “MinGW-5.1.4.exe”. You can also download MinGW Version 5.1.4 from the link given here.

You may also download an older version, and follow the instructions given in the section called “Older Instructions”:

Most of the options in the MinGW 5 installer are pretty straightforward. I will point out some of the more tricky options.

The first one of such options is which “MinGW” package to install. Any of those should work just fine, but I would recommend Current.

Figure 1. MinGW 5 install

MinGW 5 install

MinGW will ask which components to install. Either select All or at least make sure that you have the g++ compiler checked. This is needed for C++ support.