A start job is running for raise network interfaces (5 mins)

by Soo-Hyun Choi on 4/02/2017

I have encountered a problem with a Wifi-only Ubuntu machine to be waited as long as 5 minutes when booting. The error message show that “A start job is running for raise network interface”. This is burdensome.

Before jumping into fix the issue, there is a full documentation on this at – https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/

I did simple Google and found a useful answer on Ubuntu forum

  – https://ubuntuforums.org/showthread.php?t=2323253&p=13484073#post13484073

  – https://ubuntuforums.org/showthread.php?t=2323253&p=13488422#post13488422


What I did is to modify 

$ sudo vi /etc/systemd/system/network-online.targets.wants/networking.service 

and changed like – 



It all worked great!

No Comments

How To Open Iomega MiniMax External HDD

by Soo-Hyun Choi on 27/12/2016

I’ve got an external HDD that works with Mac Mini – Iomega MiniMax (1TB). I’ve got this HDD from eBay about two months ago, but died a few days ago where I’ve collected fair amount of music files.

Okay, it’s time to replace the HDD in it. Here is the instruction as to how you can dismantle the external HDD – https://www.ifixit.com/Guide/Iomega+MiniMax+Disassembly/56773 

It was fairly simple, and I am going to buy a 3TB HDD at an open market!  ๐Ÿ˜‰

No Comments

[ubuntu] Consolas Font Install

by Soo-Hyun Choi on 3/12/2016

1 Install package

2 Make and execute consolas.sh

  • Make consolas.sh

  • Content of consolas.sh

  • Execute script

3 Install consolas font

  • Execute font-manger and install fonts in temp dir

  • Install font
    • Click Install Fonts and select font files.


4 Remove temp dir and scirpt

5 External Link

No Comments

[ubuntu] Set a Real Time Photo of Earth

by Soo-Hyun Choi on 3/12/2016

โ€˜Himawaripyโ€˜ is a small Python 3 script that fetches a near-real time picture of Earth taken by the Japanese Himawari 8 weather satellite and sets it as your desktop background.

Once installed you can set the app to run as a cron job every 10 minutes (in the background, naturally) so that it can fetch and set a realtime picture of Earth as your desktop wallpaper.

Because Himawari-8 is a geostationary satellite youโ€™re only ever going to images of the earth as seen from above Australasia โ€” but with real time weather patterns, cloud formations and lighting itโ€™s still makes for spectacular scene, even if seeing things above the UK would be better for me!

Advanced settings allow you to configure the quality of the images pulled from the satellite , but keep in mind that any increase in quality will result in an increased file size, and a longer download wait!

Lastly, while this script is very similar to many others that weโ€™ve covered over the years it is up-to-date and working.

Get Himawaripy

Himawaripy has been tested on a range of desktop environments, including Unity, LXDE, i3, MATE and a host of other desktop environments. It is free, open-source software but is not entirely straightforward to set up and configure.

Find all instructions on getting the app installed and set up (hint: thereโ€™s no one-click installer) on the projectโ€™s GitHub page.

Real time earth wallpaper script on GitHub

Install & Use


A few readers asked me to update this post with a line-by-line guide to using the app. All the steps are on the main Github page, but here they are anyway.

1. Download & Extract Himawaripy

Well this is the easiest step. Hit the download button below to grab the latest build of the script, and then extract it to your Downloads folder.

Download Himawaripy Master (.zip)

2. Install python3-setuptools

Youโ€™ll need to install this package manually as it does not come pre-installed on Ubuntu:

3. Install Himawaripy

In the Terminal app you need to โ€˜cdโ€™ into the folder you extracted earlier and run the following install command:

4. Check itโ€™s running and download the latest real-time image by running:

5. Set up a cron job

This step is needed if you wish for the script to run and update automatically in the background (if youโ€™d rather you can update it manually by running โ€˜himarwaripyโ€™ at any time)

In the terminal run:

Add the following new line (default is every 10 minutes)

The Ubuntu Wiki has detailed information on configuring cron.

You wonโ€™t need to keep running once youโ€™ve checked that the app has installed. It will run automatically, every 10-minutes or so in the background.

(source) http://www.omgubuntu.co.uk/2016/07/set-real-time-earth-wallpaper-ubuntu-desktop

No Comments

[์ •์˜ฌ] ๋™์ „๊ตํ™˜

by Soo-Hyun Choi on 29/11/2016

๋ฌธ์ œ) http://www.jungol.co.kr/bbs/board.php?bo_table=pbank&wr_id=1273&sca=3050


