Welcome to ACMSolver :: Largest ACM Programming Training Blog

Search Code (hints: hello world, sorting, 3n+1, backtracking)
 
ACMSOLVER is an ever increasing group of people, who like to solve, analyze and even create programming problems similar to ACM/ICPC programming Contest. Another important thing is, we are also trying to make the programming contest/ problem solving more popular for ever. One can also solve the problems on our own Archive (Problem Set). The only thing we wish to do is that spread out the knowledge of programming to the mass people! Now we plan to elaborate the site - Research for Programming, Development and Computer Science Education.
       
History of ACMSolver
ACMSolver- initiated by Ahmed Shamsul Arefin. It was first introduced in the year 2002. It has already been linked with many ACMICPC Online Judges and mentioned in Wikipedia as ACM-ICPC Training blog!  
 
// demonstrates minimum spanning tree
Programming Contest - C/C++ (Solution Codes)
Thursday, 02 July 2009 09:58
// mst.java
// demonstrates minimum spanning tree
// to run this program: C>java MSTApp
////////////////////////////////////////////////////////////////
class StackX
{
private final int SIZE = 20;
private int[] st;
private int top;
// -------------------------------------------------------------
public StackX() // constructor
{
st = new int[SIZE]; // make array
top = -1;
}
// -------------------------------------------------------------
public void push(int j) // put item on stack
{ st[++top] = j; }
// -------------------------------------------------------------
public int pop() // take item off stack
{ return st[top--]; }
// -------------------------------------------------------------
public int peek() // peek at top of stack
{ return st[top]; }
// -------------------------------------------------------------
public boolean isEmpty() // true if nothing on stack
{ return (top == -1); }
// -------------------------------------------------------------
} // end class StackX
////////////////////////////////////////////////////////////////
class Vertex
{
public char label; // label (e.g. 'A')
public boolean wasVisited;
// -------------------------------------------------------------
public Vertex(char lab) // constructor
{
label = lab;
wasVisited = false;
}
// -------------------------------------------------------------
} // end class Vertex
////////////////////////////////////////////////////////////////
class Graph
{
private final int MAX_VERTS = 20;
private Vertex vertexList[]; // list of vertices
private int adjMat[][]; // adjacency matrix
private int nVerts; // current number of vertices
private StackX theStack;
// -------------------------------------------------------------
public Graph() // constructor
{
vertexList = new Vertex[MAX_VERTS];
// adjacency matrix
adjMat = new int[MAX_VERTS][MAX_VERTS];
nVerts = 0;
for(int j=0; j<MAX_VERTS; j++) // set adjacency
for(int k=0; k<MAX_VERTS; k++) // matrix to 0
adjMat[j][k] = 0;
theStack = new StackX();
} // end constructor
// -------------------------------------------------------------
public void addVertex(char lab)
{
vertexList[nVerts++] = new Vertex(lab);
}
// -------------------------------------------------------------
public void addEdge(int start, int end)
{
adjMat[start][end] = 1;
adjMat[end][start] = 1;
}
// -------------------------------------------------------------
public void displayVertex(int v)
{
System.out.print(vertexList[v].label);
}
// -------------------------------------------------------------
public void mst() // minimum spanning tree (depth first)
{ // start at 0
vertexList[0].wasVisited = true; // mark it
theStack.push(0); // push it

while( !theStack.isEmpty() ) // until stack empty
{ // get stack top
int currentVertex = theStack.peek();
// get next unvisited neighbor
int v = getAdjUnvisitedVertex(currentVertex);
if(v == -1) // if no more neighbors
theStack.pop(); // pop it away
else // got a neighbor
{
vertexList[v].wasVisited = true; // mark it
theStack.push(v); // push it
// display edge
displayVertex(currentVertex); // from currentV
displayVertex(v); // to v
System.out.print(" ");
}
} // end while(stack not empty)

// stack is empty, so we're done
for(int j=0; j<nVerts; j++) // reset flags
vertexList[j].wasVisited = false;
} // end mst()
// -------------------------------------------------------------
// returns an unvisited vertex adj to v
public int getAdjUnvisitedVertex(int v)
{
for(int j=0; j<nVerts; j++)
if(adjMat[v][j]==1 && vertexList[j].wasVisited==false)
return j;
return -1;
} // end getAdjUnvisitedVert()
// -------------------------------------------------------------
} // end class Graph
////////////////////////////////////////////////////////////////
class MSTApp
{
public static void main(String[] args)
{
Graph theGraph = new Graph();
theGraph.addVertex('A'); // 0 (start for mst)
theGraph.addVertex('B'); // 1
theGraph.addVertex('C'); // 2
theGraph.addVertex('D'); // 3
theGraph.addVertex('E'); // 4

theGraph.addEdge(0, 1); // AB
theGraph.addEdge(0, 2); // AC
theGraph.addEdge(0, 3); // AD
theGraph.addEdge(0, 4); // AE
theGraph.addEdge(1, 2); // BC
theGraph.addEdge(1, 3); // BD
theGraph.addEdge(1, 4); // BE
theGraph.addEdge(2, 3); // CD
theGraph.addEdge(2, 4); // CE
theGraph.addEdge(3, 4); // DE

System.out.print("Minimum spanning tree: ");
theGraph.mst(); // minimum spanning tree
System.out.println();
} // end main()
} // end class MSTApp
////////////////////////////////////////////////////////////////

 
Templates in C++
Code:: C/C++/Java - task
Thursday, 02 July 2009 01:37

