Nov 192008
 

ICPC Team Strategy

Co-author: Andoko Chandra, Andrian Kurniady, Evan Leonardi, Suhendry Effendy.

There are several ways to solve this problem.

Dynamic Programming
This was the first approach which came to my mind after I read the problem. I’m sure if you’re fond with DP then the recurrence structure for this problem is not hard to find. Define a state in dynamic programming as f(k,S,T): the maximum number of problem that can be solved, where k is the last student who solved a problem, S is the set of solved problems, and T is the current time. Just try all the remaining students and problems combination.


k = last person who solved a problem.
S = set of solved problems.
T = current time.
i = next person to solve problem.
j = next problem to be solved.
tij = time required by i to solve problem j.

To implement set S, you will need bitmask operation (using set stl/library will not pass the time-limit). The maximum size of S is 12, so the number of distict set S is not more than 212. The overall time-complexity is O(2N . P2 . T . N), where N is the number of problems, T is the contest time (280), and P is the number of student (3).

Kurniady suggested to process each state in ascending order of T (using priority queue) and flag on [k, S]. Actually, it is Dijkstra’s Algorithm with [k, S] as nodes in the graph.

Brute Force (?)
There are 4 possibilities for each problem:
– Solved by Andi.
– Solved by Budi.
– Solved by Chandra.
– The problem is not solved by the team.

So, the idea is to brute force all of this possibilities (there are 4N combinations) and find one which give the best result. For each combination we should check whether the combination is feasible, i.e. they can solve the problems so that no student solve two problems consecutively. This can be done by checking if there is a student who solve more than half of the problems (round up). If yes, then the combination is not feasible.

The overall time-complexity is O(4N . N). I have not yet verified this approach yet as I realized there is a brute force solution after the contest. Will it pass the time-limit?

New update. I have just tested the brute force solution and it did not pass the time-limit.

If you have noticed the number of author of this problem, then maybe you will ask “why did you need so many authors just to prepare an easy problem?”. There’s a story behind this :))