ํ’€์ด) ๋™์ „๊ตํ™˜.c


No Comments

why you have to hands on coding all the times

by Soo-Hyun Choi on 28/11/2016

because people will not trust architect without hands on
– http://itsadeliverything.com/i-only-trust-architects-that-code


No Comments

Least Recently Used (LRU) Cache

by Soo-Hyun Choi on 26/11/2016

Your task for this problem is to take a sequence of data accesses and simulate an LRU cache. When requested, you will output the contents of the cache, ordered from least recently used to most recently used.

Input:  The input will be a series of data sets, one per line. Each data set will consist of an integer N and a string of two or more characters. The integer N represents the size of the cache for the data set (1 โ‰ค N โ‰ค 26). The string of characters consists solely of uppercase letters and exclamation marks. An upppercase letter represents an access to that particular piece of data. An exclamation mark represents a request to print the current contents of the cache.

For example, the sequence ABC!DEAF!B! means to acces A, B, and C (in that order), print the contents of the cache, access D, E, A, and F (in that order), then print the contents of the cache, then access B, and again print the contents of the cache.

The sequence will always begin with an uppercase letter and contain at least one exclamation mark.

The end of input will be signaled by a line containing only the number zero.

Output:  For each data set you should output the line “Simulation S“, where S is 1 for the first data set, 2 for the second data set, etc. Then for each exclamation mark in the data set you should output the contents of the cache on one line as a sequence of characters representing the pieces of data currently in the cache. The characters should be sorted in order from least recently used to most recently used, with least recently occuring first. You only output the letters that are in the cache; if the cache is not full, then you simply will have fewer characters to output (that is, do not print any empty spaces). Note that because the sequence always begins with an uppercase letter, you will never be asked to output a completely empty cache.

Example input: Example output:
Simulation 1
Simulation 2
Simulation 3


source) http://mcicpc.cs.atu.edu/archives/2012/mcpc2012/lru/lru.html

์ฐธ๊ณ ) http://www.geeksforgeeks.org/implement-lru-cache/




No Comments

๊ด„ํ˜ธ ๋ฌถ์Œ ์ ๊ฒ€ํ•˜๊ธฐ

by Soo-Hyun Choi on 26/11/2016

input string ์œผ๋กœ ๊ด„ํ˜ธ ๋ฌถ์Œ์ด ํฌํ•จ๋œ ๋ฌธ์ž์—ด์ด ์ฃผ์–ด์กŒ์„๋•Œ, ๊ด„ํ˜ธ์˜ ์ง์ด ๋งž์œผ๋ฉด 1, ํ‹€๋ฆฌ๋ฉด 0๋ฅผ return ํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ ์ž‘์„ฑํ•˜๊ธฐ.

์˜ˆ1) “{}{()}[] ” ๋กœ ์ฃผ์–ด์ง€๋ฉด 1 ๋ฆฌํ„ด

์˜ˆ2) “{(})” ๋กœ ์ฃผ์–ด์ง€๋ฉด 0 ๋ฆฌํ„ด -> ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ๋˜๋ ค๋ฉด {()} ์ด๋Ÿฐ์‹์ด ๋˜์–ด์•ผ ํ•จ

์˜ˆ3) “(h[e{lo}!]~()()())” ๋กœ ์ฃผ์–ด์ง€๋ฉด 1 ๋ฆฌํ„ด -> ๋ชจ๋“  ๊ด„ํ˜ธ์Œ์ด ์ž˜ ๋ฌถ์—ฌ์žˆ์Œ



ํ’€์ด) ๊ด„ํ˜ธ ๋ฌถ์Œ ์ ๊ฒ€ํ•˜๊ธฐ.c

์ฐธ๊ณ ) http://www.geeksforgeeks.org/check-for-balanced-parentheses-in-an-expression/


Read the rest of this article »

No Comments

์žฌ๋ฏธ์žˆ๋Š” ์—ฐ์‚ฐ๋†€์ด

by Soo-Hyun Choi on 19/11/2016

