Skip to Content

Blogs

Solution to hw00f

#include <cstdlib>
#include <iostream>
 
using namespace std;
 
int main(int argc, char *argv[])
{
    int n;
    int min,max,val;
    scanf("%d",&n);
    min = INT_MAX;
    max = INT_MIN;
    for (int i = 0;i < n;i++) {
        scanf("%d",&val);
        if (val < min) min = val;
        if (val > max) max = val;
    }
    printf("%d\n%d\n",min,max);
    return EXIT_SUCCESS;
}

Solution to hw00e

#include <stdio.h>
#include <iostream>
 
using namespace std;
 
int main(int argc, char *argv[])
{
    int w,h;
    double hf;
    scanf("%d %d",&w,&h);
    hf = h * 0.01;
    printf("%.3f\n",w/hf/hf);
    return EXIT_SUCCESS;
}

Solution to hw00d

#include <stdio.h>
#include <iostream>
#include <math.h>
 
using namespace std;
 
int main(int argc, char *argv[])
{
    int h,m;
    int min;
    int nm,nh;
    scanf("%d %d",&h,&m);
    scanf("%d",&min);
    nm = (m + min) % 60;
    nh = ( h + (m + min) / 60) ;
    nh = nh % 24;
    printf("%02d %02d\n",nh,nm);
    return EXIT_SUCCESS;
}

IOI 2010

สำหรับ Jun 06 2010

Semper Fidelis

I am not a student of history nor have ever wished to be one. I lack background knowledge so required to judiciously analyze current event. Moreover, I cannot faithfully say that I understand their desire, their hatred nor their anger. You can be assured that you won’t find any attempt in justifying nor rationalizing the course of current event here. I won’t bother condemn nor praise any decision nor anybody.

I won’t contemplate for tomorrow what the government should do, what the red-shirt should do or what all of us should do. That is something already fallen into the good hands of several intellectual and spiritual leaders of our community.
What I know is that these unfortunate, unsought and unmindful events ultimately are something to which I will look back ruefully; because I undeniably take at least some responsibility in nourishing it. Yes, I used to support what yellow-shirts did and, now, red-shirts are doing something similar or so.

Yet again, remorse is not what I want to share with you today. All I yearn to do is to make a wish. I wish that I know a path, a particular one that will bring us all to a philosophical society, a society that treasures understanding of other and us at the top virtue. I sincerely believe that if we understand them, there will be no more them; it will be just us. We won’t see them as someone else but a fellow Thai people who simply wish for well-being. We won’t utter belligerent tone that separates them from us. We won’t call them non-Thai, unpatriotic, wretched soul or any things of sort.

I will brand myself a hypocrite if I don’t admit that, right now, while punching a keyboard, a big portion of my thought still hate them, don’t understand them and wish them all hell. Ironically, even though we call ourselves “homo sapiens”, i.e., “wise men”, we still act out of clouded judgment, or worse, purely instinct. However, I hope, faithfully, truly, and constantly that someday, I will find the path that would make me someone I wish I should be.

Always Faithful,
Nattee Niparnan

Diet Diary #53 -- #69

Last two weeks were very busy one for me. I DID keep track of my weight but couldn’t record my eating. Eating time is totally lost. Here is the best that my memory could serve.

1 May 2010, Sat

morning weight: 82.0 kg

completely lost track of meals.


2 May 2010, Sun

morning weight: 82.3 kg

BF: 2 Bananas + water
Lunch: ข้าวราดแกง
Dinner: นิตยาไก่ย่าง

Bo’s father-side grandma passed away today.


3 May 2010, Mon

morning weight: 82.6 kg

BF: 2 Bananas + water
Lunch: can’t remember
20:00 Dinner: กระเพาะปลา @ grandma’s funeral.

The first day of funeral. Today is also a substitute for Mayday so Bo was could help with the funeral for the whole day. Government section (including Chula U) is on a working day.


4 May 2010, Tue

morning weight: 82.7 kg

BF: 2 Bananas + water
Lunch: can’t remember
20:00 Dinner: ก๋วยจั๊บ @ grandma’s funeral.


5 May 2010, Wed

morning weight: 82.0 kg

BF: 2 Bananas + water
Lunch: Salad
20:00 Dinner: เกี้ยวน้ำ @ grandma’s funeral.


6 May 2010, Thu

morning weight: 81.6 kg

BF: 2 Bananas + water
Lunch: Salad
20:00 Dinner: ข้าวต้มหมู @ grandma’s funeral.


7 May 2010, Fri

morning weight: 81.5 kg

BF: 2 Bananas + water
Lunch: Salad
17:30 Dinner: โต๊ะจีน @ grandma’s funeral.

