How to create reactive tasks for programming competitions?

Posted by directx on Stack Overflow See other posts from Stack Overflow or by directx
Published on 2010-04-22T04:39:41Z Indexed on 2010/04/22 4:43 UTC
Read the original article Hit count: 386

A reactive task is sometimes seen in the IOI programming competition. Unlike batch tasks, reactive solutions take input from another program as well as outputting it. The program typically 'query' the judge program a certain number of times, then output a final answer.

An example

The client program accepts lines one by one, and simply echoes it back. When it encountered a line with "done", it exists immediately.

The client program in Java looks like this:

import java.util.*;
class Main{
  public static void main (String[] args){
     Scanner in = new Scanner(System.in);
     String s;
     while (!(s=in.nextLine()).equals("done"))
        System.out.println(s);
  }
}

The judge program gives the input and processes output from the client program. In this example, it feeds it a predefined input and checks if the client program has echoed it back correctly.

A session might go like this:

Judge       Client
------------------
Hello
            Hello
World
            World
done

I'm having trouble writing the judge program and having it judge the client program. I'd appreciate if someone could write a judge program for my example.

© Stack Overflow or respective owner

Related posts about competition

Related posts about reactive-programming