์ฃผ๋จธ๋‹ˆ์— 1๋ถ€ํ„ฐ 9๊นŒ์ง€์˜ ์ˆซ์ž๊ฐ€ ์ƒˆ๊ฒจ์ง„ ๊ณต์ด ์žˆ๊ณ , ๋ง์…ˆ/๋บ„์…ˆ/๊ณฑ์…ˆ/๋‚˜๋ˆ—์…ˆ์„ ๋‚˜ํƒ€๋‚ด๋Š” ์—ฐ์‚ฐ์ž ๊ณต์ด 4๊ฐœ๊ฐ€ ๋“ค์–ด์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜์ž (์ด 13๊ฐœ์˜ ๊ณต). ์ฃผ๋จธ๋‹ˆ์—์„œ N๊ฐœ์˜ ๊ณต์„ ์„ ํƒํ•œ ํ›„ ์ผ๋ ฌ๋กœ ๋ฐฐ์น˜ํ•œ๋‹ค๊ณ  ๊ฐ€์ •ํ–ˆ์„๋•Œ, ๊ณ„์‚ฐ์น˜์˜ ์ตœ๋Œ€๊ฐ€ ๋˜๋Š” ๊ฐ’์„ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜๋ผ.


(์ œ์•ฝ์‚ฌํ•ญ)

  • N์€ 2๋ณด๋‹ค ํฌ๊ณ  9๋ณด๋‹ค ์ž‘๋‹ค.
  • ์—ฐ์‚ฐ์ž๊ฐ€ ๋งˆํ‚น๋œ ๊ณต์€ ์ตœ๋Œ€ 2๊ฐœ๊นŒ์ง€๋งŒ ์„ ํƒ ๊ฐ€๋Šฅํ•˜๋‹ค.
  • ์—ฐ์‚ฐ์ž ๊ณต์ด ํ•˜๋‚˜๋„ ์—†์„ ์ˆ˜๋„ ์žˆ๋‹ค.
  • ์—ฐ์‚ฐ์ž ๊ณต์ด ์ œ์ผ ์ฒ˜์Œ, ํ˜น์€ ์ œ์ผ ๋’ค์— ์˜ฌ์ˆ˜ ์—†๋‹ค (์ด ๊ฒฝ์šฐ ๋ฌดํšจ).
  • ์—ฐ์‚ฐ์ž ๊ณต์€ ์—ฐ์†ํ•ด์„œ 2๊ฐœ๊ฐ€ ๊ฐ™์ด ์˜ฌ์ˆ˜ ์—†๋‹ค (์ด ๊ฒฝ์šฐ ๋ฌดํšจ).
  • ์—ฐ์‚ฐ์ž์˜ ์šฐ์„ ์ˆœ์œ„๊ฐ€ ์žˆ๋‹ค (๋ง์…ˆ, ๋บ„์…ˆ: ์šฐ์„ ์ˆœ์œ„ 1 // ๊ณฑ์…ˆ, ๋‚˜๋ˆ—์…ˆ: ์šฐ์„ ์ˆœ์œ„ 2)


(์ž…๋ ฅ)

  • ์ฒซ row์— N ์ด ์ฃผ์–ด์ง€๊ณ ,  ๋‹ค์Œ row์—๋Š” N๊ฐœ ๊ฐ’์ด ์ฃผ์–ด์ง„๋‹ค.
  • ๋ง์…ˆ์€ -1, ๋บ„์…ˆ์€ -2, ๊ณฑ์…ˆ์€ -3, ๋‚˜๋ˆ—์…ˆ์€ -4๋กœ ์ฃผ์–ด์ง„๋‹ค.

(์ถœ๋ ฅ)

  • ๊ณ„์‚ฐ์น˜์˜ ์ตœ๋Œ€๊ฐ’



(ํ’€์ด๊ณผ์ •)

ํ’€์ด์ค‘) ์žฌ๋ฏธ์žˆ๋Š” ์—ฐ์‚ฐ๋†€์ด.c


No Comments

[BOJ] JOI ๊นƒ๋ฐœ

by Soo-Hyun Choi on 7/11/2016

๋ฌธ์ œ) https://www.acmicpc.net/problem/5559

์ด ๋ฌธ์ œ๋Š” ์ค‘๋ณต์ˆœ์—ด ๋ฌธ์ œ๋กœ ๋ณด์ธ๋‹ค. ์ฆ‰, n ๊ฐœ์˜ ‘?’ ์œ„์น˜์— J/O/I ๋ฅผ ์ค‘๋ณต์œผ๋กœ ์„ ํƒํ•ด์„œ ๋ฐฐ์—ดํ•˜๋Š” ์™„์ „ํƒ์ƒ‰์„ ํ•œ ๋‹ค์Œ, ์ข‹์€ flag ์กฐ๊ฑด์ธ์ง€ ์•„๋‹Œ์ง€ ๊ฒ€์ƒ‰์„ ํ•ด๋ณด์ž.