This day was กงเต๊ก day for grandma. The ceremonial ended at almost midnight.


8 May 2010, Sat

morning weight: 81.2 kg

BF: 2 Bananas + water
Lunch: โต๊ะจีน @ grandma’s funeral.
Snack: ซาลาเปา, บัวลอย
Dinner: ครัวกลางกรุง (Big Meal)

Burial ceremony at สระบุรี took the entire day since the morning. We left mourning ceremony traditionally at the end of the day.


9 May 2010, Sun

morning weight: 82.0 kg

BF: 2 Bananas + water
Lunch: โต๊ะจีน @ grandma’s funeral.
Snack: ซาลาเปา, บัวลอย
Dinner: ครัวกลางกรุง (Big Meal)

Burial ceremony at สระบุรี took the entire day since the morning. We left mourning ceremony traditionally at the end of the day.


10 May 2010, Mon (my birthday)

morning weight: 82.3

09:00 BF: nothing
13:00 Lunch: can’t remember
18:30 Dinner: can’t remember

I and bo and her mom and dad went to La Toscana resort at Ratchaburi. Didn’t bring the scale with us.


11 May 2010, Tue (my birthday)

morning weight: 81.6

09:00 BF: 2 Banana
13:00 Lunch: Italian cuisine @ La Toscana
18:30 Dinner: Steak @ The Scenery (Big Meal)

I and bo and her mom and dad went to La Toscana resort at Ratchaburi. Didn’t bring the scale with us.


12 May 2010, Wed

morning weight: —- no scale —-

09:00 BF: 2 Banana + all-you-can-eat American breakfast (Big meal)
14:00 Lunch: ไก่ย่าง ส้มตำ ข้าวเหนียว & etc (Big meal)
18:30 Dinner: none.

On the way back from La Toscana, we stopped at Northeastern restaurant near ไร่ขิง temple and had another big meal for lunch.


13 May 2010, Thu

morning weight: 82.1

09:00 BF: 2 Banana
12:00 Lunch: Seafood at Hua-Hin
15:00 Tea Break
18:30 Dinner: all-you-can-eat Thai buffet (Big meal)

I didn’t gain much weight from eating spree at La Toscana.

My department had a 3-days seminar at Keree-Waree resort & spa at Prachuap Khiri Khan. Traveling time is 6 hours on bus!. Didn’t bring the scale with us.


14 May 2010, Fri

morning weight: —- no scale —-

09:00 BF: 2 Banana + all-you-can-eat American breakfast (Big meal)
10:30 Tea Break
14:00 Lunch: all-you-can-eat thai buffet (Big meal)
15:00 Tea Break
18:30 Dinner: Seafood BBQ (Big meal)

The last night at Keree-Waree, we had Seafood BBQ. No need to tell, I ate a LOT!.


15 May 2010, Sat

morning weight: —- no scale —-

09:00 BF: all-you-can-eat American breakfast (Big meal)
14:00 Lunch: all-you-can-eat thai buffet
17:00 Snack: lots of snack + ซาลาเปา
20:00 Dinner: ผัดไทย + หมูสะเต๊ะ

Finally, we came back from Keree-Waree. That marked the end of all-you-can-eat. I felt very chubby.


16 May 2010, Sun

morning weight: 82.7 kg

10:00 BF: 2 Bananas + water
14:00 Lunch: Salad (450g)
17:00 Snack: Mark & Spencer biscuit.
18:00 Dinner: ข้าวเนื้อสับ + ลูกชิ้นหมู @ ต้าหว่อ Max Value

Pretty shocked by the weight but it was expected. Bo had seminar on this day. I went to visit my mom and my grandma.


17 May 2010, Mon

morning weight: 82.6 kg

08:30 BF: 2 Bananas + water
14:00 Lunch: Salad (450g)
18:00 Dinner: ครัวกลางกรุง (Big Meal)
19:00 Snack: ขนมหม้อแกง

Red-shirt riot. All government office closed today, including Chula U.

Solution to hw00c

#include <cstdlib>
#include <iostream>
 
using namespace std;
 
int main(int argc, char *argv[])
{
    int N; // num rows
    int M; // num columns
    scanf("%d %d",&N,&M);
    for (int j = 0;j < N;j++) {
        for (int i = 0;i < M;i++) {
            printf("*");
        }
        printf("\n");
    }
    return EXIT_SUCCESS;
}

Solution to hw00a

#include <cstdlib>
#include <iostream>
 
using namespace std;
 
int main(int argc, char *argv[])
{
    printf("Hello, CP!\n");
    return EXIT_SUCCESS;
}

Solution to hw00b

#include <cstdlib>
#include <iostream>
 
