<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Wilbert Liu&#039;s Blog</title>
	<atom:link href="http://wilbertliu.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://wilbertliu.wordpress.com</link>
	<description>Just do my best everytime in my life</description>
	<lastBuildDate>Tue, 18 Jan 2011 01:06:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='wilbertliu.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Wilbert Liu&#039;s Blog</title>
		<link>http://wilbertliu.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://wilbertliu.wordpress.com/osd.xml" title="Wilbert Liu&#039;s Blog" />
	<atom:link rel='hub' href='http://wilbertliu.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Codeforces Beta Round #14</title>
		<link>http://wilbertliu.wordpress.com/2010/06/04/codeforces-beta-round-14/</link>
		<comments>http://wilbertliu.wordpress.com/2010/06/04/codeforces-beta-round-14/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 19:39:28 +0000</pubDate>
		<dc:creator>Wilbert Liu</dc:creator>
				<category><![CDATA[Codeforces]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://wilbertliu.wordpress.com/?p=111</guid>
		<description><![CDATA[Hi All.. It&#8217;s time to blog again.. Now i will post some small-writeup about the problems were used at this contest.. Well.., about today small-writeup, i will not post my source code anymore. Because in practice we are sure that &#8230; <a href="http://wilbertliu.wordpress.com/2010/06/04/codeforces-beta-round-14/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wilbertliu.wordpress.com&amp;blog=12686597&amp;post=111&amp;subd=wilbertliu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi All.. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>It&#8217;s time to blog again.. Now i will post some small-writeup about the problems were used at <a href="http://codeforces.com/contest/14" target="_blank">this contest</a>..</p>
<p>Well.., about today small-writeup, i will not post my source code anymore. Because<br />
in practice we are sure that reading the source code at first sight will make us<br />
bored and no creativity to implement our own solution..</p>
<p>Here is me at standing page :<br />
<a href="http://wilbertliu.files.wordpress.com/2010/06/standings.png"><img class="alignnone size-medium wp-image-112" title="Standing Page" src="http://wilbertliu.files.wordpress.com/2010/06/standings.png?w=300&#038;h=133" alt="Standing Page" width="300" height="133" /></a></p>
<p>Okay then, i will only put my ideas in this writeup. So, enjoy it.. <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><span id="more-111"></span><strong>Problem A : Letter (Accepted 1st try)</strong><br />
It is a very nice problem at the beginning. We are given rectangular board, we should take some rectangular board (possibly smaller) that cover all the shaded square. My idea is to make 4 lines, and take their intersection to be the left topmost and the right bottom, so we can make a rectangle with that. After that, print the solution. It can be done in O(n * m) time. Since the n and m is small, the algorithm above will be run in-time.</p>
<p><strong>Problem B : Young Photographer (Accepted 1st try)</strong><br />
This problem is about &#8220;array differencing&#8221; problem. But since the constraints were small enough, i decided to code it in the worst complexity (maybe). My idea is just make an array of positions, then increment it one-by-one if there are sports-man at that position. The complexity of this solution is O(n ^ 2) i think. The solution of this problem is to compare each position that contain n sports-man at there and the initial position of the photographer, take the minimum.</p>
<p><strong>Problem C : Four Segments (Accepted 3rd try)</strong><br />
This is a simple geometry problem. What did i do is to generate permutation of the segments, and decide if the rectangle is exist there. The complexity is O(4!), since there are 4 segments given. I did Wrong Answer 2 times because a silly mistakes. And it is time-consuming problem.</p>
<p><strong>Problem D : Two Paths (Wrong Answer)</strong><br />
I can&#8217;t solve this problem yet. But actually my idea is to select some vertex and make it a &#8220;divider&#8221;. But i think that&#8217;s the wrong idea, so never mind.. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Maybe anyone can help me to solve this? <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  I am very sure that i have no idea how to solve it because of there are some algorithms that i never learn before.</p>
<p><strong>Problem E : Camels (Accepted 1st try)</strong><br />
Well, this is my favorite problem in this contest. The combination about geometry stuffs and dynamic programming. I used 5-dimensions table of DP to solve it. Maybe anyone have a better complexity or memory? <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  I spent many times to write the code, because the implementation was quite time-consuming.</p>
<p>Yeah, that&#8217;s all.. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Feedbacks are welcome then.. Please comment if you like this post or<br />
want to give some tips, etc? <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Best Regards,<br />
Wilbert Liu</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wilbertliu.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wilbertliu.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wilbertliu.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wilbertliu.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/wilbertliu.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/wilbertliu.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/wilbertliu.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/wilbertliu.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wilbertliu.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wilbertliu.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wilbertliu.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wilbertliu.wordpress.com/111/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wilbertliu.wordpress.com/111/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wilbertliu.wordpress.com/111/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wilbertliu.wordpress.com&amp;blog=12686597&amp;post=111&amp;subd=wilbertliu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://wilbertliu.wordpress.com/2010/06/04/codeforces-beta-round-14/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/527d0f4343a7d4f7f0380195af8a69e7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Wilbert</media:title>
		</media:content>

		<media:content url="http://wilbertliu.files.wordpress.com/2010/06/standings.png?w=300" medium="image">
			<media:title type="html">Standing Page</media:title>
		</media:content>
	</item>
		<item>
		<title>Finally Have A Time To Blog</title>
		<link>http://wilbertliu.wordpress.com/2010/05/29/finally-have-a-time-to-blog/</link>
		<comments>http://wilbertliu.wordpress.com/2010/05/29/finally-have-a-time-to-blog/#comments</comments>
		<pubDate>Fri, 28 May 2010 17:05:02 +0000</pubDate>
		<dc:creator>Wilbert Liu</dc:creator>
				<category><![CDATA[Activities]]></category>
		<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://wilbertliu.wordpress.com/?p=95</guid>
		<description><![CDATA[Several months ago was the busiest months for me. Actually i prepared my final presentation about internship in some company, and of course, i had to prepare my thesis defense. That&#8217;s why i can&#8217;t update this blog regularly. But now &#8230; <a href="http://wilbertliu.wordpress.com/2010/05/29/finally-have-a-time-to-blog/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wilbertliu.wordpress.com&amp;blog=12686597&amp;post=95&amp;subd=wilbertliu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Several months ago was the busiest months for me. Actually i prepared my final presentation about internship in some company, and of course, i had to prepare my thesis defense. That&#8217;s why i can&#8217;t update this blog regularly.</p>
<p>But now i have lots of free time, because i&#8217;ve already finished such &#8220;busiest&#8221; things at my university time. And i think, it&#8217;s time to fill this blog with some new stories, sketch, and something funny that will entertain your day (i hope) <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>The first thing that i should consider about posting some &#8220;algorithm write-up&#8221; is i will not post the code anymore. The reason behind that is obvious, i want the reader to think about the implementation by themselves. Many times i found that reading other implementation at first made us not creative anymore.</p>
<p>Okay then, let&#8217;s wait for the new post.. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wilbertliu.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wilbertliu.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wilbertliu.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wilbertliu.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/wilbertliu.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/wilbertliu.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/wilbertliu.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/wilbertliu.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wilbertliu.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wilbertliu.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wilbertliu.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wilbertliu.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wilbertliu.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wilbertliu.wordpress.com/95/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wilbertliu.wordpress.com&amp;blog=12686597&amp;post=95&amp;subd=wilbertliu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://wilbertliu.wordpress.com/2010/05/29/finally-have-a-time-to-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/527d0f4343a7d4f7f0380195af8a69e7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Wilbert</media:title>
		</media:content>
	</item>
		<item>
		<title>My Activities So Far</title>
		<link>http://wilbertliu.wordpress.com/2010/05/01/my-activities/</link>
		<comments>http://wilbertliu.wordpress.com/2010/05/01/my-activities/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 19:43:26 +0000</pubDate>
		<dc:creator>Wilbert Liu</dc:creator>
				<category><![CDATA[Activities]]></category>
		<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://wilbertliu.wordpress.com/?p=76</guid>
		<description><![CDATA[Hi all.., i am quite busy with my research few weeks ago.. So i can&#8217;t update this blog regularly. But now i have a time to rest, since my research paper was submitted, so that i just wait for the &#8230; <a href="http://wilbertliu.wordpress.com/2010/05/01/my-activities/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wilbertliu.wordpress.com&amp;blog=12686597&amp;post=76&amp;subd=wilbertliu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi all.., i am quite busy with my research few weeks ago..</p>
<p>So i can&#8217;t update this blog regularly. But now i have a time to rest, since my research paper was submitted, so that i just wait for the thesis defense schedule around May..</p>
<p>Well.., i spent my time with my lovely girlfriend, and doing something funny (of course) at SPOJ (you know that well). Yeah, i solved problems at there..</p>
<p>I think i will share something tomorrow.., something about problems of course..</p>
<p>Stay tuned!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wilbertliu.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wilbertliu.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wilbertliu.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wilbertliu.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/wilbertliu.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/wilbertliu.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/wilbertliu.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/wilbertliu.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wilbertliu.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wilbertliu.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wilbertliu.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wilbertliu.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wilbertliu.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wilbertliu.wordpress.com/76/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wilbertliu.wordpress.com&amp;blog=12686597&amp;post=76&amp;subd=wilbertliu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://wilbertliu.wordpress.com/2010/05/01/my-activities/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/527d0f4343a7d4f7f0380195af8a69e7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Wilbert</media:title>
		</media:content>
	</item>
		<item>
		<title>Codeforces Beta Round #4</title>
		<link>http://wilbertliu.wordpress.com/2010/03/23/codeforces-beta-round-4/</link>
		<comments>http://wilbertliu.wordpress.com/2010/03/23/codeforces-beta-round-4/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 20:56:24 +0000</pubDate>
		<dc:creator>Wilbert Liu</dc:creator>
				<category><![CDATA[Codeforces]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://wilbertliu.wordpress.com/?p=30</guid>
		<description><![CDATA[Yesterday is a great day.., i coded my thesis quickly and realize that i have a time to solve problems at night . Of course, i won&#8217;t let it go away. Well, i think i become addicted to Codeforces now, &#8230; <a href="http://wilbertliu.wordpress.com/2010/03/23/codeforces-beta-round-4/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wilbertliu.wordpress.com&amp;blog=12686597&amp;post=30&amp;subd=wilbertliu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Yesterday is a great day.., i coded my thesis quickly and realize that i have a time to solve problems at night <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . Of course, i won&#8217;t let it go away. Well, i think i become addicted to <a title="Codeforces" href="http://codeforces.com/" target="_blank">Codeforces</a> now, since there are good quality problems with various difficulty. So, i went there, at <a title="Codeforces Beta Round #4" href="http://codeforces.com/contest/4/">this past contest</a>! Here is me at standing page :</p>
<div id="attachment_31" class="wp-caption alignnone" style="width: 310px"><a href="http://wilbertliu.files.wordpress.com/2010/03/standings.png"><img class="size-medium wp-image-31" title="Standings" src="http://wilbertliu.files.wordpress.com/2010/03/standings.png?w=300&#038;h=132" alt="Standings" width="300" height="132" /></a><p class="wp-caption-text">Standings</p></div>
<p><span id="more-30"></span></p>
<p><strong>Problem A :</strong></p>
<p>It is a nice problem (i think). Given W, the weight of watermelon bought by the boys, we have to determine whether the watermelon can be divided into 2 parts with each of them having even number of kilos, or not. At first, brute force came up in my mind, but then i found a really nice solution for this problem. The first observation is, assume the watermelon with weight w can be divided into 2 parts, so, w = 2x + 2y = 2(x + y), because each part must have even value. From the first observation, we can see that if w can be divided into 2 parts, then w must be even value. Then, it&#8217;s easy to see that 2x + 2y must be &gt;= 4, because the lowest positive even number is 2, so 2 + 2 = 4. Here is my implementation :</p>
<p><pre class="brush: cpp; collapse: true; light: false; toolbar: true;">
#include &lt;cstdio&gt;

using namespace std;

int n;

int main()
{
    while(scanf(&quot;%d&quot;, &amp;n) != EOF)
        printf(n % 2 == 0 &amp;&amp; n &gt; 2 ? &quot;YES\n&quot; : &quot;NO\n&quot;);
    return 0;
}
</pre></p>
<p><strong>Problem B :</strong><br />
There are several approaches to solve this problem, but i used to solve this problem with Dynamic Programming, since i can&#8217;t proof other approaches like Greedy, etc. Post on comment if you have any questions about my DP.. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> . So, without doubt, here is my implementation for this problem :</p>
<p><pre class="brush: cpp; collapse: true; light: false; toolbar: true;">
#include &lt;algorithm&gt;
#include &lt;cstdio&gt;
#include &lt;cstring&gt;

using namespace std;

int d, sumTime, path[30];
bool dp[30][241], vis[30][241];
pair&lt;int, int&gt; tme[30];

bool doit(int pos, int t)
{
    if(pos == d)
    {
        if(t == 0)
            return true;
        else
            return false;
    }
    bool &amp;ret = dp[pos][t];
    if(!vis[pos][t])
    {
        vis[pos][t] = true;
        ret = false;
        for(int i = tme[pos].first; i &lt;= tme[pos].second; ++i)
        {
            bool check = false;
            if(t &gt;= i)
                check = doit(pos + 1, t - i);
            if(check)
                path[pos] = i;
            ret |= check;
        }
    }
    return ret;
}

int main()
{
    while(scanf(&quot;%d %d&quot;, &amp;d, &amp;sumTime) != EOF)
    {
        memset(vis, false, sizeof(vis));
        for(int i = 0; i &lt; d; ++i)
            scanf(&quot;%d %d&quot;, &amp;tme[i].first, &amp;tme[i].second);
        for(int i = tme[0].first; i &lt;= tme[0].second; ++i)
        {
            bool check = false;
            if(sumTime &gt;= i)
                check = doit(1, sumTime - i);
            if(check)
                path[0] = i;
        }
        if(path[0] &gt;= tme[0].first &amp;&amp; path[0] &lt;= tme[0].second)
        {
            printf(&quot;YES\n%d&quot;, path[0]);
            for(int i = 1; i &lt; d; ++i)
                printf(&quot; %d&quot;, path[i]);
        }
        else
            printf(&quot;NO&quot;);
        printf(&quot;\n&quot;);
    }
    return 0;
}
</pre></p>
<p><strong>Problem C :</strong></p>
<p>From the first time i read the problem statement, i know it can be solved with map. I implemented it quickly and got AC at first time submit. Here is my implementation :</p>
<p><pre class="brush: cpp; collapse: true; light: false; toolbar: true;">

#include &lt;cstdio&gt;
#include &lt;iostream&gt;
#include &lt;map&gt;
#include &lt;string&gt;

using namespace std;

int n;
string s;
map&lt;string, int&gt; mp;

int main()
{
    while(scanf(&quot;%d&quot;, &amp;n) != EOF)
    {
        mp.clear();
        getline(cin, s);
        for(int i = 0; i &lt; n; ++i)
        {
            getline(cin, s);
            if(!mp[s])
            {
                ++mp[s];
                printf(&quot;OK\n&quot;);
            }
            else
            {
                printf(&quot;%s%d\n&quot;, s.c_str(), mp[s]);
                ++mp[s];
            }
        }
    }
    return 0;
}
</pre></p>
<p><strong>Problem D :</strong></p>
<p>I think this is the hardest problem compared to the other problems. At this problem i have to find the answer for maximum chain and i have to print the &#8220;path&#8221; of the answer. I just thought a simple way, because this problem is similar to Longest Increasing Subsequence problem. Printing path was quite easy job here. I got WA 2 times because i tried to proof Greedy solution for this problem. At first i was sure that my Greedy was true, but after submitting the solution, i got WA and i can&#8217;t found the couter example to disprove my solution. So, i turned out to think about DP to solve this problem. Here is my implementation :</p>
<p><pre class="brush: cpp; collapse: true; light: false; toolbar: true;">
#include &lt;algorithm&gt;
#include &lt;cstdio&gt;
#include &lt;cstring&gt;
#include &lt;vector&gt;

using namespace std;

struct env
{
    int w, h, id;

    bool operator &lt; (const env &amp;e) const
    {
        if(w &lt; e.w || w == e.w &amp;&amp; h &lt; e.h)
            return true;
        return false;
    }
};

int n, w, h, dp[5000], path[5000];
env e[5000];

int main()
{
    while(scanf(&quot;%d %d %d&quot;, &amp;n, &amp;w, &amp;h) != EOF)
    {
        int cnt = 0;
        for(int i = 0; i &lt; n; ++i)
        {
            env tem;
            scanf(&quot;%d %d&quot;, &amp;tem.w, &amp;tem.h);
            if(tem.w &gt; w &amp;&amp; tem.h &gt; h)
            {
                e[cnt].w = tem.w;
                e[cnt].h = tem.h;
                e[cnt].id = i + 1;
                ++cnt;
            }
        }
        sort(e, e + cnt);
        if(cnt &gt; 0)
        {
            for(int i = 0; i &lt; cnt; ++i)
            {
                dp[i] = 1;
                path[i] = i;
                for(int j = 0; j &lt; i; ++j)
                    if(e[j].w &lt; e[i].w &amp;&amp; e[j].h &lt; e[i].h &amp;&amp; dp[i] &lt; dp[j] + 1)
                    {
                        dp[i] = dp[j] + 1;
                        path[i] = j;
                    }
            }
            int res = 1, tip = 0;
            for(int i = 0; i &lt; cnt; ++i)
            if(res &lt; dp[i])
            {
                res = dp[i];
                tip = i;
            }
            vector&lt;int&gt; resPath;
            resPath.push_back(e[tip].id);
            while(path[tip] != tip)
            {
                resPath.push_back(e[path[tip]].id);
                tip = path[tip];
            }
            printf(&quot;%d\n%d&quot;, res, resPath[resPath.size() - 1]);
            for(int i = resPath.size() - 2; i &gt;= 0; --i)
                printf(&quot; %d&quot;, resPath[i]);
        }
        else
            printf(&quot;0&quot;);
        printf(&quot;\n&quot;);
    }
    return 0;
}
</pre></p>
<p>Feel free to ask anything here.. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Best Regards,<br />
Wilbert Liu</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wilbertliu.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wilbertliu.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wilbertliu.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wilbertliu.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/wilbertliu.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/wilbertliu.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/wilbertliu.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/wilbertliu.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wilbertliu.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wilbertliu.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wilbertliu.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wilbertliu.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wilbertliu.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wilbertliu.wordpress.com/30/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wilbertliu.wordpress.com&amp;blog=12686597&amp;post=30&amp;subd=wilbertliu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://wilbertliu.wordpress.com/2010/03/23/codeforces-beta-round-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/527d0f4343a7d4f7f0380195af8a69e7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Wilbert</media:title>
		</media:content>

		<media:content url="http://wilbertliu.files.wordpress.com/2010/03/standings.png?w=300" medium="image">
			<media:title type="html">Standings</media:title>
		</media:content>
	</item>
		<item>
		<title>Codeforces Beta Round #5</title>
		<link>http://wilbertliu.wordpress.com/2010/03/21/codeforces-beta-round-5/</link>
		<comments>http://wilbertliu.wordpress.com/2010/03/21/codeforces-beta-round-5/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 14:26:44 +0000</pubDate>
		<dc:creator>Wilbert Liu</dc:creator>
				<category><![CDATA[Codeforces]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://wilbertliu.wordpress.com/?p=9</guid>
		<description><![CDATA[Well.., i am busy now with my own thesis and internship in some company. But still, i spent my time around 1 hour to solve problems here : http://codeforces.com/contest/5 There are 5 problems with various difficulty, and i found myself &#8230; <a href="http://wilbertliu.wordpress.com/2010/03/21/codeforces-beta-round-5/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wilbertliu.wordpress.com&amp;blog=12686597&amp;post=9&amp;subd=wilbertliu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well.., i am busy now with my own thesis and internship in some company. But still, i spent my time around 1 hour to solve problems here : <a title="Codeforces Beta Round #5" href="http://codeforces.com/contest/5" target="_blank">http://codeforces.com/contest/5</a></p>
<p>There are 5 problems with various difficulty, and i found myself solved the first two problems easily, and then i scratched my mind to solve the third problem, but i can&#8217;t found any solutions at that time.., but still thinking to find the right way to solve that one..</p>
<p><span id="more-9"></span>I will post my solution on the other problems if i can solve them later.. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Here is my solutions to problem A and B</p>
<p><pre class="brush: cpp; collapse: true; light: false; toolbar: true;">
//A.cpp
#include &lt;cstdio&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

string s;
int fr = 0, res = 0;

int main()
{
    while(getline(cin, s))
    {
        if(s[0] == '+')
            ++fr;
        else if(s[0] == '-')
            --fr;
        else
        {
            for(int i = 0; i &lt; s.size(); ++i)
                if(s[i] == ':')
                {
                    if(i + 1 &lt; s.size())
                        res += (s.size() - (i + 1)) * fr;
                    break;
                }
         }
     }
     printf(&quot;%d\n&quot;, res);
     return 0;
}
</pre></p>
<p><pre class="brush: cpp; collapse: true; light: false; toolbar: true;">
//B.cpp
#include &lt;algorithm&gt;
#include &lt;cstdio&gt;
#include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

string s, w[1000];
int longest = 0, turn = 0;

int main()
{
    int cnt = 0;
    while(getline(cin, s))
    {
        longest = max(longest, (int) s.size());
        w[cnt] = s;
        ++cnt;
    }
    for(int i = 0; i &lt; longest + 2; ++i)
        printf(&quot;*&quot;);
    printf(&quot;\n&quot;);
    for(int i = 0; i &lt; cnt; ++i)
    {
        printf(&quot;*&quot;);
        int leng = longest - w[i].size();
        if(leng % 2 == 0)
        {
            for(int j = 0; j &lt; leng / 2; ++j)
            printf(&quot; &quot;);
            printf(&quot;%s&quot;, w[i].c_str());
            for(int j = 0; j &lt; leng / 2; ++j)
                printf(&quot; &quot;);
        }
        else
        {
            for(int j = 0; j &lt; leng / 2 + turn; ++j)
                printf(&quot; &quot;);
            printf(&quot;%s&quot;, w[i].c_str());
            for(int j = 0; j &lt; leng / 2 + !turn; ++j)
                printf(&quot; &quot;);
            turn = !turn;
        }
        printf(&quot;*\n&quot;);
    }
    for(int i = 0; i &lt; longest + 2; ++i)
        printf(&quot;*&quot;);
    printf(&quot;\n&quot;);
    return 0;
}
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wilbertliu.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wilbertliu.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wilbertliu.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wilbertliu.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/wilbertliu.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/wilbertliu.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/wilbertliu.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/wilbertliu.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wilbertliu.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wilbertliu.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wilbertliu.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wilbertliu.wordpress.com/9/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wilbertliu.wordpress.com/9/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wilbertliu.wordpress.com/9/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wilbertliu.wordpress.com&amp;blog=12686597&amp;post=9&amp;subd=wilbertliu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://wilbertliu.wordpress.com/2010/03/21/codeforces-beta-round-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/527d0f4343a7d4f7f0380195af8a69e7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Wilbert</media:title>
		</media:content>
	</item>
		<item>
		<title>I’m Here</title>
		<link>http://wilbertliu.wordpress.com/2010/03/21/im-here/</link>
		<comments>http://wilbertliu.wordpress.com/2010/03/21/im-here/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 03:25:47 +0000</pubDate>
		<dc:creator>Wilbert Liu</dc:creator>
				<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://wilbertliu.wordpress.com/?p=5</guid>
		<description><![CDATA[Hi All&#8230; After few moments, i decide to do blogging again.. I think it&#8217;s important to share all of my life to the other people.. My daily life, relationship, vision, target, etc.. How about my previous blog? Hmm.., maybe i &#8230; <a href="http://wilbertliu.wordpress.com/2010/03/21/im-here/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wilbertliu.wordpress.com&amp;blog=12686597&amp;post=5&amp;subd=wilbertliu&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi All&#8230;</p>
<p>After few moments, i decide to do blogging again.. I think it&#8217;s important to share all of my life to the other people.. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  My daily life, relationship, vision, target, etc.. How about <a title="my previous blog" href="http://wilbertjava.wordpress.com/" target="_blank">my previous blog</a>? Hmm.., maybe i will start to ignore that, since this blog will contain tech things like programming, math, algorithm, etc..</p>
<p>Well, i try to post all things here with English, because i am learning English right now.. :p So, forgive me if there are typos here.. I&#8217;d be glad if someone remind me about my mistakes.. <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Okay, enjoy my blog then, i will try to update it regularly if i have enough time..</p>
<p>Best Regards,</p>
<p>Wilbert Liu</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/wilbertliu.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/wilbertliu.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/wilbertliu.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/wilbertliu.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/wilbertliu.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/wilbertliu.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/wilbertliu.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/wilbertliu.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/wilbertliu.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/wilbertliu.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/wilbertliu.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/wilbertliu.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/wilbertliu.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/wilbertliu.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=wilbertliu.wordpress.com&amp;blog=12686597&amp;post=5&amp;subd=wilbertliu&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://wilbertliu.wordpress.com/2010/03/21/im-here/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/527d0f4343a7d4f7f0380195af8a69e7?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Wilbert</media:title>
		</media:content>
	</item>
	</channel>
</rss>