ํ’€์ด์ค‘) https://github.com/soohyunc/algostudy/blob/master/5559.c

No Comments

์—ฐ๋ชป์— ๋Œ ๋˜์ง€๊ธฐ

by Soo-Hyun Choi on 6/11/2016

XxY ํฌ๊ธฐ์˜ ์—ฐ๋ชป์ด ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜์ž. ์—ฌ๊ธฐ์— N ๊ฐœ์˜ E ๋ฌด๊ฒŒ์˜ ์—ฐ๊ฝƒ์ด (x, y) ์œ„์น˜์— ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ• ๋•Œ, ๋ฌด๊ฒŒ๊ฐ€ P์ธ M ๊ฐœ์˜ ๋Œ์„ ๋˜์ ธ์„œ ์—ฐ๊ฝƒ์„ ๊ฐ€์žฅ ๋งŽ์ด ๊ฐ€๋ผ์•Šํ˜”์„๋•Œ, ๋‚จ์•„ ์žˆ๋Š” ์—ฐ๊ฝƒ์˜ ๊ฐฏ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•˜๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•ด๋ณด์ž. ๋‹จ. ๋Œ์„ ์—ฐ๋ชป์— ๋˜์กŒ์„๋•Œ R ๊ฑฐ๋ฆฌ ๋งŒํผ์˜ ์œ„๋ ฅ์ด ์žˆ์œผ๋ฏ€๋กœ, ๊ฑฐ๋ฆฌ ์•ˆ์— ์žˆ๋Š” ๋ชจ๋“  ์—ฐ๊ฝƒ์— ๋™์ผํ•œ ํ”ผํ•ด๋ฅผ ์ค„ ์ˆ˜ ์žˆ๋‹ค.

  • ๊ฑฐ๋ฆฌ (d) = |Xa – Xb| + |Ya – Yb|

์˜ˆ๋ฅผ๋“ค์–ด, (100, 100) ์œ„์น˜์— ๋ฌด๊ฒŒ 40 ์งœ๋ฆฌ์˜ ์—ฐ๊ฝƒ์ด ์œ„์น˜ ํ•ด ์žˆ์„๋•Œ, ๋ฌด๊ฒŒ 40 ์งœ๋ฆฌ์˜ ๋Œ์„ ๋˜์ง€๋ฉด, ํ•ด๋‹น ์—ฐ๊ฝƒ์˜ ๋ฌด๊ฒŒ๊ฐ€ 0์ด ๋˜์–ด ๊ฐ€๋ผ ์•‰๋Š”๊ฑธ๋กœ ๊ฐ€์ •ํ•œ๋‹ค. ๋˜ํ•œ, ๋Œ์˜ ๊ฑฐ๋ฆฌ ํŒŒ์žฅ๋ ฅ (R) ์•ˆ์— ์žˆ๋Š” ๋˜ ๋‹ค๋ฅธ ์—ฐ๊ฝƒ์ด ์žˆ๋‹ค๋ฉด, ์ด ์—ฐ๊ฝƒ์˜ ๋ฌด๊ฒŒ๊ฐ€ P ๋งŒํผ ๊ฐ์†Œํ•˜๊ฒŒ ๋œ๋‹ค. 

์ฆ‰, (100, 100) ์œ„์น˜์— ๋ฌด๊ฒŒ 40์งœ๋ฆฌ์˜ ์—ฐ๊ฝƒ ํ•˜๋‚˜. ๊ทธ๋ฆฌ๊ณ  (100, 200) ์œ„์น˜์— ๋ฌด๊ฒŒ 50์งœ๋ฆฌ์˜ ์—ฐ๊ฝƒ ํ•˜๋‚˜, ์ด 2๊ฐœ์˜ ์—ฐ๊ฝƒ์ด ์žˆ๊ณ , ๋ฌด๊ฒŒ 40์งœ๋ฆฌ, ๊ทธ๋ฆฌ๊ณ  ๊ฑฐ๋ฆฌ ํŒŒ์žฅ๋ ฅ 100 ์ธ ๋Œ ํ•˜๋‚˜๋ฅผ (100, 100) ์œ„์น˜์— ๋˜์ง€๊ฒŒ ๋˜๋ฉด, ์ฒซ๋ฒˆ์งธ ์—ฐ๊ฝƒ์˜ ๋ฌด๊ฒŒ๋Š” 0์ด ๋˜์–ด ๊ฐ€๋ผ ์•‰๊ณ , ๋‘๋ฒˆ์จฐ ์—ฐ๊ฝƒ์€ ๊ฑฐ๋ฆฌ ํŒŒ์žฅ๋ ฅ ์•ˆ์— ๋“ค์–ด์˜ค๊ฒŒ ๋˜๋ฏ€๋กœ 50 – 40 = 10, ์ฆ‰ ๋ฌด๊ฒŒ 10์งœ๋ฆฌ์˜ ์—ฐ๊ฝƒ์ด ๋œ๋‹ค.

