This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
μ°μ λͺκ°μ§ λ°κ²¬ν΄μΌ νλ κ·μΉλ€μ μμ νμ΄μ κ°κ³ 쑰건λ€μ λν΄ λͺ¨λ ν¨ν΄μ λ°μ Έμ£Όμ§ μμλ λλ ꡬνλ κ°λ¨νκ³ κΉλν νμ΄κ° μλ€. | |
λ°λλ‘ λ€μμ λΆν° 보λ κ²μ΄λ€. μ μ λκ° μμμμ§ λͺ¨λ₯΄λ건 ? λΌλ λ³κ°μ λ¬Έμλ₯Ό νλ μ ν΄μ νμλ₯Ό ν΄μ£Όκ³ BB μΌκ²½μ° | |
μλ λκ°λ₯Ό μ€μ λ‘ swapμ ν΄μ£Όλ©° WB λ BW μΌκ²½μ°λ λλ€ μλ λκ°λ₯Ό ??λ‘ λ°κΏμ£Όλ©΄ λλ€. WWμΌλ κ°λ§ν λλ©΄λλ€. | |
κ·Έλ¦¬κ³ λ§μ§λ§μ ?μ κ°μλ§νΌ 2λ₯Ό κ³±ν΄μ£Όλ©΄ λλ€. λ¬Όλ‘ μ€κ°μ λΆκ°λ₯ν κ²½μ°λ₯Ό λ°μ Έμ€μΌνλλ° μ΄κ±΄ WBμΌλμ BWμΌλ μλμ κ°κ° Bλ Wκ° | |
νλλΌλ μμΌλ©΄ λΆκ°λ₯ν κ²½μ°μ΄κ³ κ°κ° Wμ Bλ μμ΄λλκ³ ?λ λλ€ μΈμ λ μ§ μμ΄λ λλ€. | |
*/ | |
#include <bits/stdc++.h> | |
#define REP(i,a,b) for(int i=a;i<=b;++i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://community.topcoder.com/stat?c=problem_statement&pm=11355 | |
μΌλ¨ λͺκ°μ§λ₯Ό μΊμΉν΄μΌνλ€. | |
μ°μ 맨μμ€μ λ³νμ§ μλλ€. | |
κ·Έλ¦¬κ³ νΉμ μ€μ 무쑰건 λ°λ‘ μμ€μ μν΄ μν₯μ λ°λλ€. μλνλ©΄ λ¬Έμ μμ μ£Όμ΄μ§ μ½λλ₯Ό 보면 μμ λ°κΏμ£Όλ μμλ₯Ό μμμλλ° | |
νΉμ μ€μ λ³Όλλ μ΄λ―Έ μμ€μ΄ λ°λ μνμ΄κΈ° λλ¬Έμ μ λ ₯μΌλ‘ μ£Όμ΄μ§λ outputμμμμ λ°λ‘μμ€κ³Ό κ°μμνμμ μν₯μ λ°λκ²μ΄λ€. | |
κ·Έλ¦¬κ³ λμ λκ°μ§λ₯Ό μ λ°μ Έμ€μΌνλ€. | |
첫λ²μ§Έλ Wμ B λλ€ κ°λ₯ν κ³³μ΄ μκΈ°λ μ‘°κ±΄λ€ | |
λλ²μ§Έλ νΉμ μμΉκ° 무쑰건 Wλ Bμ€ νκ°μ§ μ¬μΌνλ μ‘°κ±΄λ€ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://community.topcoder.com/stat?c=problem_statement&pm=11315 | |
λ¨μν 그리λ+ꡬν+μλ£κ΅¬μ‘° λ¬Έμ μ΄λ€. | |
map μ μμ key κ°μΌλ‘ κ°μλ₯Ό μΈμ΄μ€λ€ λκ°μ΄μμ΄ μλ μμ΄μμΌλ©΄ 무쑰건 | |
λ§μ£Όλ³΄λ λ λ©΄μ μ°κ³ λ²λ¦¬λκ² μ΄λμ΄λ€. | |
κ·Έλ¦¬κ³ μλ‘ λ€λ₯Έ μλ€μ μ무λ κ²λ λΆμ¬λ λλ€. | |
*/ | |
#include <bits/stdc++.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://community.topcoder.com/stat?c=problem_statement&pm=11342 | |
μ²μμ μ΄ λ¬Έμ κ° ν΄μμ΄ λ무μλΌμ λ°©μΉν΄ λλ€κ° κ²°κ΅ λ μ‘κ³ μ€μ€λ‘ νμλ€. | |
νλ₯ μ λν μ΄ν΄μ μ¨κ²¨μ§ κ·μΉμ λ°κ²¬μ΄ μꡬλλ λ¬Έμ λΌκ³ μκ°νλ€. | |
μ°μ κ°μ₯ μ€μν κ·μΉμ λ°κ²¬ν΄μΌνλλ° | |
맨 μ²μμ definite decisions λ₯Ό λ°νμΌλ‘ λ€λ₯Έμ¬λμκ² μ νλ μλ₯Ό κ°κ°μ μ¬λλ§λ€ μΈμ΄λ³΄λ©΄ | |
ν λͺ μκ²λ μ νλμ§ μμ μ¬λμ 0, ν λͺ μκ² μ νλ μ¬λμ 1, ... μ΄λ°μμΌλ‘ κ°κ²λλλ° | |
μ νλ νμκ° λͺ¨λ 0 λλ 1μ΄λΌλ©΄ λ€μλ² round μλ λͺ¨λκ° vulerable ν΄μ§λ€. μλνλ©΄ | |
definite decisions μ ν¬ν¨ λμ§μμ λλ¨Έμ§ μ¬λλ€μ λν΄μλ νμ¬ κ°μ₯ μ κ² λ½ν μ¬λλ€μ λλ€νκ² λ½κ²λλλ° |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://community.topcoder.com/stat?c=problem_statement&pm=11063 | |
μ°μ Linearity of expectation μ μμμΌ νλ€. | |
κ·ΈλκΉ κ±΄μ€ν λλ‘λ€μ κΈΈμ΄μ μ΄ ν©μ κΈ°λκ°μ | |
κ°κ°μ λλ‘μ κΈΈμ΄μ κΈ°λκ°λ€μ μ΄ ν©κ³Ό κ°λ€λΌλ κ²μ΄λ€. | |
Editorial μ μλ μμ μΈμ©νμλ©΄ | |
Expected Length of all roads build after picking all villages = | |
Expected Length (Sum of lengths of the roads built when village i is picked, for all i) = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://community.topcoder.com/stat?c=problem_statement&pm=11334 | |
μ²μμ μνλ€μ μ μ μνλ€ κ·Έλνλ₯Ό νμ±ν΄μ λ€μ΅μ€νΈλΌλ₯Ό λ리λ μμΌλ‘ ν μκ° μμ κ±°λΌκ³ μκ°νλλ° | |
μ½μ§μμλ€. μλ§ μ§κΈκΉμ§ κ·Έλ κ² νμλ λ¬Έμ λ€μ λ¬Έμ μμ μ£Όμ΄μ§ κ²½λ‘λλ‘ μ΄λνλ κ²μ΄ μλλΌ | |
μΆλ°μ§μ λμ°©μ§λ§ μ£Όμ΄μ§κ³ μΆλ°μ§μμ λμ°©μ§λ‘ μ΄λνλ κ°μ₯ μ μ λΉμ©μ 묻λ λ¬Έμ μλκ²κ°κ³ | |
μ΄ λ¬Έμ λ κ²½λ‘κ° μ£Όμ΄μ§κ³ λ°λμ κ·Έ κ²½λ‘λλ‘ μ΄λν΄μΌ νλ©΄μ νμ λ μμμ΄ μ‘΄μ¬ν λμ μ΅μ λΉμ©μ ꡬνλ λ¬Έμ μ΄λ€. | |
κ·Έλμ μ΄ λ¬Έμ λ network flow graph λ‘ ν μκ° μκ³ μ΅μ λΉμ©μ μ°ΎμμΌ νκΈ° λλ¬Έμ mcmf λ‘ ν μκ° μλ€. | |
μ°μ νκ°μ§ μ¬μ€μ κΉ¨λ¬μμΌ νλ€. κ²½λ‘κ° μ£Όμ΄μ‘μΌλ kλ²μ§Έ λμκ° μΆλ°μ§μΌλ k+1λ²μ§Έ λμλ λμ°©μ§λΌκ³ λ³Ό μκ°μλ€. | |
κ·Έλ λ€λ©΄ 맨μ²μ 0λ²λμμ μλ€λ κ²μ κ³ λ €νμλ μ λ ₯μΌλ‘ μ£Όμ΄μ§ λμλ€μ λ°°μ΄μ ν¬κΈ°κ° M μ΄λΌλ©΄ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://community.topcoder.com/stat?c=problem_statement&pm=11233 | |
κ·Έλ₯ μ¬κ·ν¨μλ‘ κ΅¬ννλ©΄λλ€ | |
μΈμλ‘λ μνλ°μ μ¬λΆμ μλ°μ μ¬λΆ κ·Έλ¦¬κ³ λ¨μμλ μΌμͺ½λκ³Ό μ€λ₯Έμͺ½λλ§ κ°μ§κ³ μμΌλ©΄λλ€ | |
μλνλ©΄ 곡μ λΉΌλ μ λμΌλ‘λ§ λΉ μ Έλκ°κΈ° λλ¬Έμ κ°μ΄λ°λ κ·Έλλ‘ λ¨μμκ² λκΈ°λλ¬Έμ μ’ νΉμ μ°λ‘ νμΉΈμ©λ§ λ³νκ² λκΈ°λλ¬Έμ΄λ€. | |
μκ° λ³΅μ‘λλ O(N) μ¦ 10λ§λ²μ λ λλ€. | |
*/ | |
#include <bits/stdc++.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://community.topcoder.com/stat?c=problem_statement&pm=11204 | |
νκ²κ³Ό λμ΅μκ²μ νλμ 벑ν°μ λ΄μμ Xκ°μΌλ‘ μ λ ¬νμλ | |
맨μΌμͺ½μ΄ νκ²μ΄κ±°λ 맨μ€λ₯Έμͺ½μ΄ λμ΅μκ²μ΄λ©΄ 무쑰건 λΆκ°λ₯νκ³ | |
λ§μ½ μλλΌλ©΄, νκ°μ§ μ¬μ€μ νμ ν΄μΌνλ€. μλμ λκ°λ₯Ό μ μΈνμλ | |
λͺ¨λ ν λΉ΅μ 맨μΌμͺ½μμλ λμ΅μ λΉ΅κ³Ό λ§€μΉμν¬μμκ³ | |
λͺ¨λ λμ΅μ λΉ΅μ 맨 μ€λ₯Έμͺ½μ μλ ν λΉ΅κ³Ό λ§€μΉ μν¬μκ°μμΌλ―λ‘ λ΅μ 2λ³΄λ€ μ»€μ§μκ°μλ€. κ·Έλ°λ° λ± ν κ²½μ°μ λ΅μ΄ 1μ΄ λλ€. | |
λ°λ‘ λͺ¨λ λμ΅μλΉ΅μ΄ λͺ¨λ νλΉ΅λ³΄λ€ μΌμͺ½μ μμ λ μ΄λ€. |
NewerOlder