1.

/**Angewandte Mathematik, SS11
* Problem: 11309 - Counting Chaos
* Link: http://uva.onlinejudge.org/external/113/11309.html
*
* @author Ritter Marius
* @author Wende Tom
* @author Zehentbauer Stefan
* @version 1.0, 05/19/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 1.448
*/

import java.util.Scanner;
public class Main {

public static void main(String[] args)
{
int zeit;
StringBuffer buff = new StringBuffer();
int lauf;
int hh;
int mm;
boolean ausgegeben;
boolean pali;
Scanner _scan = new Scanner(System.in);
lauf = _scan.nextInt();

for(int i = 0;i!=lauf;i++)
{
ausgegeben=false;
pali=false;
zeit = Integer.parseInt(_scan.next().replace(":", ""));
if ( zeit == 2359 )
buff.append("00:00\n");
else
{
do
{
if(zeit == 2359)
{
zeit=0;
pali=true;
buff.append("00:00\n");
ausgegeben=true;

}
else
{
zeit++;
if ( zeit % 100 == 60 ) zeit += 40;
}


//----------------------Suche nach Palidrom
if(!pali)
{
char[] a = String.format("%d", zeit).toCharArray();

if(!pali && zeit>=1000)
{
if(a[0]==a[3])
if(a[1]==a[2])
pali= true;
}
else if(!pali && zeit>=100)
{
if(a[0]==a[2])
pali= true;
}
else if(!pali&&zeit>=10)
{
if(a[0]==a[1])
pali= true;
}
else pali= true;
//----------------------
if (pali) {
mm = zeit % 100;
hh = zeit / 100;
buff.append(String.format("%02d:%02d\n", hh, mm));
ausgegeben=true;
}

}
}while(!ausgegeben);
}

}
System.out.print(buff);
}
}

2.

/**
* FWP, Angewandte Mathematik, SS11
* Problem: 11309 - Counting Chaos
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=25&page=show_problem&problem=2284
*
* @author Sebastian Stumpf
* @author Benjamin Vogt
* @version 1.0, 2011-05-06 12:07:24
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.284
*/

import java.io.*;
import java.util.*;


public class Main
{
// the times that are palindromic
static HashSet <Time> PALINDROMICTIMES = getPalindromicTimes();

// a Time, HH:MM, hours(24) and minutes
static private class Time
{
// the hours
int HH;
// minutes
int MM;

Time(int HH, int MM)
{
this.HH = HH;
this.MM = MM;
}

// add a minute to the Time
void addMin()
{
if(this.MM < 59)
++this.MM;
else if(this.HH < 23)
{
this.MM = 0;
++this.HH;
}
else
{
this.MM = 0;
this.HH = 0;
}
}

// a string for correct output
public String toString()
{
return (this.HH<10? "0"+this.HH: this.HH) + ":" + (this.MM<10? "0"+this.MM: this.MM);
}

// hashCode for the equals
public int hashCode()
{
return this.HH*1000+this.MM;
}

// equals compares two objects for equality
public boolean equals(Object other)
{
if(other == null)
return false;
if(this.getClass() != other.getClass())
return false;
if(this.hashCode() != other.hashCode())
return false;
return this.MM == ((Main.Time)other).MM && this.HH == ((Main.Time)other).HH;
}
}

// generates the palindromic Times as a HashSet of Times
static HashSet <Time> getPalindromicTimes()
{
HashSet <Time> PT = new HashSet <Time>();
// reason for the ifs is that leading zeros are overread
for(int HH = 0; HH < 24; ++HH)
for(int MM = 0; MM < 60; ++MM)
{
// HH == 0 => check MM
if(HH == 0)
{
// MM < 10 => time is Palindromic
if(MM < 10)
PT.add(new Main.Time(HH, MM));
// MM >= 10 => palindromic if you get MM again when exchanging the last and previous digit
else
{
int temp = MM % 10;
temp = temp * 10 + MM / 10;
if(temp == MM)
PT.add(new Main.Time(HH, MM));
}
}
// s.b.
else if(HH < 10)
{
int temp = MM % 10;
temp = temp * 100 + (MM / 10) * 10 + HH;
if(temp == HH * 100 + MM)
PT.add(new Main.Time(HH, MM));
}
else
{
int tempMM = MM % 10;
int tempHH = HH % 10;
int temp = tempMM * 1000 + (MM / 10) * 100 + tempHH * 10 + HH / 10;
if(temp == HH * 100 + MM)
PT.add(new Main.Time(HH, MM));
}
}
return PT;
}

public static void main(String args[]) throws Exception
{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int testCases = Integer.valueOf(reader.readLine());
StringTokenizer tokenizer;
Main.Time time;
for(int i = 0; i < testCases; ++i)
{
tokenizer = new StringTokenizer(reader.readLine(), ":");
time = new Main.Time(Integer.valueOf(tokenizer.nextToken()), Integer.valueOf(tokenizer.nextToken()));
// add minutes as long as the current Time is not part of the palindromic set
while(true)
{
time.addMin();
if(PALINDROMICTIMES.contains(time))
{
System.out.println(time);
break;
}
}
}
}
}


-------------------------------------------------------


1.

/*
* ACM Contest training
* Problem: 11309 - Counting Chaos
* Link: http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=25&problem=2284
*
* @author Christoph Goettschkes
* @version 1.0, 01/06/2011
*
* Method : Ad-Hoc
* Status : Accepted
* Runtime: 0.012
*/

#include <stdio.h>

int hh[2];
int mm[2];

void nextTime() {
mm[1]++;
if (mm[1] < 10) {
return;
}

mm[1] = 0, mm[0]++;

if (mm[0] < 6) {
return;
}

mm[0] = 0, hh[1]++;

if ((hh[0] < 2 && hh[1] < 10) || hh[1] < 4) {
return;
}

hh[1] = 0, hh[0]++;

if (hh[0] <= 2) {
return;
}

hh[0] = 0;
}

int isPal() {
if (hh[0] == 0) {
if (hh[1] == 0) {
if (mm[0] == 0) {
return 1;
}
return mm[0] == mm[1];
}
return hh[1] == mm[1];
}
return hh[0] == mm[1] && hh[1] == mm[0];
}

int main() {
int tc, h, m;
scanf("%d", &tc);

while (tc-- > 0) {
scanf("%d:%d", &h, &m);
hh[0] = h / 10;
hh[1] = h % 10;
mm[0] = m / 10;
mm[1] = m % 10;

nextTime();

while (!isPal())
nextTime();

printf("%d%d:%d%d\n", hh[0], hh[1], mm[0], mm[1]);

}

return 0;
}