๋˜ํ•œ, ๋ฌด๊ฒŒ๊ฐ€ 0์ด ๋˜์–ด ๊ฐ€๋ผ์•‰์€ ์—ฐ๊ฝƒ ์œ„์น˜์— ๋Œ์„ ๋˜์ง€๊ฒŒ ๋˜๋ฉด ์ „ํ˜€ ์˜ํ–ฅ๋ ฅ์„ ๋ฏธ์น  ์ˆ˜ ์—†๊ฒŒ ๋œ๋‹ค (์ฆ‰, ๋Œ์„ ๋˜์ง€์ง€ ์•Š์€ ๊ฒƒ๊ณผ ๊ฐ™์€ ํšจ๊ณผ).


์ž…๋ ฅ ์ฒซ์งธ์ค„์—๋Š” ์ด ์—ฐ๊ฝƒ์˜ ๊ฐฏ์ˆ˜๊ฐ€ ์ฃผ์–ด์ง€๊ณ , ๊ทธ ๋‹ค์Œ์œผ๋กœ ์—ฐ๊ฝƒ์˜ ์ขŒํ‘œ ๋ฐ ๋ฌด๊ฒŒ ๊ฐ€ ์ฐจ๋ก€๋กœ ์ฃผ์–ด์ง„๋‹ค. ๊ทธ๋ฆฌ๊ณ , ์ œ์ผ ๋งˆ์ง€๋ง‰์—๋Š” ๋Œ์˜ ๊ฐฏ์ˆ˜ ๋ฐ ๋ฌด๊ฒŒ, ํŒŒ์žฅ๋ ฅ์ด ์ž…๋ ฅ์œผ๋กœ ์ฃผ์–ด์ง„๋‹ค.


์ž…๋ ฅ ์ œ์•ฝ์‚ฌํ•ญ)

  • X, Y ์˜ ์ตœ๋Œ€๊ฐ’์€ 1000 ์ด๋‹ค
  • ์—ฐ๊ฝƒ์˜ ๊ฐฏ์ˆ˜ N์€ 1๋ณด๋‹ค ํฌ๊ณ  16๋ณด๋‹ค ์ž‘๋‹ค
  • ์—ฐ๊ฝƒ์˜ ๋ฌด๊ฒŒ E๋Š” 10๋ณด๋‹ค ํฌ๊ณ  500๋ณด๋‹ค ์ž‘๋‹ค
  • ๋Œ์˜ ๊ฐฏ์ˆ˜ M ์€ 1๋ณด๋‹ค ํฌ๊ณ  4๋ณด๋‹ค ์ž‘๋‹ค
  • ๋Œ์˜ ๋ฌด๊ฒŒ P๋Š” 30๋ณด๋‹ค ํฌ๊ณ  100 ๋ณด๋‹ค ์ž‘๋‹ค
  • ๊ฑฐ๋ฆฌ ํŒŒ์žฅ๋ ฅ R์€ 100๋ณด๋‹ค ํฌ๊ณ  600 ๋ณด๋‹ค ์ž‘๋‹ค



ํ’€์ด ๊ณผ์ •

์ฒซ๋ฒˆ์งธ ํ•จ์ •) ์ด ๋ฌธ์ œ๋Š” ์ค‘๋ณต์ˆœ์—ด๋กœ ํ’€์–ด์•ผ ํ•  ๊ฒƒ ๊ฐ™๋‹ค. ์ฒ˜์Œ ๋ฌธ์ œ๋ฅผ ์ฝ์—ˆ์„๋•Œ๋Š” P(N, M), ์ฆ‰, N ๊ฐœ์ค‘ M๊ฐœ๋ฅผ ๊ณ ๋ฅด๋Š” ์ˆœ์—ด ๋ฌธ์ œ๋กœ ๋ณด์•˜์œผ๋‚˜, ๋งž์ถ”์—ˆ๋˜ ๊ฝƒ์— ๋Œ์„ ํ•œ๋ฒˆ ๋” ๋˜์งˆ์ˆ˜๋„ ์žˆ๊ฒ ์œผ๋ฏ€๋กœ PI(N, M) ์ด ๋œ๋‹ค.