using namespace std;
 
int main(int argc, char *argv[])
{
 
    // read input from keyboard and store in n
    int n;             
    scanf("%d",&n);
 
    int curr; // current fibonacci number
    int next; // the next fibonacci number
 
    // compute n-th fibo number
    curr = 0;            
    next = 1;
    for (int i = 0;i < n;i++) {
        int tmp = next + curr;
        curr = next;
        next = tmp;
    }
 
    //display output
    printf("%d\n",curr);
 
    return EXIT_SUCCESS;
}

Algorithm Design, first semester, 2010

News (latest first)

cafe grader is available at http://www.nattee.net/grader
For discussion, please use the main webboard
Email is encouraged, please start your subject by [algo] and include your real name and id as well

  • (25-07-2010) add more slides for Dynamic Programming
  • (21-07-2010) Homework #4, Lecture note #2 is available. (see below)
  • (14-07-2010) Lecture note #1 is available. (see below)
  • (13-07-2010) Homework #3 is extended to monday (19 Jul).
  • (08-07-2010) Homework #3 is available. Due date is 14 Jul.
  • (05-07-2010) Full syllabus is available here
  • (16-06-2010) Homework #1 is available. Nobody opts out of homework system. This marks the end of opt-out period. For section 3, we won’t have a class on 18 Jun and 25 Jun. On 27 Jun, we will have the second quiz.
  • (10-06-2010) Tomorrow we will have first quiz. Please check this file for your seating. Quiz will start exactly at 0900. This is test run, anybody attending the quiz will get full score regardless of their submission.
  • (09-06-2010) Syllabus —short version— can be downloaded
  • (01-06-2010) list of username for grader system is available.
  • (31-05-2010) The first set of h/w is available. This one does not count for final scoring.
  • (31-05-2010) Video and docs for introduction is up!.
  • (18-05-2010) Course syllabus will be available soon.
  • (18-05-2010) The student are required to finish homework 00 before semester begin.

Resource

  • Download course syllabus here.
  • Lab docs of 2009 can be found here
  • Introduction to cafe-grader is here. You can also download dev-c++ and grader introduction video.
  • Our local copy of Bloodshed Dev-C++

C++ Resource

C++ Development platform

  • Dev-C++ is the recommended platform
  • Code::Blocks is also a good alternative

Quizzes

  1. The first quiz (11 Jun) is here. Its solution is also available.
  2. The second quiz (25 Jun) will be available soon.

Assignment

Solution and test data will be available when the submission of the particular problem is closed. Solution marked by [ref] means it is the reference solution. Be noted that there are definitely more than one ways to solve the problem.

Name Issue Date Due Date Solution Test Data
hw00a_helloworld pdf 18 May 2010 7 Jun 2010 ref
hw00b_fibo pdf 18 May 2010 7 Jun 2010 ref
hw00c_drawbox pdf 18 May 2010 7 Jun 2010 ref
hw00d_timeafter pdf 31 May 2010 7 Jun 2010 ref
hw00e_BMI pdf 31 May 2010 7 June 2010 ref
hw00f_aminmax pdf 31 May 2010 7 Jun 2010 ref
hw01a_palindrome pdf 16 Jun 2010 27 Jun 2010
hw01b_drawtri pdf 16 Jun 2010 27 Jun 2010
hw01c_minmax2 pdf 16 Jun 2010 27 Jun 2010
hw02a_drawstar pdf 30 Jun 2010 7 Jul 2010
hw02b_sudoku pdf 30 Jun 2010 7 Jul 2010
hw02c_nodemax pdf 30 Jun 2010 7 Jul 2010
hw03a_pairsum pdf 8 Jul 2010 14 Jul 2010
hw03b_tiling pdf 8 Jul 2010 14 Jul 2010
hw03c_sds pdf 8 Jul 2010 14 Jul 2010
hw04a_lcs pdf 21 Jul 2010 4 Aug 2010
hw04b_barcode pdf 21 Jul 2010 4 Aug 2010
hw04c_denomination pdf 21 Jul 2010 4 Aug 2010

Lecture summary (Section 3)

Lecture note assignment is here. Lecture note should be handed in in the next lecture. If you wish to send via email, please include [algo] in the topic.

  • (09-06-2010) First meeting slide
  • (16-07-2010 — 25-07-2010) Analysis Introduction slide
  • (30-06-2010 — 02-07-2010) Converting program into Big-O slide
  • (07-07-2010 — 14-07-2010) Divide and Conquer slide | lecture note #1 #2
  • (21-07-2010 — 23-07-2010) Dynamic Programming slide slide MCM slide LCS | lecture note #1 #2
Syndicate content