Function templates

Function templates are special functions that can operate with generic types. This allows us to create a function template whose functionality can be adapted to more than one type or class without repeating the entire code for each type.

In C++ this can be achieved using template parameters. A template parameter is a special kind of parameter that can be used to pass a type as argument: just like regular function parameters can be used to pass values to a function, template parameters allow to pass also types to a function. These function templates can use these parameters as if they were any other regular type.

The format for declaring function templates with type parameters is:

template <class identifier> function_declaration;
template <typename identifier> function_declaration;


The only difference between both prototypes is the use of either the keyword class or the keyword typename. Its use is indistinct, since both expressions have exactly the same meaning and behave exactly the same way.

For example, to create a template function that returns the greater one of two objects we could use:

template <class myType> myType GetMax (myType a, myType b) {  return (a>b?a:b); }
Read more...
 
AUST Inter University Programming Contest
Programming Contest - News
Wednesday, 17 June 2009 13:46

Ahsanullah University of Science and Technology has decided to organize this grand IT event, AUST Inter University Programming Contest 2009 (AUST IUPC 2009), on 24 July 2009 with a view to providing a forum to highly skilled computer programmers and academics at its newly built magnificent permanent campus. It is expected that about 80 teams from different universities all over the country will participate in the contest.

Each team will comprise three students enrolled in any recognized university program along with a teacher of that university as the coach of the team. Any number of teams may participate from a university. In general, environment of ACM ICPC, NCPC and other similar programs is supposed to prevail in the contest with typical rules, regulations, awards, etc.


http://www.aust. edu/iupc2009/ index.htm


Registration of Teams Opens: 27 June 2009 (10.00 AM - 3.00 PM)

Registration Deadline: 12 July 2009 , Up to 3.00 PM

Time/Date for Contest Kit Collection: 23 July 2009, 2.00 PM - 4.00 PM *

Time/Date of Mock Contest : 23 July 2009, 4.00 PM - 5.30 PM *

Date/Time of IUPC 2009: 24 July 2009, 8.00 AM  

 For further enquiry,  please contact

 

Prof. Dr. Abul Kasem Kamaluddin
Organizing Co-Chair

Email: This e-mail address is being protected from spambots. You need JavaScript enabled to view it
This e-mail address is being protected from spambots. You need JavaScript enabled to view it
Cell: 01911420868
Tel.: (02) 9897339, 9897311, 9897132, 9896696,
9897020, 9860907 Ext. 503

 

Mr. Faisal Muhammad Shah

Lecturer, Department of CSE, AUST
Cell: 01911090363
Email:
This e-mail address is being protected from spambots. You need JavaScript enabled to view it

      

 
At Newcastle..~ Keep going ACM Programmers
About - About us!
Thursday, 11 June 2009 08:10

Hello Programmmers

 

I needed to move to Newcastle, NSW, Australia at the University of Newcastle, to do my PhD. So there may be a small delay in updating this site.

No worries...I will be back ~ Arefin

 
More Articles...
<< Start < Prev 1 2 3 4 5 6 7 8 9 10 Next > End >>

Page 1 of 19

Site Statistics

Members : 182
Content : 131
Web Links : 6
Content View Hits : 128401

Login Form




Copyright © 2009 Welcome to ACMSolver :: Largest ACM Programming Training Blog. All Rights Reserved.
Joomla! is Free Software released under the GNU/GPL License.