๋‘๋ฒˆ์งธ ํ•จ์ •) ๋Œ์„ ๋งž์•„ ๋ฌด๊ฒŒ๊ฐ€ 0๋ณด๋‹ค ์ž‘์•„์ง„ ๊ฒฝ์šฐ, ๊ฝƒ์ด ๊ฐ€๋ผ ์•‰์•˜๊ณ  ๋”ฐ๋ผ์„œ ๊ฑฐ๊ธฐ์— ๋Œ์„ ๋˜์ ธ๋ดค์ž ํŒŒ์žฅ๋ ฅ ํšจ๊ณผ๊ฐ€ ๋‚˜ํƒ€๋‚˜์ง€ ์•Š์œผ๋ฏ€๋กœ, ๋ฌด๊ฒŒ๊ฐ€ 0๋ณด๋‹ค ์ž‘์•„์ง„, ์ฆ‰ ๊ฐ€๋ผ์•‰์€ ๊ฝƒ์— ๋Œ์„ ๋˜์กŒ์„๋•Œ๋Š” skip ํ•ด์ฃผ๋Š” ์˜ˆ์™ธ์ฒ˜๋ฆฌ๊ฐ€ ํ•„์š”ํ•˜๋‹ค.


ํ’€์ด) ์—ฐ๋ชป์— ๋Œ ๋˜์ง€๊ธฐ.c


No Comments

[BOJ] ๋‹จ์ง€๋ฒˆํ˜ธ๋ถ™์ด๊ธฐ

by Soo-Hyun Choi on 5/11/2016

๋ฌธ์ œ) https://www.acmicpc.net/problem/2667

์ „ํ˜•์ ์ธ DFS ๋ฌธ์ œ์ด๋‹ค. ์•„๋ž˜ ๋ณ„์ด ๋น›๋‚˜๋Š” ๋ฐค์— ๋ฌธ์ œ์™€ ๊ฑฐ์˜ ์œ ์‚ฌ.


์†Œ์Šค) https://github.com/soohyunc/algostudy/blob/master/2667.c

No Comments

maze (์ตœ๋‹จ ๊ฑฐ๋ฆฌ ์ฐพ๊ธฐ)

by Soo-Hyun Choi on 4/11/2016
ํ”„๋กœ๊ทธ๋žจ ๋ช…: maze
์ œํ•œ์‹œ๊ฐ„: 1 ์ดˆ

๋„์ ๋“ค๋กœ๋ถ€ํ„ฐ ๊ฐ’์ง„ ๋ณด๋ฌผ์„ ํ›”์ณ ๋‹ฌ์•„๋‚˜๋˜ ์•Œ๋ฆฌ๋ฐ”๋ฐ”๋Š” ํ•œ ๋„์‹œ์— ์ด๋ฅด๋ €๋‹ค. ๊ทธ ๋„์‹œ๋Š” ์ „์ฒด๊ฐ€ ๋งˆ์น˜ ๋ฏธ๋กœ์ฒ˜๋Ÿผ ๋˜์–ด ์žˆ๋Š” ๋„์‹œ์˜€๋Š”๋ฐ ๊ทธ ๋„์‹œ ํ•œ ์ชฝ ๋์—๋Š” ๋ฏธ๋ฆฌ ์ค€๋น„ํ•ด ๋†“์€ ๋ฐฐ๊ฐ€ ์žˆ์–ด,๋„์‹œ ๋๊นŒ์ง€๋งŒ ๋‹ค๋‹ค๋ฅด๋ฉด ๋„์ ๋“ค์„ ๋”ฐ๋Œ๋ฆด ์ˆ˜ ์žˆ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ๋„์ ๋“ค์€ ์ด ๋„์‹œ์— ๋Œ€ํ•˜์—ฌ ์ž˜์•„๊ณ  ์žˆ๊ธฐ ๋•Œ๋ฌธ์— ๋„์ ๋“ค๋ณด๋‹ค ๋จผ์ € ์ถœ๊ตฌ์— ๋‹ค๋‹ค๋ฅด๊ธฐ ์œ„ํ•ด์„œ๋Š”๋ฐ˜๋“œ์‹œ ์ตœ๋‹จ๊ฑฐ๋ฆฌ๋ฅผ ๊ฐ–๋Š” ๊ธธ๋กœ ๊ฐ€์•ผ๋งŒ ํ•œ๋‹ค.