This problem was solved by 8 teams. The first team to solve this problem is Joy (58).


  35 Responses to “ACM-ICPC 2008 Jakarta – Problem Set & Analysis”

  1. Hi, shouldn’t it be “Rabin-Karp” instead of “Booyer-Moore”?

  2. ooops, you’re right 😀 , thanks!

  3. Hi, I’m a member of team Seed.
    It’s a great problemset, and it’s really responsible for the author team to write such detailed solutions after the contest.

    Here’s some of our experience:
    1. We use segment tree to solve E 🙁
    2. We solved I using DFS(4^n), only add a few pre-cut.

    Would you mind if I ask for the testdata of the contest, so we could use it for practice, and I could test my program for D & H.
    My email is: chy_charlie@hotmail.com

  4. Oh, and also the time limit for each problem.
    Thanks a lot.

  5. @Cheng Yu:

    1. Yeah, some other teams also used segment tree to solve E 😀
    2. Hm, interesting 😕

    Btw, I have sent an email for you 🙂 We will also upload the problemset and testdata to baylor’s archieve.

  6. Don’t worry, I won’t paste the exact value of 3^^^^3 as I know it wouldn’t fit in here… instead I would like to paste the exact values of the so-called “? scrapers” from this site, which make those hyper-mod numbers above insignificant http://www.polytope.net/hedrondude/scrapers.htm

  7. i’am trying to solve the problem I using brute force , but my answer still judge wrong answer.
    is there any trick on the brute force one?
    still curious ^^

  8. @indra
    what problem you’re talking about?

  9. @Indra Suryatama:
    No, there isn’t any tricky case. It means your bruteforce solution was wrong 🙂

    @Felix J:
    Clearly he’s talking about problem “I”

  10. Yap i’am thalkin about problem I….
    hmm still curious….
    is the judge test case can be downloaded? cause still curious in which test case my solution get wrong hehehe
    maybe my brute force solution was wrong….
    but until now i still dunno which test case hahah
    because at that time i make several test case and it passed hehehhehehe ^^
    maybe you can give me some advice heheh ^^

  11. by the way …. you said
    “New update. I have just tested the brute force solution and it did not pass the time-limit.”
    so we cant solve problem I with brute force solution…?
    hmmm hahah so i must moved on from BF solution tu DP solution ya… heheheh
    tq

  12. @Indra Suryatama:
    check your mail.

    Your bruteforce program failed on some cases. I suspect that your program didn’t properly check whether a combination/solution is possible to happen or not.

    If you do plain 4^N brute force then you’ll surely get TLE 🙂

  13. Hi Suhendry!
    Great reviews for the problems! You mention in one of the comments that you’ll sen the dataset to the Baylor Archive. If you mean the CLI Live Archive, we didn’t recieved anything yet. We’ve already uploaded the problem descriptions, so having the datasets will be very very helpful for us.

    Please, contact me at carlos.marce@gmail.com

    Thanks!

  14. Hi Carlos!

    No wonder the problemset is still not available in Live Archieve, the email address was wrong…

    check your mail, thanks 🙂

  15. Thanks to Carlos, now the problemset is available in CLI Live Archieve:

    http://acmicpc-live-archive.uva.es/nuevoportal/region.php?r=as7&year=2008

    enjoy it 🙂

  16. Hi Suhendry! Could you please send the testcase to me for my practice these problems? I don’t know where the baylor’s archieve is…could you tell me? Thanks!
    mail: f7495622@mail.ncku.edu.tw

  17. Oh i means where can i find the testcase in the baylor’s archieve… i can’t find the correct link. Could you please tell me ??

  18. Thanks a lot for this great and detailed review!

    If only every regional had these type of reviews 🙁

    Also I really loved the problem set and I can feel that it especially enriched my DP skills. Thanks to all problem setters.

  19. hi 🙂

    I’m Ivan from the team from Ateneo de Manila University, Philippines. I was wondering if you can send the testdata to my email? I’d use it to analyze our solutions to the problems, and for our future training sessions as well.

    My email is ivan_pisay07@yahoo.com.

    And oh, your review of the problems is great! Thanks for this 🙂

  20. So what’s the story behind problem I? 😀

  21. Hi,

    will you please send testdata to me for our training contests?

    Thanks,

    — Kamran

  22. plz ,Explain 3rd test case according to your algorithm,
    i,e min{ (ai-bi)mod 10,(bi-ai) mod 10} , then MST….

  23. for problem A

    plz ,Explain 3rd test case according to your algorithm,
    i,e min{ (ai-bi)mod 10,(bi-ai) mod 10} , then MST….

  24. The link for the CLI Live Archive is not working for me, can anyone update it?

  25. @rizoan toufiq
    First, compute the cost from each state to other state.

    For example,
    1234 to 5678 =
    min((1-5+10) mod 10, (5-1+10) mod 10) +
    min((2-6+10) mod 10, (6-2+10) mod 10) +
    min((3-7+10) mod 10, (7-3+10) mod 10) +
    min((4-8+10) mod 10, (8-4+10) mod 10) +
    = 4 + 4 + 4 + 4 = 16

    The matrix cost will be:
    0 16 12
    16 0 12
    12 12 0

    The MST for above graph is 24. Connect the MST with (0,0,0,0) and you will get 26.

  26. @John Bull

    The CLI Live Archive link is working…

  27. You did a good job.

  28. hi everyBody…

    i have a problem about Palindrome number .
    i want to find a Palindrome number By index of numbers ( numbers are subset of natural numbers = N )
    like this :::

    input | output
    9 | 9
    10 | 11
    29 | 202
    40 | 313
    & so on…

    i want an algorithm to find this

    (someone said : e.g. : if input = 12 /// output => 12 + 21 = 33
    or 64= > 64+46 = 110 go on = > 110+011 = 111 /// But not true for all numbers)

    please help me

    • //in c++
      #include
      #include
      using namespace std;
      int main()
      {
      char s[22],a[20],b[20];int i,j;
      cin>>a;
      for(i=0,j=strlen(a)-1;i<strlen(a);i++,j–)
      b[j]=a[i];
      for(i=0;i<strlen(a);i++)
      s[i]=(a[i]-48)+(b[i]-48)+48;
      for(i=0;i46 && s[i]<58)
      cout<<s[i];
      cout<<endl;
      return 0;
      }

  29. mohammed just out of curiosity what do you need this algorithm?

  30. I got TLE in ICPC team strategy, altough I’ve used DP bitmask. Can someone suggest me please..

  31. Hi Suhendry, I praticed solving this contest some days ago and I used brute force for this problem (ICPC Team Strategy). I tried all the possibilities and I got AC in 2.6s. After that, I add only one line of code for checking some variables and then I submitted again and got AC in 0.104s. I’m really surprise! 🙂

  32. HI!!
    I have some problem with ICPC team strategy : (
    I use DP + bitmask , run for all the state by 5*for,
    and the time complexity is the same as yours , but still TLE : (
    Is there any cut or tip ?
    thanks.

  33. Can you please email me the test data for the contest , we are a team from Egypt and we will use this data to prepare for the coming regional contest
    here is my e-mail: kamokim2@gmail.com

    Thanks

  34. Could you mind if I you send me test data of the contest specially D and F , so my team could use it for practice.

    E-mail : yasser.csd@gmail.com

    Thanks

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)