๋„์‹œ์˜ ์ง€๋„๊ฐ€ ์ฃผ์–ด์งˆ ๋•Œ ์ตœ๋‹จ ๊ฑฐ๋ฆฌ์˜ ๊ธธ์„ ์ฐพ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ์ž‘์„ฑํ•˜์‹œ์˜ค. ์˜ˆ๋ฅผ๋“ค์–ด ๋„์‹œ์˜๋ชจ์–‘์ด ์œ„์™€ ๊ฐ™์„ ๊ฒฝ์šฐ ์ž…๊ตฌ์—์„œ ์˜ค๋ฅธ์ชฝ์œผ๋กœ ๊ฐˆ ๊ฒฝ์šฐ ์ด 9 ๊ฐœ์˜ ๋ธ”๋ก(ํ•˜์–€ ๋ธ”๋ก์˜ ๊ฐœ์ˆ˜)๋ฅผ ์ง€๋‚˜ ์ถœ๊ตฌ์— ๋‹ค๋‹ค๋ฅผ ์ˆ˜ ์žˆ๋‹ค.

์ž…๋ ฅ ํ˜•์‹

์ฒซ์งธ ์ค„์— ๋ฏธ๋กœ์˜ ์„ธ๋กœ์˜ ํฌ๊ธฐ์™€ ๊ฐ€๋กœ์˜ ํฌ๊ธฐ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ์ž์—ฐ์ˆ˜ N ๊ณผ M ์ด ์ด ์ฃผ์–ด์ง€๊ณ  ๋‹ค์Œ N ์ค„์—๋Š” ๋ฏธ๋กœ์˜ ์ƒํƒœ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” M ๊ฐœ์˜ ์ •์ˆ˜๊ฐ€ ์ฃผ์–ด์ง„๋‹ค. ๊ธธ์€ 0 ์œผ๋กœ ๋ง‰ํžŒ ๊ณณ์€ 1 ๋กœ ํ‘œ์‹œ๋˜๋ฉฐ ๋ชจ๋“  ์ •๋ณด๋Š” ๋นˆ ์นธ ์—†์ด ๋ถ™์–ด ์žˆ๋‹ค. ์ž…๊ตฌ๋Š” ํ•ญ์ƒ ์™ผ์ชฝ ์ œ์ผ ์•„๋ž˜ ์ด๊ณ , ์ถœ๊ตฌ๋Š” ํ•ญ์ƒ ์˜ค๋ฅธ์ชฝ ์ œ์ผ ์œ„์ด๋‹ค. N ๊ณผ M ์€ 20 ์ดํ•˜์˜ ์ž์—ฐ์ˆ˜์ด๋‹ค.

์ถœ๋ ฅ ํ˜•์‹

์ฒซ ์ค„์— ์ตœ๋‹จ ๊ฑฐ๋ฆฌ์˜ ๊ธธ๋กœ ๊ฐˆ ๊ฒฝ์šฐ ๊ฑฐ์ณ์•ผ ํ•˜๋Š” ๋ธ”๋ก์˜ ๊ฐœ์ˆ˜๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค. ๋งŒ์•ฝ ์ถœ๊ตฌ์— ์ด๋ฅด๋Š” ๊ธธ์ด ์—†๋‹ค๋ฉด -1 ์„ ์ถœ๋ ฅํ•œ๋‹ค.

์ž…์ถœ๋ ฅ ์˜ˆ



No Comments

[BOJ] ๋ฏธ์นœ๋กœ๋ด‡

by Soo-Hyun Choi on 4/11/2016


์ด ๋ฌธ์ œ๋Š” ์ „ํ˜•์ ์ธ DFS ๋ฌธ์ œ์ด๋‹ค. ๊ฐ ๊ฒฝ๋กœ์—์„œ ๊ฐˆ์ˆ˜ ์žˆ๋Š” ๋ฐฉํ–ฅ์„ ์งš์–ด๋ณด๋ฉด์„œ ๋‹จ์ˆœํ•œ ๊ฒฝ๋กœ๊ฐ€ ์•„๋‹๊ฒฝ์šฐ ๋Œ์•„์˜ค๋Š” ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ˜„ ํ•˜๋ฉด ๋œ๋‹ค. ๊ฐ ์ง€์ ์—์„œ ๋„ค ๋ฐฉํ–ฅ์œผ๋กœ ๋ชจ๋‘ DFS ๋ฐฉ๋ฌธํ•ด๋ณด๊ณ  ํ•ด๋‹น ๋ฐฉํ–ฅ์œผ๋กœ ์ด๋™ํ–ˆ์„๋•Œ ๊ฒฝ๋กœ๊ฐ€ ๋‹จ์ˆœํ•  ํ™•๋ฅ ์„ ๊ตฌํ•œ ํ›„, ๊ฐ๊ฐ์— ๊ทธ ๋ฐฉํ–ฅ์œผ๋กœ ์ด๋™ํ•  ํ™•๋ฅ ์„ ๊ณฑํ•ด์„œ ๋ฆฌํ„ดํ•˜๋Š” ๋ฐฉ์‹. 

Read the rest of this article »

No Comments

์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œ ํ’€์ด : ์ž์ฃผ ์“ฐ์ด๋Š” ์ฝ”๋“œ

by Soo-Hyun Choi on 4/11/2016

* ์ดˆ๋ณด์ž๋ฅผ ์œ„ํ•œ ์ถ”์ฒœ ์ฝ์„๊บผ๋ฆฌ ๊ฐ•์˜ ์ž๋ฃŒ์—์„œ ๋ชจ์Œ

1) ์ž…๋ ฅ์„ ๊ทธ๋Œ€๋กœ ์ถœ๋ ฅ

2) 1 ๋ถ€ํ„ฐ n ๊นŒ์ง€ ํ•ฉ

3) ๊ฐ„ํŽธํ•œ ์ตœ๋Œ€ ๊ณต์•ฝ์ˆ˜ ๊ตฌํ•˜๊ธฐ

4) char ๋ณ€์ˆ˜ ์—ฐ์‚ฐ

4-1) char <-> int ๋ณ€ํ™˜


4-2) ๋Œ€์†Œ๋ฌธ์ž ๋ณ€ํ™˜

5) int ์˜ ์ตœ๋Œ€๊ฐ’๊ณผ ํฐ ๊ฐ’์œผ๋กœ ์ดˆ๊ธฐํ™” ํ•„์š”์‹œ

6) ๋ฌธ์ž์—ด ์„ธ๊ธฐ

7) ์ˆซ์ž ํ•˜๋‚˜์”ฉ ๊บผ๋‚ด์“ฐ๊ธฐ

9) ์Šคํƒ

10) ํ

11) ๋ฐ˜์˜ฌ๋ฆผ
๋ฐ˜์˜ฌ๋ฆผ์— ๋Œ€ํ•ด์„œ ๋”ฐ๋กœ ์ฒ˜๋ฆฌํ•  ํ•„์š”๊ฐ€ ์—†๋‹ค
.2f ๋Š” ์†Œ์ˆ˜์  ์…‹์งธ ์ž๋ฆฌ์—์„œ ๋ฐ˜์˜ฌ๋ฆผํ•œํ›„ ์†Œ์ˆ˜์  ๋‘˜์งธ ์ž๋ฆฌ๊นŒ์ง€ ์ถœ๋ ฅํ•˜๋ผ๋Š” ์˜๋ฏธ

12) ๋ฑ (deq)


1) ์ด๋ถ„ ํƒ์ƒ‰

2) ํ–‰๋ ฌ์„ ์ด์šฉํ•œ ๊ทธ๋ž˜ํ”„ ํ‘œํ˜„

3) ํ–‰๋ ฌ์„ ์ด์šฉํ•œ ๊ทธ๋ž˜ํ”„ ํ‘œํ˜„(๊ฐ€์ค‘์น˜)

4) DFS – ์ธ์ ‘ํ–‰๋ ฌ

5) DFS

6) BFS – ์ธ์ ‘ํ–‰๋ ฌ

7) BFS – ๊ฒฉ์ž

8) BFS – ๋‚˜์ดํŠธ



2) MAX

3) MIN

4) ABS

5) Log ์ถœ๋ ฅ

6) ์ˆ˜ํ–‰์‹œ๊ฐ„ ์ธก์ •

7) ๋‚˜๋จธ์ง€ ์—ฐ์‚ฐ

8) BigInteger for C++
C์—์„œ BigInteger ์‚ฌ์šฉ์— ๊ด€ํ•œ ๋ฐฑ์ค€๋‹˜์˜ ์ถ”์ฒœ๋งํฌ
=> http://stackoverflow.com/questions/4507121/c-big-integer
=> http://codeforces.com/blog/entry/16380

9) quick sort

10) merge sort


No Comments