├── .gitignore ├── 2013 ACM-ICPC World Finals ├── A.cpp ├── C.cpp ├── D.cpp ├── F.cpp ├── H.cpp └── J.cpp ├── 2014-2015 Petrozavodsk Winter Training Camp, Contest.58 (Makoto rng_58 Soejima contest) ├── A.cpp ├── B.cpp └── C.cpp ├── 2014-2015 Summer Petrozavodsk Camp, Petr Mitrichev Contest 12 ├── C.cpp ├── D.cpp ├── E.cpp ├── G.cpp └── I.cpp ├── 2015-2016 Petrozavodsk Winter Training Camp, Makoto rng_58 Soejima Сontest 4 ├── A.cpp ├── B.cpp ├── C.cpp ├── E.cpp ├── F.cpp ├── H.cpp ├── I.cpp ├── J.cpp └── L.cpp ├── 2015-2016 Petrozavodsk Winter Training Camp, SPb SU + SPb AU Contest ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp ├── L ├── L.cpp └── statements.pdf ├── 2016 ACM-ICPC World Finals ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── I.cpp ├── K.cpp ├── L.cpp └── statements.pdf ├── 2017-2018 ACM-ICPC Asia East Continent League Final (ECL-Final 2017) ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── J.cpp ├── K.cpp ├── L.cpp └── M.cpp ├── 2017-2018 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2017) ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── G.cpp ├── I.cpp ├── J.cpp └── K.cpp ├── 2017-2018 ACM-ICPC Northern Eurasia (Northeastern European Regional) Contest (NEERC 17) ├── B.cpp ├── C.cpp ├── D.cpp └── E.cpp ├── 2017-2018 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2017) ├── A.cpp ├── D.cpp ├── F.cpp ├── G.cpp ├── J.cpp └── K.cpp ├── 2017-2018 ACM-ICPC Southwestern European Regional Programming Contest (SWERC 2017) ├── A.cpp ├── C.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── J.cpp └── K.cpp ├── 2017-2018 ACM-ICPC, Asia Daejeon Regional Contest ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── K.cpp └── L.cpp ├── 2017-2018 ACM-ICPC, Central Europe Regional Contest (CERC 17) ├── A.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp └── K.cpp ├── 2017-2018 ACM-ICPC, NEERC, Northern Subregional Contest ├── A.cpp ├── B.py ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp ├── L.cpp └── statements.pdf ├── 2017-2018 Northwestern European Regional Contest (NWERC 2017) ├── B.cpp ├── D.cpp ├── G.cpp ├── H.cpp ├── I.cpp └── K.cpp ├── 2017-2018 Petrozavodsk Winter Training Camp, Saratov SU Contest ├── A.cpp ├── D.cpp ├── F.cpp └── L.cpp ├── 2018 China Collegiate Programming Contest Final (CCPC-Final 2018) ├── D.cpp └── statements.pdf ├── 2018 ICPC Asia Jakarta Regional Contest ├── A.cpp ├── D.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp ├── L.cpp └── statements.pdf ├── 2018 Multi-University Training Contest 1 ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── G.cpp ├── H.cpp └── K.cpp ├── 2018 Multi-University Training Contest 10 ├── A.cpp ├── E.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp └── L.cpp ├── 2018 Multi-University Training Contest 2 ├── C.cpp ├── D.cpp ├── E.cpp ├── G.cpp └── J.cpp ├── 2018 Multi-University Training Contest 3 ├── A.cpp ├── C.cpp ├── D.cpp ├── F.cpp ├── G.cpp └── L.cpp ├── 2018 Multi-University Training Contest 4 ├── B.cpp ├── D.cpp ├── E.cpp ├── J.cpp ├── K.cpp └── L.cpp ├── 2018 Multi-University Training Contest 5 ├── B.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp └── H.cpp ├── 2018 Multi-University Training Contest 6 ├── A.cpp ├── B.cpp ├── C.cpp ├── I.cpp ├── K.cpp └── L.cpp ├── 2018 Multi-University Training Contest 7 ├── A.cpp ├── E.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp └── K.cpp ├── 2018 Multi-University Training Contest 9 ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── J.cpp └── K.cpp ├── 2018-2019 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2018) ├── B.cpp ├── C.cpp ├── E.cpp ├── G.cpp ├── H.cpp ├── I.cpp └── statements.pdf ├── 2018-2019 ACM-ICPC, Asia Seoul Regional Contest ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── J.cpp ├── K.cpp ├── L.cpp └── statements.pdf ├── 2018-2019 ICPC, NEERC, Northern Eurasia Finals ├── A.cpp ├── B.cpp ├── C.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── J.cpp ├── K.cpp ├── L.cpp ├── M.cpp └── statements.pdf ├── 2018-2019 ICPC, NEERC, Southern Subregional Contest ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── I.cpp__tests ├── I.exe ├── J.cpp ├── K.cpp └── statements.pdf ├── 2018-2019 XIX Open Cup, Grand Prix of Korea ├── A.cpp ├── B.cpp ├── C ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp ├── L.cpp ├── M.cpp └── statements.pdf ├── 2018中国大学生程序设计竞赛 - 网络选拔赛 ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── G.cpp ├── I.cpp └── J.cpp ├── 2018牛客网暑期ACM多校训练营(第一场) ├── A.cpp ├── B.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── I.cpp └── J.cpp ├── 2018牛客网暑期ACM多校训练营(第七场) ├── A.cpp ├── C.cpp ├── D.cpp ├── E.cpp └── J.cpp ├── 2018牛客网暑期ACM多校训练营(第三场) ├── A.cpp ├── C.cpp ├── E.cpp ├── H.cpp ├── I.cpp └── J.cpp ├── 2018牛客网暑期ACM多校训练营(第九场) ├── A.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp └── I.cpp ├── 2018牛客网暑期ACM多校训练营(第二场) ├── A.cpp ├── B.cpp ├── D.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp └── K.cpp ├── 2018牛客网暑期ACM多校训练营(第五场) ├── A.cpp ├── B.py ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp └── J.cpp ├── 2018牛客网暑期ACM多校训练营(第八场) ├── B.cpp ├── E.cpp ├── G.cpp └── H.cpp ├── 2018牛客网暑期ACM多校训练营(第六场) ├── A.cpp ├── C.cpp ├── D.cpp ├── F.java ├── G.cpp ├── I.cpp └── J.cpp ├── 2018牛客网暑期ACM多校训练营(第十场) ├── A.cpp ├── D.cpp ├── E.cpp ├── F.cpp └── J.cpp ├── 2018牛客网暑期ACM多校训练营(第四场) ├── A.cpp ├── C.cpp ├── D.cpp ├── F.cpp ├── G.cpp └── J.cpp ├── 2019 China Collegiate Programming Contest, Qinhuangdao Site ├── C.cpp ├── D.cpp ├── F.cpp ├── G.cpp ├── I.cpp ├── J.cpp └── K.cpp ├── 2019 ICPC Asia Hong Kong Onsite ├── A.cpp ├── B.py ├── D.cpp ├── E.cpp ├── G.cpp ├── I.cpp ├── J.cpp └── statements.pdf ├── 2019 ICPC Asia Nanjing Onsite ├── D.cpp ├── E.cpp ├── I.cpp └── statements.pdf ├── 2019 ICPC Asia Xuzhou Onsite ├── A.cpp ├── B.cpp ├── C.cpp ├── E.cpp ├── F.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── L.cpp └── M.cpp ├── 2019 ICPC Asia Yinchuan Onsite ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.java ├── J.cpp ├── K.cpp ├── L.cpp ├── N.py └── statements.pdf ├── 2019 Multi-University Training Contest 1 ├── A.cpp ├── B.cpp ├── D.cpp ├── E.cpp ├── K.cpp ├── L.cpp └── M.cpp ├── 2019 Multi-University Training Contest 2 ├── E.cpp ├── G.cpp ├── I.cpp ├── J.cpp ├── K.cpp └── L.cpp ├── 2019 Multi-University Training Contest 3 ├── A.cpp ├── B.cpp ├── E.cpp ├── F.cpp ├── G.cpp └── H.cpp ├── 2019 Multi-University Training Contest 4 ├── A.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp └── J.cpp ├── 2019 Multi-University Training Contest 5 ├── A.cpp ├── B.cpp ├── C.cpp ├── E.cpp ├── F.cpp ├── G.cpp └── I.cpp ├── 2019 Multi-University Training Contest 6 ├── B.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp └── L.cpp ├── 2019-2020 ACM-ICPC Latin American Regional Programming Contest ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp ├── L.cpp ├── M.cpp └── statements.pdf ├── 2019-2020 ICPC Southeastern European Regional Programming Contest (SEERC 2019) ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── I.cpp ├── J.cpp └── statements.pdf ├── 2019-2020 ICPC, Asia Jakarta Regional Contest ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── J.cpp ├── K.cpp ├── L.cpp └── statements.pdf ├── 2019-2020 ICPC, NERC, Northern Eurasia Finals ├── A.cpp ├── B.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── I.cpp ├── J.cpp ├── K.cpp ├── L.cpp └── statements.pdf ├── 2019-2020 XX Open Cup, Grand Prix of Korea ├── A.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp ├── KK.cpp └── statements.pdf ├── 2019牛客暑期多校训练营(第一场) ├── A.cpp ├── B.cpp ├── C.cpp ├── E.cpp ├── F.cpp ├── H.cpp ├── I ├── I.cpp └── J.cpp ├── 2019牛客暑期多校训练营(第七场) ├── A.cpp ├── B.py ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.py └── K.cpp ├── 2019牛客暑期多校训练营(第三场) ├── B.cpp ├── C.cpp ├── F.cpp ├── G.cpp └── H.cpp ├── 2019牛客暑期多校训练营(第二场) ├── A.cpp ├── B.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── H.cpp ├── I.cpp └── J.cpp ├── 2019牛客暑期多校训练营(第五场) ├── A.py ├── B.cpp ├── C.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp └── input.in ├── 2019牛客暑期多校训练营(第八场) ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── G.cpp ├── I.cpp └── J.cpp ├── 2019牛客暑期多校训练营(第六场) ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp └── J.cpp ├── 2019牛客暑期多校训练营(第四场) ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── I.cpp ├── J.cpp └── K.cpp ├── ACM-ICPC 2018 南京赛区网络预赛 ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── G.cpp ├── I.cpp ├── J.cpp └── L.cpp ├── ACM-ICPC 2018 徐州赛区网络预赛 ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp └── K.cpp ├── ACM-ICPC 2018 沈阳赛区网络预赛 ├── B.cpp ├── D.cpp ├── F.cpp ├── G.cpp ├── I.cpp ├── J.cpp └── K.cpp ├── ACM-ICPC 2018 焦作赛区网络预赛 ├── A.cpp ├── B.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp └── L.cpp ├── ACM-ICPC 2018 青岛赛区网络预赛 ├── A.cpp ├── B.cpp ├── C.cpp ├── G.cpp ├── H.cpp ├── J.cpp └── K.cpp ├── ACM-ICPC 2019 上海赛区网络预赛 ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── F.cpp ├── J.cpp ├── L.cpp └── dabiao.txt ├── ACM-ICPC 2019 南京赛区网络预赛 ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp └── I.cpp ├── ACM-ICPC 2019 南昌赛区网络预赛 ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.py ├── H.cpp └── I.cpp ├── ACM-ICPC 2019 徐州赛区网络预赛 ├── A.py ├── B.cpp ├── C.py ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp ├── L.cpp └── M.cpp ├── ACM-ICPC 2019 沈阳赛区网络预赛 ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp └── K.cpp ├── ACM-ICPC 2019 银川赛区网络预赛 ├── A.cpp ├── D.cpp ├── H.cpp ├── I.cpp ├── K.cpp └── M.cpp ├── Asia Hong Kong Regional Contest 2016 ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp └── K.cpp ├── Asia-Tsukuba 2017 ├── A.cpp ├── B.cpp ├── C.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── I.cpp ├── K.cpp └── statements.pdf ├── BAPC 2018 ├── A.py ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp └── statements.pdf ├── ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 1 ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── K.cpp ├── L.cpp └── statements.pdf ├── ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 2, Div A ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── G.cpp ├── J.cpp ├── K.cpp └── statements.pdf ├── ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 2, Div B ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E ├── E.cpp ├── EE ├── EE.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── a.out ├── gen ├── gen.cpp └── input.txt ├── ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 3, Div A ├── A.py ├── C.cpp ├── D.cpp ├── E.cpp ├── I.cpp └── statements.pdf ├── ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 3, Div B ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── EE.cpp ├── F.cpp ├── H.cpp ├── I.cpp └── statements.pdf ├── ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 4, Div A ├── A.cpp ├── C.cpp ├── E.cpp ├── G.cpp ├── I.cpp ├── K.cpp ├── KK.cpp └── statements.pdf ├── ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 4, Div B ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp └── statements.pdf ├── ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 5. Div B ├── A ├── A.cpp ├── D.cpp ├── E.cpp ├── H.cpp └── statements.pdf ├── ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 6, The Final Contest ├── A.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── I.cpp ├── J.cpp ├── K.cpp ├── L.cpp ├── M.cpp └── N.cpp ├── ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 7, Blitz Contest ├── B.cpp ├── C.cpp ├── D.cpp ├── F.py ├── G.cpp ├── J.cpp ├── K.cpp ├── L.py ├── M.cpp ├── N.cpp ├── P.cpp ├── Q.py ├── R.cpp ├── S.cpp └── statements.pdf ├── CCPC 2016-2017, Finals ├── A.cpp ├── B.cpp ├── H.cpp ├── I.cpp ├── J.cpp └── L.cpp ├── Discover Vladivostok 2019. Division A Day 1 ├── A.cpp ├── B.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp └── statements.pdf ├── Discover Vladivostok 2019. Division A Day 2 ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── I.cpp └── statements.pdf ├── Discover Vladivostok 2019. Division A Day 3 ├── A.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp └── statements.pdf ├── Discover Vladivostok 2019. Division A Day 4 ├── B.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp ├── L.cpp └── statements.pdf ├── Helvetic Coding Contest 2018 online mirror ├── A1.cpp ├── A2.cpp ├── B1.cpp ├── B2.cpp ├── C1.cpp ├── C2.cpp ├── C3.cpp ├── D1.cpp ├── E1.cpp ├── E2.cpp ├── E3.cpp ├── F1.cpp ├── F2.cpp └── F3.cpp ├── ITMO Winter Camp 2019 ├── Day2 │ ├── 20190122.pdf │ ├── A.cpp │ ├── B.cpp │ ├── F.cpp │ ├── H.cpp │ ├── I.cpp │ ├── J.cpp │ ├── L.cpp │ ├── M.cpp │ ├── c.cpp │ ├── d.cpp │ ├── e.cpp │ ├── g.cpp │ └── l.py ├── Day3 │ ├── 20190123.pdf │ ├── A.cpp │ ├── C.cpp │ ├── F.cpp │ ├── G.cpp │ ├── H.cpp │ ├── L.cpp │ ├── b.cpp │ ├── d.cpp │ ├── i.py │ ├── j.cpp │ ├── k.cpp │ └── k.py ├── Day4 │ ├── 20190124.pdf │ ├── D.cpp │ ├── E.cpp │ ├── F.cpp │ ├── FF.cpp │ ├── H.cpp │ ├── a.py │ ├── b.py │ ├── c.py │ ├── gen.py │ ├── h.cpp │ ├── i.py │ └── ii.cpp ├── Day5 │ ├── 20190125.pdf │ ├── C.cpp │ ├── D.cpp │ ├── b.cpp │ ├── blossom.cpp │ ├── g.cpp │ ├── g.py │ ├── i.cpp │ └── j.cpp └── Day6 │ ├── 20190126.pdf │ ├── C.cpp │ ├── F.cpp │ ├── FF.cpp │ ├── K.cpp │ ├── KK.cpp │ ├── L.cpp │ ├── c.cpp │ ├── f.cpp │ ├── h.cpp │ ├── i.cpp │ ├── j.py │ └── k.cpp ├── MEX Foundation Contest ├── A.cpp ├── C_CD.cpp ├── C_HLD.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp └── statements.pdf ├── Moscow Pre-Finals Workshop 2016. Kent Nikaido Contest 1 ├── A.cpp ├── B.cpp ├── D.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp └── statements.pdf ├── Moscow Pre-Finals Workshop 2016. National Taiwan U Selection ├── A.cpp ├── B.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── H.cpp ├── I.cpp ├── J.cpp └── statements.pdf ├── Moscow Pre-Finals Workshop 2019. KAIST Contest ├── A.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp └── statements.pdf ├── NWERC 2018 ├── A.cpp ├── B.cpp ├── C.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp └── statements.pdf ├── NWERC 2019 ├── A.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp └── statements.pdf ├── North American Southeast Regional 2019 (Div 1) ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.py ├── I.cpp ├── J.cpp ├── K.cpp └── statements.pdf ├── Petrozavodsk Summer-2014. Andrew Stankevich Contest 46 ├── A.cpp ├── B.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── I.cpp ├── J.cpp └── statements.pdf ├── Petrozavodsk Summer-2015. Andrew Stankevich Contest 48 ├── C.cpp ├── D.cpp ├── J.cpp └── statements.pdf ├── Petrozavodsk Summer-2015. Moscow IPT Contest ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── G.cpp ├── H.cpp ├── J.cpp └── statements.pdf ├── Petrozavodsk Summer-2015. Xudyh Contest ├── A.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── J.cpp └── statements.pdf ├── Petrozavodsk Summer-2016. Warsaw U Contest, XVI Open Cup Onsite ├── B.cpp ├── D.cpp ├── E.cpp ├── G.py ├── H.cpp ├── J.cpp └── statements.pdf ├── Petrozavodsk Summer-2017. JOI TST 2012 Selection ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp └── statements.pdf ├── Petrozavodsk Summer-2017. MIPT Contest ├── B.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp └── statements.pdf ├── Petrozavodsk Summer-2017. Ruyi Li Contest 2 ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.java ├── K.cpp └── statements.pdf ├── Petrozavodsk Summer-2017. Songyang Chen Contest 1 ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp ├── L.cpp └── statements.pdf ├── Petrozavodsk Summer-2017. UESTC Selection ├── C.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp ├── L.cpp └── statements.pdf ├── Petrozavodsk Summer-2017. Warsaw U Contest, XVII OpenCup Onsite ├── A.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── G.cpp ├── H.cpp ├── J.cpp ├── K.cpp └── statements.pdf ├── Petrozavodsk Winter-2014. Andrew Stankevich Contest 47 ├── A.cpp ├── B.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── J.cpp └── statements.pdf ├── Petrozavodsk Winter-2016. JAG Contest ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── K.cpp └── statements.pdf ├── Petrozavodsk Winter-2016. Moscow SU Trinity Contest ├── A.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.py ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp └── statements.pdf ├── Petrozavodsk Winter-2016. Xiaoxu Guo Contest 4 ├── A.cpp ├── B.cpp ├── D.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp └── statements.pdf ├── Petrozavodsk Winter-2017. Xiaoxu Guo Contest 5 ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── K.cpp ├── brute.cpp ├── checker_B.cpp └── statements.pdf ├── Petrozavodsk Winter-2018. Atcoder Contest ├── A.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── H.cpp ├── I.cpp └── K.cpp ├── Petrozavodsk Winter-2018. Carnegie Mellon U Contest ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── H.cpp └── statements.pdf ├── Petrozavodsk Winter-2018. ITMO U 1 Contest ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── L.cpp └── statements.pdf ├── Petrozavodsk Winter-2018. Jagiellonian U Contest ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp └── L.cpp ├── Petrozavodsk Winter-2019. Japanese Contest ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── G.cpp ├── H.cpp ├── J.cpp ├── K.cpp └── statements.pdf ├── Petrozavodsk Winter-2019. Oleksandr Kulkov Contest ├── D.cpp ├── E.cpp ├── F.cpp ├── H.cpp ├── J.cpp ├── K.cpp └── statements.pdf ├── Petrozavodsk Winter-2019. Petrozavodsk SU Contest ├── A.cpp ├── B.py ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp └── statements.pdf ├── Petrozavodsk Winter-2019. Yandex Cup 2019 ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── DD.cpp ├── H.cpp ├── I.cpp ├── J.cpp └── statements.pdf ├── The 43rd ACM ICPC Asia Jiaozuo Regional Contest ├── A.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── I.cpp ├── L.cpp └── statements.pdf ├── The 43rd ACM ICPC Asia Nanjing Regional Contest ├── B.cpp ├── L.cpp └── statements.pdf ├── The 43rd ACM ICPC Asia Qingdao Regional Contest (Mirror) ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── J.cpp ├── L.cpp ├── M.cpp └── statements.pdf ├── The 43rd ACM ICPC Asia Shenyang Regional Contest ├── C.cpp ├── E.cpp ├── G.cpp ├── I.cpp ├── J.cpp ├── K.cpp ├── L.cpp ├── M.cpp └── statements.pdf ├── The 43rd ACM ICPC Asia Xuzhou Regional Contest ├── C.cpp ├── D.cpp ├── I.cpp ├── K ├── K.cpp ├── M.cpp └── statements.pdf ├── Warsaw U Contest, Urozero 2015 Day 4 ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp └── statements.pdf ├── XIX Open Cup named after E.V. Pankratiev. Grand Prix of America ├── A.cpp ├── B.cpp ├── D.cpp ├── E.cpp ├── G.cpp ├── I.cpp ├── J.cpp ├── L.cpp ├── M.cpp └── statements.pdf ├── XIX Open Cup named after E.V. Pankratiev. Grand Prix of China ├── A.cpp ├── D.cpp ├── F.cpp ├── I.cpp ├── J.cpp └── statements.pdf ├── XIX Open Cup named after E.V. Pankratiev. Grand Prix of Eurasia ├── 1.cpp ├── 10.cpp ├── 11.cpp ├── 3.cpp ├── 4.cpp ├── 5.cpp ├── 7.cpp ├── 8.cpp ├── 9.cpp └── statements.pdf ├── XIX Open Cup named after E.V. Pankratiev. Grand Prix of Peterhof ├── A.cpp ├── B.cpp ├── C.cpp ├── E.cpp ├── F.py ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp └── statements.pdf ├── XIX Open Cup named after E.V. Pankratiev. Grand Prix of SPb, Division 1 ├── A.cpp ├── D.cpp ├── E.py ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp └── statements.pdf ├── XIX Open Cup named after E.V. Pankratiev. Grand Prix of Siberia ├── 1.py ├── 10.cpp ├── 11.cpp ├── 12.cpp ├── 2.cpp ├── 3.cpp ├── 4.cpp ├── 5.cpp ├── 6.cpp ├── 7.cpp └── statements.pdf ├── XVII Open Cup named after E.V. Pankratiev. Grand Prix of America (NAIPC-2017) ├── A.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── H.cpp ├── J.cpp └── statements.pdf ├── XVII Open Cup named after E.V. Pankratiev. Grand Prix of Moscow Workshops ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp └── statements.pdf ├── XVII Open Cup named after E.V. Pankratiev. Grand Prix of Two Capitals ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── F.cpp ├── H.cpp ├── J.cpp ├── K.cpp └── statements.pdf ├── XVII Open Cup named after E.V. Pankratiev. XXI Ural Championship ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── G.cpp ├── H.cpp ├── J.cpp ├── K.cpp ├── M.cpp └── statements.pdf ├── XVIII Open Cup named after E.V. Pankratiev. Eastern Grand Prix ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── G.cpp ├── I.cpp ├── J.cpp ├── K.cpp ├── L.cpp └── statements.pdf ├── XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Eurasia ├── 1.cpp ├── 10.cpp ├── 11.cpp ├── 12.cpp ├── 2.cpp ├── 4.cpp ├── 8.cpp └── statements.pdf ├── XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Gomel ├── A.cpp ├── B.cpp ├── D.cpp ├── F.cpp ├── G.cpp ├── J.cpp ├── K.cpp ├── KK.cpp └── statements.pdf ├── XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Khamovniki ├── A.cpp ├── C.cpp ├── D.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp └── statements.pdf ├── XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Korea ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── F.cpp ├── I.cpp ├── J.cpp ├── K.cpp ├── L.cpp └── statements.pdf ├── XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Peterhof ├── A.py ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── dabiao.txt ├── hardcode.cpp └── statements.pdf ├── XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Romania ├── A.cpp ├── C.cpp ├── D.cpp ├── J.cpp ├── L.cpp └── statements.pdf ├── XVIII Open Cup named after E.V. Pankratiev. Grand Prix of SPb ├── A.cpp ├── B.cpp ├── E.cpp ├── G.cpp ├── I.cpp ├── J.cpp ├── K.cpp ├── L.cpp └── statements.pdf ├── XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Siberia ├── 1.cpp ├── 10.py ├── 11.cpp ├── 12.cpp ├── 2.py ├── 4.cpp ├── 5.cpp ├── 7.cpp ├── 8.cpp ├── 9.cpp └── statements.pdf ├── XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Ukraine ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── F.cpp ├── G.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── L.cpp └── statements.pdf ├── XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Urals ├── A.cpp ├── B.cpp ├── C.cpp ├── D.cpp ├── E.cpp ├── F.cpp ├── K.cpp ├── cdq.cpp └── statements.pdf ├── XX Open Cup named after E.V. Pankratiev. Grand Prix of Kazan ├── B.cpp ├── E.cpp ├── G.cpp ├── I.cpp └── statements.pdf ├── XX Open Cup named after E.V. Pankratiev. Grand Prix of SPb ├── A.py ├── B.cpp ├── C.cpp ├── D.cpp ├── E.py ├── F.cpp ├── H.cpp ├── I.cpp ├── J.cpp ├── K.cpp └── statements.pdf ├── XX Open Cup named after E.V. Pankratiev. Grand Prix of Siberia ├── 1.cpp ├── 10.cpp ├── 11.cpp ├── 2.cpp ├── 4.cpp ├── 5.cpp ├── 6.cpp ├── 7.cpp ├── 8.cpp └── statements.pdf ├── readme.md ├── sh.exe.stackdump ├── 字节跳动冬令营网络赛 ├── C.cpp └── D.cpp └── 第四届CCPC中国大学生程序设计竞赛(吉林) └── H.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.json 3 | -------------------------------------------------------------------------------- /2014-2015 Petrozavodsk Winter Training Camp, Contest.58 (Makoto rng_58 Soejima contest)/A.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by sy-chen on 18-6-7. 3 | // 4 | #include 5 | #define MAXN 100005 6 | #define INF 1000000000 7 | #define MOD 1000000007 8 | #define F first 9 | #define S second5**0.5 10 | 11 | using namespace std; 12 | typedef long long ll; 13 | double d; 14 | int main() 15 | { 16 | scanf("%lf",&d); 17 | double ans=0; 18 | ans=max(ans,sqrt(2)*d); 19 | double r=floor(d); 20 | //printf("%.12f\n",r); 21 | double x=sqrt(d*d-r*r); 22 | if(x<1&&d>=1) ans=max(ans,r+1); 23 | printf("%.12f\n",ans); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /2015-2016 Petrozavodsk Winter Training Camp, Makoto rng_58 Soejima Сontest 4/E.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: E.cpp 3 | > Author: Roundgod 4 | > Mail: wcysai@foxmail.com 5 | > Created Time: 2018-09-02 14:09:43 6 | ************************************************************************/ 7 | 8 | #pragma GCC optimize(3) 9 | #include 10 | #define MAXN 100005 11 | #define INF 1000000000 12 | #define MOD 1000000007 13 | #define F first 14 | #define S second 15 | using namespace std; 16 | typedef long long ll; 17 | typedef pair P; 18 | ll n,k,a[MAXN]; 19 | int main() 20 | { 21 | scanf("%lld",&n); 22 | for(ll i=0;icur) 28 | { 29 | cur+=a[i]; 30 | ans++; 31 | } 32 | } 33 | printf("%lld\n",ans); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /2015-2016 Petrozavodsk Winter Training Camp, Makoto rng_58 Soejima Сontest 4/J.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #ifdef __LOCAL_DEBUG__ 5 | # define _debug(fmt, ...) fprintf(stderr, "\033[94m%s: " fmt "\n\033[0m", \ 6 | __func__, ##__VA_ARGS__) 7 | #else 8 | # define _debug(...) ((void) 0) 9 | #endif 10 | #define rep(i, n) for (int i=0; i<(n); i++) 11 | #define Rep(i, n) for (int i=1; i<=(n); i++) 12 | #define range(x) (x).begin(), (x).end() 13 | typedef long long LL; 14 | typedef unsigned long long ULL; 15 | 16 | const LL mod = 1000000007, inv2 = (mod + 1) / 2; 17 | 18 | int n; 19 | LL a[4]; 20 | 21 | 22 | int main() { 23 | scanf("%d", &n); 24 | rep (i, n) { 25 | int d; scanf("%d", &d); 26 | a[d]++; 27 | } 28 | if (a[1] + 2 * a[2] + 3 * a[3] != 2 * n - 2 || a[1] != a[3] + 2) { 29 | cout << 0 << endl; 30 | } else { 31 | LL ans = 1; 32 | Rep (i, n - 2) ans = ans * i % mod; 33 | rep (i, a[3]) ans = ans * inv2 % mod; 34 | cout << ans << endl; 35 | } 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /2015-2016 Petrozavodsk Winter Training Camp, Makoto rng_58 Soejima Сontest 4/L.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #ifdef __LOCAL_DEBUG__ 5 | # define _debug(fmt, ...) fprintf(stderr, "\033[94m%s: " fmt "\n\033[0m", \ 6 | __func__, ##__VA_ARGS__) 7 | #else 8 | # define _debug(...) ((void) 0) 9 | #endif 10 | #define rep(i, n) for (int i=0; i<(n); i++) 11 | #define Rep(i, n) for (int i=1; i<=(n); i++) 12 | #define range(x) (x).begin(), (x).end() 13 | typedef long long LL; 14 | typedef unsigned long long ULL; 15 | 16 | int n, m; 17 | char s[5120], t[5120]; 18 | 19 | int main() { 20 | scanf("%s%s", s, t); 21 | n = strlen(s); m = strlen(t); 22 | int l = 0, r = 0; 23 | while (s[l] && s[l] == s[0]) l++; 24 | while (t[r] && t[r] == t[0]) r++; 25 | if (s[0] != t[0] || l < r) { 26 | puts("No"); 27 | return 0; 28 | } 29 | r = l; 30 | while (s[l]) { 31 | while (t[r] && t[r] != s[l]) r++; 32 | if (t[r] == 0) { 33 | puts("No"); 34 | return 0; 35 | } 36 | l++; r++; 37 | } 38 | puts("Yes"); 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /2015-2016 Petrozavodsk Winter Training Camp, SPb SU + SPb AU Contest/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int n,a[MAXN],b[MAXN]; 11 | vector

v; 12 | int main() 13 | { 14 | scanf("%d",&n); 15 | for(int i=1;i<=n;i++) scanf("%d",&a[i]); 16 | for(int i=1;i<=n;i++) scanf("%d",&b[i]); 17 | for(int i=1;i<=n;i++) v.push_back(P(a[i],b[i])); 18 | sort(v.begin(),v.end(),greater

()); 19 | ll ans=0; 20 | priority_queue,greater > pque; 21 | for(int i=1;i 2 | #define MAXN 1000005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int n; 11 | P a[MAXN]; 12 | bool cmp(P x,P y) 13 | { 14 | if(x.S-x.F>0&&y.S-y.F>0) return x.F=0||y.S-y.F>=0) return x.S-x.F>y.S-y.F; 17 | return max(x.F,x.F+y.F-x.S) 5 | #define MAXN 1005 6 | #define INF 1000000000 7 | #define MOD 1000000007 8 | #define F first 9 | #define S second 10 | using namespace std; 11 | typedef long long ll; 12 | typedef pair P; 13 | int t,n,a[MAXN],b[MAXN],s[MAXN]; 14 | int main() 15 | { 16 | scanf("%d",&t); 17 | int kase=0; 18 | while(t--) 19 | { 20 | kase++; 21 | scanf("%d",&n); 22 | double sum=0; 23 | for(int i=0;i 5 | #define MAXN 100005 6 | #define INF 1000000000 7 | #define MOD 1000000007 8 | #define F first 9 | #define S second 10 | using namespace std; 11 | typedef long long ll; 12 | typedef pair P; 13 | int t,n; 14 | int main() 15 | { 16 | scanf("%d",&t); 17 | int kase=0; 18 | while(t--) 19 | { 20 | kase++; 21 | scanf("%d",&n); 22 | if(n>=7) 23 | { 24 | if(n&1) printf("Case #%d: Panda\n",kase); 25 | else if(n>15) printf("Case #%d: Sheep\n",kase); 26 | else printf("Case #%d: Draw\n",kase); 27 | } 28 | else printf("Case #%d: Draw\n",kase); 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /2017-2018 ACM-ICPC Asia East Continent League Final (ECL-Final 2017)/M.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by calabash_boy on 18-5-24. 3 | // 4 | #include 5 | #define MAXN 100005 6 | #define INF 1000000000 7 | #define MOD 1000000007 8 | #define F first 9 | #define S second 10 | using namespace std; 11 | typedef long long ll; 12 | int t,n,a[5]; 13 | int main() 14 | { 15 | scanf("%d",&t); 16 | int kase=0; 17 | while(t--) 18 | { 19 | kase++; 20 | for(int i=0;i<5;i++) scanf("%d",&a[i]); 21 | scanf("%d",&n); 22 | int s=0,x; 23 | for(int i=0;i=1&&x<=48) s+=a[0]; 27 | else if(x>=49&&x<=56) s+=a[1]; 28 | else if(x>=57&&x<=60) s+=a[2]; 29 | else if(x>=61&&x<=62) s+=a[3]; 30 | else s+=a[4]; 31 | } 32 | printf("Case #%d: %I64d\n",kase,10000LL*s); 33 | } 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /2017-2018 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2017)/J.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #ifdef __LOCAL_DEBUG__ 5 | # define _debug(fmt, ...) fprintf(stderr, "\033[94m%s: " fmt "\n\033[0m", \ 6 | __func__, ##__VA_ARGS__) 7 | #else 8 | # define _debug(...) ((void) 0) 9 | #endif 10 | #define rep(i, n) for (int i=0; i<(n); i++) 11 | #define Rep(i, n) for (int i=1; i<=(n); i++) 12 | #define range(x) (x).begin(), (x).end() 13 | typedef long long LL; 14 | typedef unsigned long long ULL; 15 | 16 | int main() { 17 | int l, r; cin >> l >> r; 18 | if (l == 0 && r == 0) { 19 | printf("Not a moose\n"); 20 | } else if (l == r ) { 21 | printf("Even %d\n", l + r); 22 | } else { 23 | printf("Odd %d\n", 2*max(l, r)); 24 | } 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /2017-2018 ACM-ICPC Northern Eurasia (Northeastern European Regional) Contest (NEERC 17)/B.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by calabash_boy on 18-6-8. 3 | // 4 | #include 5 | using namespace std; 6 | int a,b,c,w,h; 7 | bool check(int xx,int yy){ 8 | if(xx<=w&&yy<=h)return true; 9 | if(xx<=h&&yy<=w)return true; 10 | return false; 11 | } 12 | bool check(int a,int b,int c){ 13 | if(check(2*b+2*c,a+2*b)||check(a+b+2*c,a+2*b)||check(a+b+c,a+2*b+c)||check(3*a+b+c,b+c)){ 14 | return true; 15 | }else{ 16 | return false; 17 | } 18 | } 19 | int main(){ 20 | cin>>a>>b>>c>>w>>h; 21 | if(check(a,b,c)||check(a,c,b)||check(b,a,c)||check(b,c,a)||check(c,a,b)||check(c,b,a)){ 22 | cout<<"Yes"< 3 | using namespace std; 4 | 5 | #ifdef __LOCAL_DEBUG__ 6 | # define _debug(fmt, ...) fprintf(stderr, "\033[94m%s: " fmt "\n\033[0m", \ 7 | __func__, ##__VA_ARGS__) 8 | #else 9 | # define _debug(...) (void(0)) 10 | #endif 11 | 12 | #define rep(i, n) for (int i=0; i<(n); i++) 13 | #define Rep(i, n) for (int i=1; i<=(n); i++) 14 | #define range(x) (x).begin(), (x).end() 15 | typedef long long ll; 16 | typedef unsigned long long ull; 17 | 18 | int n; 19 | int ans[100005]; 20 | pair val[100005]; 21 | 22 | int main() { 23 | cin >> n; 24 | for (int i=0; i> val[i].first; 26 | val[i].second = i; 27 | } 28 | sort(val, val+n); 29 | for (int i=0; i 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int n,w,l,x,y; 11 | int main() 12 | { 13 | scanf("%d",&w); 14 | scanf("%d",&n); 15 | ll s=0; 16 | for(int i=0;i 3 | using namespace std; 4 | 5 | #ifdef __LOCAL_DEBUG__ 6 | # define _debug(fmt, ...) fprintf(stderr, "\033[94m%s: " fmt "\n\033[0m", \ 7 | __func__, ##__VA_ARGS__) 8 | #else 9 | # define _debug(...) (void(0)) 10 | #endif 11 | 12 | #define rep(i, n) for (int i=0; i<(n); i++) 13 | #define Rep(i, n) for (int i=1; i<=(n); i++) 14 | #define range(x) (x).begin(), (x).end() 15 | typedef long long ll; 16 | typedef unsigned long long ull; 17 | 18 | int n; 19 | ll w[3], h[3]; 20 | 21 | int main() { 22 | scanf("%d", &n); 23 | Rep (i, n) { 24 | int ww; scanf("%d", &ww); 25 | w[i%3] += ww; 26 | } 27 | Rep (i, n) { 28 | int hh; scanf("%d", &hh); 29 | h[i%3] += hh; 30 | } 31 | ll ans[3] = {0}; 32 | for (int i=0; i<3; i++) 33 | for (int j=0; j<3; j++) 34 | ans[(i+j)%3] += w[i] * h[j]; 35 | for (int i=0; i<3; i++) cout << ans[i] << ' '; 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /2017-2018 ACM-ICPC, NEERC, Northern Subregional Contest/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 1000005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef pair P; 9 | int v[3]={1,7,4}; 10 | int w[3]={2,3,4}; 11 | int n; 12 | int main() 13 | { 14 | freopen("auxiliary.in","r",stdin); 15 | freopen("auxiliary.out","w",stdout); 16 | scanf("%d",&n); 17 | int ans=0; 18 | for(int j=0;4*j<=n;j++) 19 | { 20 | int rest=n-4*j; 21 | if(rest%3) continue; 22 | ans=max(ans,4*j+7*(rest/3)); 23 | } 24 | for(int j=0;4*j+2<=n;j++) 25 | { 26 | int rest=n-4*j-2; 27 | if(rest%3) continue; 28 | ans=max(ans,4*j+1+7*(rest/3)); 29 | } 30 | printf("%d\n",ans); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /2017-2018 ACM-ICPC, NEERC, Northern Subregional Contest/B.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import sys, string 3 | sys.stdin = open("boolean.in", "r") 4 | sys.stdout = open("boolean.out", "w") 5 | s = list(set(input().split('|'))) 6 | sch = set(ch[-1] for ch in s) 7 | nlit = len(sch) 8 | for ch in sch : 9 | if ch in s and ('~' + ch) in s : 10 | print(2**nlit) 11 | exit(0) 12 | print(2**nlit-1) 13 | -------------------------------------------------------------------------------- /2017-2018 ACM-ICPC, NEERC, Northern Subregional Contest/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define F first 5 | #define S second 6 | using namespace std; 7 | typedef long long ll; 8 | typedef pair P; 9 | int n,x[MAXN],y[MAXN]; 10 | int minx,maxx,miny,maxy,ans; 11 | int getdis(int i,int j) 12 | { 13 | return max(x[i]-x[j],x[j]-x[i])+max(y[i]-y[j],y[j]-y[i]); 14 | } 15 | int main() 16 | { 17 | freopen("intel.in","r",stdin); 18 | freopen("intel.out","w",stdout); 19 | ans=0; 20 | minx=miny=INF; maxx=maxy=-INF; 21 | scanf("%d",&n); 22 | for(int i=1;i<=n;i++) 23 | { 24 | scanf("%d%d",&x[i],&y[i]); 25 | minx=min(minx,x[i]); maxx=max(maxx,x[i]); 26 | miny=min(miny,y[i]); maxy=max(maxy,y[i]); 27 | if(i>1) ans+=getdis(i,i-1); 28 | } 29 | ans+=getdis(1,n); 30 | ans-=2*(maxx-minx)+2*(maxy-miny); 31 | printf("%d\n",ans); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /2017-2018 ACM-ICPC, NEERC, Northern Subregional Contest/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/2017-2018 ACM-ICPC, NEERC, Northern Subregional Contest/statements.pdf -------------------------------------------------------------------------------- /2017-2018 Northwestern European Regional Contest (NWERC 2017)/B.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by sy-chen on 18-5-31. 3 | // 4 | #include 5 | using namespace std; 6 | int n; 7 | int main() 8 | { 9 | scanf("%d",&n); 10 | if(n<=3) puts("1"); else printf("%d\n",n-2); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /2018 China Collegiate Programming Contest Final (CCPC-Final 2018)/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/2018 China Collegiate Programming Contest Final (CCPC-Final 2018)/statements.pdf -------------------------------------------------------------------------------- /2018 ICPC Asia Jakarta Regional Contest/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | string str; 16 | 17 | int main() { 18 | cin >> str; 19 | int c0 = count(range(str), '0'); 20 | int c1 = count(range(str), '1'); 21 | if (c0 < c1) { 22 | for (char ch : str) cout << '0'; 23 | } else if (c0 > c1) { 24 | for (char ch : str) cout << '1'; 25 | } else { 26 | int flag = str[0] - '0'; 27 | rep (i, str.size()) { 28 | if (i == 0) cout << 1 - flag; 29 | else cout << flag; 30 | } 31 | } 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /2018 ICPC Asia Jakarta Regional Contest/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int n,now; 11 | string str; 12 | int main() 13 | { 14 | scanf("%d",&n);now=0; 15 | for(int i=0;i>str; 18 | if(str[0]=='L') now^=1; 19 | } 20 | if(now) puts("LIE"); else puts("TRUTH"); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /2018 ICPC Asia Jakarta Regional Contest/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/2018 ICPC Asia Jakarta Regional Contest/statements.pdf -------------------------------------------------------------------------------- /2018 Multi-University Training Contest 1/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #ifdef __LOCAL_DEBUG__ 5 | # define _debug(fmt, ...) fprintf(stderr, "\033[94m%s: " fmt "\n\033[0m", \ 6 | __func__, ##__VA_ARGS__) 7 | #else 8 | # define _debug(...) ((void) 0) 9 | #endif 10 | #define rep(i, n) for (int i=0; i<(n); i++) 11 | #define Rep(i, n) for (int i=1; i<=(n); i++) 12 | #define range(x) (x).begin(), (x).end() 13 | typedef long long LL; 14 | typedef unsigned long long ULL; 15 | 16 | int n; 17 | 18 | int main() { 19 | int T; scanf("%d", &T); 20 | while (T--) { 21 | int x, y; 22 | scanf("%d", &n); 23 | vector> p(n * 3); 24 | rep (i, 3 * n) { 25 | scanf("%d%d", &x, &y); 26 | p[i].first = x; p[i].second = i + 1; 27 | } 28 | sort(range(p)); 29 | rep (i, 3 * n) { 30 | printf("%d%c", p[i].second, i%3==2?'\n':' '); 31 | } 32 | } 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /2018 Multi-University Training Contest 1/K.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #ifdef __LOCAL_DEBUG__ 5 | # define _debug(fmt, ...) fprintf(stderr, "\033[94m%s: " fmt "\n\033[0m", \ 6 | __func__, ##__VA_ARGS__) 7 | #else 8 | # define _debug(...) ((void) 0) 9 | #endif 10 | #define rep(i, n) for (int i=0; i<(n); i++) 11 | #define Rep(i, n) for (int i=1; i<=(n); i++) 12 | #define range(x) (x).begin(), (x).end() 13 | typedef long long LL; 14 | typedef unsigned long long ULL; 15 | 16 | int h, m; 17 | char str[32]; 18 | 19 | int main() { 20 | int T; scanf("%d", &T); 21 | while (T--) { 22 | scanf("%d %d %s", &h, &m, str); 23 | { 24 | double off; 25 | sscanf(str + 3, "%lf", &off); 26 | off *= 10; 27 | int t = lround(off); 28 | t -= 80; 29 | m += t * 6; 30 | } 31 | while (m < 0) m += 60, h--; 32 | while (m >= 60) m-= 60, h++; 33 | while (h < 0) h += 24; 34 | while (h >= 24) h -= 24; 35 | printf("%02d:%02d\n", h, m); 36 | } 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /2018 Multi-University Training Contest 10/G.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: G.cpp 3 | > Author: Roundgod 4 | > Mail: wcysai@foxmail.com 5 | > Created Time: 2018-08-22 12:26:46 6 | ************************************************************************/ 7 | 8 | #pragma GCC optimize(3) 9 | #include 10 | #define MAXN 100005 11 | #define INF 1000000000 12 | #define MOD 998244353 13 | #define F first 14 | #define S second 15 | using namespace std; 16 | typedef long long ll; 17 | typedef pair P; 18 | int T,n; 19 | int a[MAXN]; 20 | int main() 21 | { 22 | a[1]=a[2]=0; 23 | a[3]=a[4]=1; 24 | int now=1; 25 | for(int i=5;i<=100000;i++) 26 | { 27 | a[i]=(1LL*(i-2)*a[i-1]+1LL*(i-1)*a[i-2]+now)%MOD; 28 | now=-now; 29 | } 30 | scanf("%d",&T); 31 | for(int i=0;i 2 | using namespace std; 3 | 4 | #ifdef __LOCAL_DEBUG__ 5 | # define _debug(fmt, ...) fprintf(stderr, "\033[94m%s: " fmt "\n\033[0m", \ 6 | __func__, ##__VA_ARGS__) 7 | #else 8 | # define _debug(...) ((void) 0) 9 | #endif 10 | #define rep(i, n) for (int i=0; i<(n); i++) 11 | #define Rep(i, n) for (int i=1; i<=(n); i++) 12 | #define range(x) (x).begin(), (x).end() 13 | typedef long long LL; 14 | typedef unsigned long long ULL; 15 | 16 | int n; 17 | int x[1024]; 18 | 19 | int main() { 20 | int T; scanf("%d", &T); 21 | while (T--) { 22 | scanf("%d", &n); 23 | memset(x, 0, sizeof x); 24 | x[0] = 1; 25 | while (n--) { 26 | rep (i, 1000) { 27 | x[i] <<= 1; 28 | } 29 | rep (i, 1000) { 30 | x[i+1] += x[i] / 10; 31 | x[i] %= 10; 32 | } 33 | } 34 | int ptr = 1023; 35 | while (x[ptr] == 0) ptr--; 36 | while (ptr >= 0) putchar('0'+x[ptr--]); 37 | puts(""); 38 | } 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /2018 Multi-University Training Contest 2/D.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: D.cpp 3 | > Author: Roundgod 4 | > Mail: wcysai@foxmail.com 5 | > Created Time: 2018-07-25 12:02:48 6 | ************************************************************************/ 7 | 8 | #pragma GCC optimize(3) 9 | #include 10 | #define MAXN 100005 11 | #define INF 1000000000 12 | #define MOD 1000000007 13 | #define F first 14 | #define S second 15 | using namespace std; 16 | typedef long long ll; 17 | typedef pair P; 18 | int n; 19 | int main() 20 | { 21 | while(scanf("%d",&n)==1) puts("Yes"); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /2018 Multi-University Training Contest 2/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 3060; 4 | const int M = 47; 5 | int a[maxn][maxn]; 6 | int main(){ 7 | //freopen("res.out","w",stdout); 8 | for (int i=0;i File Name: D.cpp 3 | > Author: Roundgod 4 | > Mail: wcysai@foxmail.com 5 | > Created Time: 2018-07-30 12:07:25 6 | ************************************************************************/ 7 | 8 | #pragma GCC optimize(3) 9 | #include 10 | #define MAXN 1000005 11 | #define INF 1000000000 12 | #define MOD 1000000007 13 | #define F first 14 | #define S second 15 | using namespace std; 16 | typedef long long ll; 17 | typedef pair P; 18 | int T,k; 19 | int main() 20 | { 21 | scanf("%d",&T); 22 | while(T--) 23 | { 24 | scanf("%d",&k); 25 | if(k==1) puts("5"); 26 | else if(k==2) puts("7"); 27 | else printf("%d\n",k+5); 28 | } 29 | return 0; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /2018 Multi-University Training Contest 3/F.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: F.cpp 3 | > Author: Roundgod 4 | > Mail: wcysai@foxmail.com 5 | > Created Time: 2018-07-30 12:17:01 6 | ************************************************************************/ 7 | 8 | #pragma GCC optimize(3) 9 | #include 10 | #define MAXN 100005 11 | #define INF 1000000000 12 | #define MOD 1000000007 13 | #define F first 14 | #define S second 15 | using namespace std; 16 | typedef long long ll; 17 | typedef pair P; 18 | int T,n,w[MAXN]; 19 | int main() 20 | { 21 | scanf("%d",&T); 22 | while(T--) 23 | { 24 | scanf("%d",&n); 25 | int s=0; 26 | for(int i=0;i 2 | using namespace std; 3 | typedef long long LL; 4 | int T,n,m; 5 | const int maxn = 150; 6 | int a[maxn]; 7 | int main(){ 8 | scanf("%d",&T); 9 | while (T--){ 10 | scanf("%d%d",&n,&m); 11 | int x,y; 12 | for (int i=0;i 2 | using namespace std; 3 | 4 | #ifdef __LOCAL_DEBUG__ 5 | # define _debug(fmt, ...) fprintf(stderr, "\033[94m%s: " fmt "\n\033[0m", \ 6 | __func__, ##__VA_ARGS__) 7 | #else 8 | # define _debug(...) ((void) 0) 9 | #endif 10 | #define rep(i, n) for (int i=0; i<(n); i++) 11 | #define Rep(i, n) for (int i=1; i<=(n); i++) 12 | #define range(x) (x).begin(), (x).end() 13 | typedef long long LL; 14 | typedef unsigned long long ULL; 15 | 16 | int w[100005]; 17 | int main() { 18 | int T; scanf("%d", &T); 19 | while (T--) { 20 | int n; scanf("%d", &n); 21 | Rep (i, n) scanf("%d", &w[i]); 22 | printf("%d\n", int(sqrt(abs(w[1] - w[n])))); 23 | } 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /2018-2019 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2018)/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/2018-2019 ACM-ICPC Southeastern European Regional Programming Contest (SEERC 2018)/statements.pdf -------------------------------------------------------------------------------- /2018-2019 ACM-ICPC, Asia Seoul Regional Contest/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | using namespace std; 4 | int T; 5 | string str; 6 | int main() 7 | { 8 | scanf("%d",&T); 9 | while(T--) 10 | { 11 | cin>>str; 12 | int sz=(int)str.size(); 13 | string suf1=str.substr(sz-1),suf2=str.substr(sz-2); 14 | string pre1=str.substr(0,sz-1),pre2=str.substr(0,sz-2); 15 | if(suf1=="a") str=pre1+"as"; 16 | else if(suf1=="i"||suf1=="y") str=pre1+"ios"; 17 | else if(suf1=="l") str=pre1+"les"; 18 | else if(suf1=="n") str=pre1+"anes"; 19 | else if(suf2=="ne") str=pre2+"anes"; 20 | else if(suf1=="o") str=pre1+"os"; 21 | else if(suf1=="r") str=pre1+"res"; 22 | else if(suf1=="t") str=pre1+"tas"; 23 | else if(suf1=="u") str=pre1+"us"; 24 | else if(suf1=="v") str=pre1+"ves"; 25 | else if(suf1=="w") str=pre1+"was"; 26 | else str=str+"us"; 27 | cout< 2 | #define MAXN 100005 3 | #define INF 1000000000LL 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int t,k,a[8]; 11 | int main() 12 | { 13 | scanf("%d",&t); 14 | while(t--) 15 | { 16 | int ans=INF; 17 | scanf("%d",&k); 18 | int s=0; 19 | for(int i=1;i<=7;i++) 20 | { 21 | scanf("%d",&a[i]);s+=a[i]; 22 | } 23 | for(int i=1;i<=7;i++) 24 | { 25 | if(a[i]!=1) continue; 26 | int cnt=0; 27 | cnt=(k-1)/s*7+1; 28 | int now=(k-1)%s,cur=i; 29 | while(now>0) 30 | { 31 | cur++;if(cur>7) cur=1; 32 | now-=a[cur];cnt++; 33 | } 34 | ans=min(ans,cnt); 35 | } 36 | printf("%d\n",ans); 37 | } 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /2018-2019 ICPC, NEERC, Northern Eurasia Finals/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/2018-2019 ICPC, NEERC, Northern Eurasia Finals/statements.pdf -------------------------------------------------------------------------------- /2018-2019 ICPC, NEERC, Southern Subregional Contest/D.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: D.cpp 3 | > Author: Roundgod 4 | > Mail: wcysai@foxmail.com 5 | > Created Time: 2018-10-20 16:11:11 6 | ************************************************************************/ 7 | 8 | #pragma GCC optimize(3) 9 | #include 10 | #define MAXN 200005 11 | #define INF 1000000000 12 | #define MOD 1000000007 13 | #define F first 14 | #define S second 15 | using namespace std; 16 | typedef long long ll; 17 | typedef pair P; 18 | ll n,k,a[MAXN],b[MAXN]; 19 | int main() 20 | { 21 | scanf("%lld%lld",&n,&k); 22 | for(ll i=0;i 2 | #define MAXN 100005 3 | using namespace std; 4 | typedef long long ll; 5 | ll A,B,C,D; 6 | int main() 7 | { 8 | scanf("%lld%lld%lld%lld",&A,&B,&C,&D); 9 | ll ans=0; 10 | for(int i=1;i<999;i++) 11 | for(int j=1;i+j<=999;j++) 12 | { 13 | if(__gcd(i,j)>1) continue; 14 | if(i>B||j>D) continue; 15 | ll l1=(A-1)/i+1,r1=B/i,l2=(C-1)/j+1,r2=D/j; 16 | l1=max(l1,l2);r1=min(r1,r2); 17 | ans+=max(0LL,r1-l1+1); 18 | } 19 | printf("%lld\n",ans); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /2018-2019 XIX Open Cup, Grand Prix of Korea/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 5005 3 | using namespace std; 4 | int n,m; 5 | int sg[MAXN]; 6 | bool f[MAXN]; 7 | int main() 8 | { 9 | sg[2]=1; 10 | for(int i=3;i<=5000;i++) 11 | { 12 | memset(f,false,sizeof(f)); 13 | for(int j=0;j<=i/2;j++) 14 | f[sg[j]^sg[i-2-j]]=true; 15 | for(int j=0;;j++) 16 | if(!f[j]) {sg[i]=j; break;} 17 | } 18 | scanf("%d",&n); 19 | while(n--) 20 | { 21 | scanf("%d",&m); 22 | if(!sg[m]) puts("Second"); else puts("First"); 23 | } 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /2018-2019 XIX Open Cup, Grand Prix of Korea/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/2018-2019 XIX Open Cup, Grand Prix of Korea/statements.pdf -------------------------------------------------------------------------------- /2018中国大学生程序设计竞赛 - 网络选拔赛/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #ifdef __LOCAL_DEBUG__ 5 | # define _debug(fmt, ...) fprintf(stderr, "\033[94m%s: " fmt "\n\033[0m", \ 6 | __func__, ##__VA_ARGS__) 7 | #else 8 | # define _debug(...) ((void) 0) 9 | #endif 10 | #define rep(i, n) for (int i=0; i<(n); i++) 11 | #define Rep(i, n) for (int i=1; i<=(n); i++) 12 | #define range(x) (x).begin(), (x).end() 13 | typedef long long LL; 14 | typedef unsigned long long ULL; 15 | 16 | int main() { 17 | int T; scanf("%d", &T); 18 | while (T--) { 19 | int p; scanf("%d", &p); 20 | rep (i, p) { 21 | rep (j, p) { 22 | printf("%d%c", (i+j)%p, j==p-1?'\n':' '); 23 | } 24 | } 25 | rep (i, p) { 26 | rep (j, p) { 27 | printf("%d%c", int((1ll*i*j)%p), j==p-1?'\n':' '); 28 | } 29 | } 30 | } 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /2018牛客网暑期ACM多校训练营(第一场)/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #ifdef __LOCAL_DEBUG__ 5 | # define _debug(fmt, ...) fprintf(stderr, "\033[94m%s: " fmt "\n\033[0m", \ 6 | __func__, ##__VA_ARGS__) 7 | #else 8 | # define _debug(...) ((void) 0) 9 | #endif 10 | #define rep(i, n) for (int i=0; i<(n); i++) 11 | #define Rep(i, n) for (int i=1; i<=(n); i++) 12 | #define range(x) (x).begin(), (x).end() 13 | typedef long long LL; 14 | typedef unsigned long long ULL; 15 | 16 | int n, mod; 17 | int x[100005]; 18 | 19 | int main() { 20 | while (scanf("%d%d", &n, &mod) != EOF) { 21 | if (mod == 1) { 22 | puts("0"); 23 | continue; 24 | } 25 | x[0] = 1; x[1] = 0; x[2] = 1; 26 | for (int i = 3; i <= n; i++) { 27 | x[i] = (1ll * (i-1) * (x[i-1] + x[i-2]) + mod - 28 | 1ll * (i-1) * (i-2) / 2 % mod * x[i-3] % mod) % mod; 29 | // x[i] %= mod; 30 | } 31 | printf("%d\n", x[n] % mod); 32 | } 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /2018牛客网暑期ACM多校训练营(第三场)/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | map ans = { 5 | {3, "3.000000"}, 6 | {4, "3.666666"}, 7 | {5, "4.166666"}, 8 | {6, "4.566666"}, 9 | {7, "4.900000"}, 10 | {8, "5.185714286"}, 11 | {9, "5.43571429"}, 12 | {10, "5.657936508"} 13 | }; 14 | 15 | #define x1 atrbkatbjr 16 | #define y1 whiergwori 17 | #define x2 ehgowhrg 18 | #define y2 shiegpoorgshogs 19 | #define x3 wuoghrg 20 | #define y3 wtughsro 21 | 22 | int x1, y1, x2, y2, x3, y3; 23 | int n; 24 | 25 | int main() { 26 | cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> n; 27 | cout << ans[n] << endl; 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /2018牛客网暑期ACM多校训练营(第二场)/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 1e5+10; 4 | const int MOD = 1e9+7; 5 | typedef long long LL; 6 | LL dp[maxn][2]; 7 | LL sum[maxn]; 8 | int k,q; 9 | int main(){ 10 | scanf("%d%d",&q,&k); 11 | dp[0][0]=1; 12 | for (int i=1;i=k){ 15 | dp[i][1] = dp[i-k][0]; 16 | } 17 | sum[i] = sum[i-1]+dp[i][0]+dp[i][1]; 18 | sum[i]%=MOD; 19 | } 20 | while (q--){ 21 | int l,r; 22 | scanf("%d%d",&l,&r); 23 | printf("%d\n",(sum[r]-sum[l-1]+MOD)%MOD); 24 | } 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /2018牛客网暑期ACM多校训练营(第五场)/B.py: -------------------------------------------------------------------------------- 1 | x = 3 2 | y = 2 3 | ans = [2, 6] 4 | for i in range(10000): 5 | [x, y] = [3*x+4*y, 2*x+3*y] 6 | ans.append(y) 7 | if (y>10**10000) : break 8 | 9 | x = 7 10 | y = 2 11 | for i in range(10000): 12 | [x, y] = [7*x+24*y, 2*x+7*y] 13 | ans.append(y*3) 14 | if (y*3>10**10000) : break 15 | 16 | ans.sort() 17 | t = int(input()); 18 | for i in ans : 19 | if (i >= t) : 20 | print(i) 21 | break 22 | -------------------------------------------------------------------------------- /2018牛客网暑期ACM多校训练营(第五场)/G.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: G.cpp 3 | > Author: Roundgod 4 | > Mail: wcysai@foxmail.com 5 | > Created Time: 2018-08-02 12:07:12 6 | ************************************************************************/ 7 | 8 | #pragma GCC optimize(3) 9 | #include 10 | #define MAXN 100005 11 | #define INF 1000000000 12 | #define MOD 1000000007 13 | #define F first 14 | #define S second 15 | using namespace std; 16 | typedef long long ll; 17 | typedef pair P; 18 | ll c,n; 19 | int main() 20 | { 21 | scanf("%lld%lld",&c,&n); 22 | if(c>n) {puts("-1"); return 0;} 23 | if(n/c==1) {printf("%lld\n",c*c); return 0;} 24 | ll ans=c*c*(n/c)*(n/c-1); 25 | printf("%lld\n",ans); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /2018牛客网暑期ACM多校训练营(第五场)/J.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int manx = 1e5+100; 4 | typedef long long LL; 5 | LL p2,p3; 6 | LL n; 7 | int main(){ 8 | cin>>n>>p2>>p3; 9 | if (n<=2){ 10 | cout< 2 | using namespace std; 3 | 4 | int main() { 5 | int T; cin >> T; 6 | while (T--) { 7 | int n; cin >> n; 8 | while (n % 2 == 0) n /= 2; 9 | while (n % 5 == 0) n /= 5; 10 | if (n == 1) puts("No"); else puts("Yes"); 11 | } 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /2019 China Collegiate Programming Contest, Qinhuangdao Site/K.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 1000005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int T,n; 11 | int p[MAXN]; 12 | int sons[MAXN],len[MAXN]; 13 | vector G[MAXN]; 14 | void dfs(int v,int d) 15 | { 16 | if(sons[v]>=2) d=0; 17 | len[v]=d; 18 | for(auto to:G[v]) dfs(to,d+1); 19 | } 20 | int main() 21 | { 22 | scanf("%d",&T); 23 | while(T--) 24 | { 25 | scanf("%d",&n); 26 | for(int i=1;i<=n;i++) p[i]=sons[i]=0,G[i].clear(); 27 | for(int i=2;i<=n;i++) 28 | { 29 | scanf("%d",&p[i]); 30 | sons[p[i]]++; 31 | G[p[i]].push_back(i); 32 | } 33 | dfs(1,1); 34 | bool f=false; 35 | for(int i=1;i<=n;i++) if(!sons[i]&&(len[i]&1)) f=true; 36 | if(f) puts("Takeru"); else puts("Meiya"); 37 | } 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /2019 ICPC Asia Hong Kong Onsite/B.py: -------------------------------------------------------------------------------- 1 | for _ in range(int(input())) : 2 | n = int(input()) 3 | for _ in range(n - 1) : 4 | input() 5 | print('Alice' if n & 1 else 'Bob') -------------------------------------------------------------------------------- /2019 ICPC Asia Hong Kong Onsite/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int T,k,X; 11 | ll p[MAXN],sum[MAXN]; 12 | string get_str(int base,int X) 13 | { 14 | string t=""; 15 | int now; 16 | p[0]=1; sum[0]=0; 17 | for(int i=1;i<=30;i++) p[i]=p[i-1]*base,sum[i]=sum[i-1]+p[i]; 18 | for(now=1;sum[now]=1;now--) 21 | { 22 | int cur; 23 | if(f) cur=(X-sum[now-1]+p[now-1]-1)/p[now-1]; else cur=(X+p[now-1]-1)/p[now-1]; 24 | t+=(char)'0'+(10-base)+(cur-1); 25 | if(f) {X-=sum[now-1]; f=false;} 26 | X-=1LL*(cur-1)*p[now-1]; 27 | } 28 | return t; 29 | } 30 | int main() 31 | { 32 | scanf("%d",&T); 33 | while(T--) 34 | { 35 | int k,X; 36 | scanf("%d%d",&k,&X); 37 | cout< 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | bool isprime(int x) 11 | { 12 | if(x==1) return true; 13 | for(int i=2;i*i<=x;i++) if(x%i==0) return false; 14 | return true; 15 | } 16 | int t,l,r; 17 | int main() 18 | { 19 | scanf("%d",&t); 20 | while(t--) 21 | { 22 | scanf("%d%d",&l,&r); 23 | if(r-l+1>=10000) puts("Yes"); 24 | else 25 | { 26 | int x=0; 27 | for(int i=l;i<=r;i++) if(isprime(i)) x++; 28 | if(3*x 2 | #define MAXN 1005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int n,a[MAXN][MAXN]; 11 | int main() 12 | { 13 | scanf("%d",&n); 14 | for(int i=1;i<=n;i++) 15 | for(int j=1;j<=n;j++) 16 | scanf("%d",&a[i][j]); 17 | for(int i=1;i<=n;i++) 18 | for(int j=1;j<=n;j++) 19 | { 20 | if(a[i][j]==-1) 21 | { 22 | printf("%d\n",a[1][j]-a[1][1]+a[i][1]); 23 | return 0; 24 | } 25 | } 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /2019 ICPC Asia Yinchuan Onsite/N.py: -------------------------------------------------------------------------------- 1 | print '1 1 2 3 5' -------------------------------------------------------------------------------- /2019 ICPC Asia Yinchuan Onsite/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/2019 ICPC Asia Yinchuan Onsite/statements.pdf -------------------------------------------------------------------------------- /2019 Multi-University Training Contest 1/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int n,l[MAXN],s[MAXN],v[MAXN]; 11 | double t1[MAXN],t2[MAXN]; 12 | double solve(int cur,int to) 13 | { 14 | if(cur==n) return (double)(to+s[cur])/v[cur]; 15 | return max((double)(to+s[cur])/v[cur],solve(cur+1,to+l[cur+1])); 16 | } 17 | int main() 18 | { 19 | while(scanf("%d",&n)==1) 20 | { 21 | for(int i=0;i<=n;i++) scanf("%d",&l[i]); 22 | for(int i=0;i<=n;i++) scanf("%d",&s[i]); 23 | for(int i=0;i<=n;i++) scanf("%d",&v[i]); 24 | printf("%.10f\n",solve(0,0)); 25 | } 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /2019 Multi-University Training Contest 2/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | ll mod = 998244353; 5 | ll power(ll x,ll y){ 6 | ll res = 1; 7 | while (y){ 8 | if (y & 1){ 9 | res = res * x % mod; 10 | } 11 | y >>= 1; 12 | x = x * x % mod; 13 | } 14 | return res; 15 | } 16 | const int maxn = 3005; 17 | ll ans[maxn]; 18 | int main(){ 19 | ll n; 20 | ll inv_3 = power(3ll,mod-2); 21 | for (int i=1;i>n){ 31 | cout< 2 | using namespace std; 3 | typedef long long ll; 4 | const ll mod = 1e6 + 3; 5 | const int maxn = mod + 5; 6 | int fac[maxn]; 7 | int main(){ 8 | fac[0] = 1; 9 | for (int i=1;i>n){ 14 | if (n >= mod){ 15 | cout<<0< 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int n,k; 11 | int main() 12 | { 13 | return 0; 14 | } -------------------------------------------------------------------------------- /2019 Multi-University Training Contest 4/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 200005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int T,N; 11 | int main() 12 | { 13 | scanf("%d",&T); 14 | while(T--) 15 | { 16 | scanf("%d",&N); 17 | bool f=true; 18 | if(__builtin_popcount(N+1)==1) 19 | { 20 | puts("1"); 21 | f=false; 22 | } 23 | else puts("0"); 24 | for(int i=2;i<=N;i++) 25 | { 26 | if(!f&&(i==N)) printf("1"); 27 | else 28 | { 29 | for(int j=0;;j++) 30 | { 31 | if(!((i>>j)&1)) 32 | { 33 | printf("%d",(1< 2 | #define MAXN 100005 3 | #define INF 8000000000000000000LL 4 | #define MOD 998244353 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int T,N,x,y; 11 | void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;} 12 | int dp[MAXN]; 13 | int main() 14 | { 15 | dp[0]=dp[1]=dp[2]=1; 16 | for(int i=3;i<=100000;i++) 17 | { 18 | dp[i]=dp[i-1]; 19 | add(dp[i],dp[i-3]); 20 | } 21 | scanf("%d",&T); 22 | while(T--) 23 | { 24 | scanf("%d%d%d",&N,&x,&y); 25 | int dif=y-x; 26 | if(x!=1) dif--; 27 | if(y!=N) dif--; 28 | printf("%d\n",dp[dif]); 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /2019 Multi-University Training Contest 6/H.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 400005 3 | #define INF 1000000000000000005LL 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int T,m; 11 | ll k; 12 | int main() 13 | { 14 | scanf("%d",&T); 15 | while(T--) 16 | { 17 | scanf("%lld%d",&k,&m); 18 | ll ans=INF; 19 | for(ll delta=1;delta<=1000;delta++) 20 | { 21 | ll n=k^delta,cur=n; 22 | int cnt=0; 23 | while(cntn+delta) break; 27 | if(__gcd(cur,n)==1) cnt++; 28 | } 29 | if(cur==n+delta) ans=min(ans,n); 30 | } 31 | if(ans==INF) puts("-1"); else printf("%lld\n",ans); 32 | } 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /2019-2020 ACM-ICPC Latin American Regional Programming Contest/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | string str; 11 | int n,k; 12 | ll ans; 13 | int main() 14 | { 15 | cin>>str; 16 | scanf("%d",&k); 17 | n=(int)str.size(); 18 | ans=1LL*n*min(k,n); 19 | if(k>=n) ans-=(n-1); 20 | int pos=-1; 21 | for(int i=0;i=k) ans-=1LL*(2*cnt-k+1)*k/2; 34 | else ans-=1LL*(cnt+1)*cnt/2; 35 | cnt=0; 36 | } 37 | } 38 | if(cnt>=k) ans-=1LL*(2*cnt-k+1)*(k)/2; 39 | else ans-=1LL*(cnt+1)*cnt/2; 40 | printf("%lld\n",ans); 41 | } 42 | -------------------------------------------------------------------------------- /2019-2020 ACM-ICPC Latin American Regional Programming Contest/K.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 10005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int N; 11 | string str; 12 | vector v; 13 | void mult(int val) 14 | { 15 | int sz=(int)v.size(); 16 | v.resize(sz+1); v[sz]=0; 17 | for(int i=sz;i>=0;i--) 18 | { 19 | v[i]=v[i]*val; 20 | if(i!=0) v[i]-=v[i-1]; 21 | } 22 | } 23 | int main() 24 | { 25 | cin>>str; 26 | N=(int)str.size(); 27 | v.push_back(1); 28 | for(int i=1;i=0;i--) if(str[0]=='A') printf("%lld%c",-v[i],i==0?'\n':' '); else printf("%lld%c",v[i],i==0?'\n':' '); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /2019-2020 ACM-ICPC Latin American Regional Programming Contest/M.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 1005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | int N,X,a[MAXN]; 9 | int main() 10 | { 11 | scanf("%d%d",&N,&X); 12 | for(int i=1;i<=N;i++) scanf("%d",&a[i]); 13 | int ans=0,cnt=0; 14 | for(int i=1;i<=N;i++) 15 | { 16 | if(i==1||a[i]-a[i-1]<=X) cnt++; 17 | else cnt=1; 18 | ans=max(ans,cnt); 19 | } 20 | printf("%d\n",ans); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /2019-2020 ACM-ICPC Latin American Regional Programming Contest/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/2019-2020 ACM-ICPC Latin American Regional Programming Contest/statements.pdf -------------------------------------------------------------------------------- /2019-2020 ICPC Southeastern European Regional Programming Contest (SEERC 2019)/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int n; 16 | vector adj[100005]; 17 | 18 | int dfs(int u, int p) { 19 | int cur = 0; 20 | for (int v : adj[u]) if (v != p) cur += dfs(v, u); 21 | return abs(cur - 1); 22 | } 23 | 24 | int main() { 25 | scanf("%d", &n); 26 | rep (i, n - 1) { 27 | int u, v; scanf("%d%d", &u, &v); 28 | adj[u].push_back(v); 29 | adj[v].push_back(u); 30 | } 31 | if (dfs(1, 0)) { 32 | puts("Alice"); 33 | } else { 34 | puts("Bob"); 35 | } 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /2019-2020 ICPC Southeastern European Regional Programming Contest (SEERC 2019)/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 1005 3 | #define INF 2000000001 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int n,a[MAXN],b[MAXN]; 11 | int main() 12 | { 13 | scanf("%d",&n); 14 | for(int i=1;i<=n;i++) scanf("%d",&a[i]); 15 | for(int i=1;i<=n;i++) scanf("%d",&b[i]); 16 | int ans=0; 17 | for(int i=1;i<=n;i++) 18 | { 19 | int res=INF; 20 | for(int j=1;j<=n;j++) res=min(res,max(a[i]-b[j],b[j]-a[i])); 21 | ans=max(ans,res); 22 | } 23 | printf("%d\n",ans); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /2019-2020 ICPC Southeastern European Regional Programming Contest (SEERC 2019)/J.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int n; 16 | LL adj[1024][1024]; 17 | 18 | int main() { 19 | scanf("%d", &n); 20 | Rep (i, n * (n - 1) / 2) { 21 | int u, v, w; scanf("%d%d%d", &u, &v, &w); 22 | adj[u][v] = adj[v][u] = w; 23 | } 24 | LL ans = 0; 25 | Rep (i, n) { 26 | vector val; 27 | Rep (j, n) if (i != j) val.push_back(adj[i][j]); 28 | sort(range(val)); 29 | for (int i = 0; i < val.size(); i += 2) ans += val[i+1]; 30 | } 31 | cout << ans << endl; 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /2019-2020 ICPC Southeastern European Regional Programming Contest (SEERC 2019)/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/2019-2020 ICPC Southeastern European Regional Programming Contest (SEERC 2019)/statements.pdf -------------------------------------------------------------------------------- /2019-2020 ICPC, Asia Jakarta Regional Contest/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int n; 16 | 17 | int main() { 18 | scanf("%d", &n); 19 | rep (i, n) { 20 | int x; scanf("%d", &x); 21 | printf("%d ", ((x - 1) + n / 2) % n + 1); 22 | } 23 | puts(""); 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /2019-2020 ICPC, Asia Jakarta Regional Contest/H.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int n; 16 | pair a[100005]; 17 | ULL ans = 0; 18 | 19 | int main() { 20 | scanf("%d", &n); 21 | rep (i, n) { 22 | ULL x, y; scanf("%llu%llu", &x, &y); 23 | ans = max(ans, x * y * 5); 24 | if (x < y) swap(x, y); 25 | a[i] = make_pair(x, y); 26 | } 27 | sort(a, a + n, greater<>()); 28 | ULL maxb = 0; 29 | rep (i, n) { 30 | ans = max(ans, a[i].first * min(maxb, a[i].second) * 10); 31 | maxb = max(maxb, a[i].second); 32 | } 33 | cout << ans / 10 << '.' << ans % 10 << endl; 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /2019-2020 ICPC, Asia Jakarta Regional Contest/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/2019-2020 ICPC, Asia Jakarta Regional Contest/statements.pdf -------------------------------------------------------------------------------- /2019-2020 ICPC, NERC, Northern Eurasia Finals/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 300005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | string str; 11 | int n; 12 | int main() 13 | { 14 | cin>>str; 15 | n=(int)str.size(); 16 | int l=0,r=n-1; 17 | while(l<=r) 18 | { 19 | if(str[l]!=str[r]) {puts("0"); return 0;} 20 | int cnt=0; 21 | char ch=str[l]; 22 | while(r>l&&str[r]==ch) {cnt++; r--;} 23 | while(r>l&&str[l]==ch) {cnt++; l++;} 24 | if(l==r&&str[l]==ch) 25 | { 26 | if(cnt==0) puts("0"); 27 | else printf("%d\n",cnt+2); 28 | return 0; 29 | } 30 | else if(cnt<3) {puts("0"); return 0;} 31 | } 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /2019-2020 ICPC, NERC, Northern Eurasia Finals/L.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int n, l, k, ptr; 16 | char str[1 << 20]; 17 | string ans[1 << 10]; 18 | 19 | int main() { 20 | scanf("%d%d%d", &n, &l, &k); 21 | scanf("%s", str); sort(str, str + n * l); 22 | int left = 0, right = k - 1; 23 | rep (i, l) { 24 | for (int j = left; j <= right; j++) ans[j].push_back(str[ptr++]); 25 | while (ans[left].back() != ans[right].back()) left++; 26 | } 27 | rep (i, n) while (ans[i].size() < l) ans[i].push_back(str[ptr++]); 28 | rep (i, n) puts(ans[i].c_str()); 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /2019-2020 ICPC, NERC, Northern Eurasia Finals/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/2019-2020 ICPC, NERC, Northern Eurasia Finals/statements.pdf -------------------------------------------------------------------------------- /2019-2020 XX Open Cup, Grand Prix of Korea/K.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/2019-2020 XX Open Cup, Grand Prix of Korea/K.cpp -------------------------------------------------------------------------------- /2019-2020 XX Open Cup, Grand Prix of Korea/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/2019-2020 XX Open Cup, Grand Prix of Korea/statements.pdf -------------------------------------------------------------------------------- /2019牛客暑期多校训练营(第一场)/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 4005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;} 11 | int n,m; 12 | int dp[MAXN][MAXN]; 13 | int main() 14 | { 15 | while(scanf("%d%d",&n,&m)==2) 16 | { 17 | for(int i=0;i<=2*(n+m);i++) 18 | for(int j=0;j<=2*(n+m);j++) 19 | dp[i][j]=0; 20 | dp[0][n+m]=1; 21 | for(int i=0;i<2*(n+m);i++) 22 | for(int j=0;j<=2*(n+m);j++) 23 | { 24 | if(!dp[i][j]) continue; 25 | int shift=j-(n+m); 26 | if(shift-m) add(dp[i+1][j-1],dp[i][j]); 28 | } 29 | printf("%d\n",dp[2*(n+m)][n+m]); 30 | } 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /2019牛客暑期多校训练营(第一场)/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int x1, y1, x2, y2, x3, y3; 6 | while (~scanf("%d%d%d%d%d%d", &x1, &y1, &x2, &y2, &x3, &y3)) { 7 | x2 -= x1; x3 -= x1; 8 | y2 -= y1; y3 -= y1; 9 | long long area = abs(1LL*x2 * y3 - 1LL*y2 * x3); 10 | printf("%lld\n", 11 * area); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /2019牛客暑期多校训练营(第一场)/I: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/2019牛客暑期多校训练营(第一场)/I -------------------------------------------------------------------------------- /2019牛客暑期多校训练营(第一场)/J.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef __int128 i128; 4 | int main() { 5 | long long x, y, a, b; 6 | while (~scanf("%lld%lld%lld%lld", &x, &a, &y, &b)) { 7 | i128 v1 = i128(x) * b, v2 = i128(y) * a; 8 | if (v1 == v2) puts("="); 9 | if (v1 < v2) puts("<"); 10 | if (v1 > v2) puts(">"); 11 | } 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /2019牛客暑期多校训练营(第七场)/B.py: -------------------------------------------------------------------------------- 1 | for _ in range(int(input())) : 2 | n = int(input()) 3 | s = list(map(int, input().split())) 4 | if n >= 3 : 5 | print('No') 6 | continue 7 | if n <= 1 : 8 | print('Yes') 9 | continue 10 | d = s[1] * s[1] - 4 * s[0] * s[2] 11 | print('Yes' if d < 0 else 'No') 12 | -------------------------------------------------------------------------------- /2019牛客暑期多校训练营(第七场)/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 1000005 3 | #define INF 1000000000 4 | using namespace std; 5 | int n,p; 6 | int main() 7 | { 8 | scanf("%d%d",&n,&p); 9 | int cnt=0,tmp=p; 10 | while(tmp) 11 | { 12 | cnt++; 13 | tmp/=10; 14 | } 15 | if(cnt>n) puts("T_T"); else 16 | { 17 | printf("%d",p); 18 | for(int i=0;i 2 | #define left jlkdasfjklajdf 3 | using namespace std; 4 | const int maxn = 1e5 + 100; 5 | char s[maxn]; 6 | map left; 7 | int n; 8 | int main(){ 9 | cin>>n; 10 | cin>>s+1; 11 | int cnt0 = 0,cnt1 = 0; 12 | for (int i=1;i<=n;i++){ 13 | if (s[i] == '0'){ 14 | cnt0 ++; 15 | }else{ 16 | cnt1 ++; 17 | } 18 | } 19 | int ans2 = 2 * min(cnt0,cnt1); 20 | int sum = 0; 21 | left[sum] = 0; 22 | int ans1 = 0; 23 | for (int i=1;i<=n;i++){ 24 | if (s[i] == '0'){ 25 | sum --; 26 | }else{ 27 | sum ++; 28 | } 29 | if (left.find(sum) != left.end()){ 30 | int pre = left[sum]; 31 | ans1 = max(ans1,i - pre); 32 | }else{ 33 | left[sum] = i; 34 | } 35 | 36 | } 37 | cout< 2 | #define MAXN 1005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int T; 11 | int n,m; 12 | int pow_mod(int a,int i) 13 | { 14 | int s=1; 15 | while(i) 16 | { 17 | if(i&1) s=1LL*s*a%MOD; 18 | a=1LL*a*a%MOD; 19 | i>>=1; 20 | } 21 | return s; 22 | } 23 | int main() 24 | { 25 | scanf("%d",&T); 26 | int last=1; 27 | while(T--) 28 | { 29 | scanf("%d%d",&n,&m); 30 | if(n==1) printf("%d\n",last); 31 | else 32 | { 33 | int res; 34 | if(m==0) res=0; else res=pow_mod(n-1,MOD-2); 35 | last=1LL*last*res%MOD; 36 | printf("%d\n",last); 37 | } 38 | } 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /2019牛客暑期多校训练营(第五场)/A.py: -------------------------------------------------------------------------------- 1 | import random as r 2 | 3 | for _ in range(int(input())) : 4 | n = int(input()) 5 | while True : 6 | x = n * r.randint(1, 10**100) 7 | ans = 0 8 | for d in str(x) : 9 | ans += ord(d) - ord('0') 10 | if ans % n == 0 : 11 | print(x) 12 | break 13 | -------------------------------------------------------------------------------- /2019牛客暑期多校训练营(第八场)/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int n; 16 | int m[2048][2048]; 17 | 18 | void make(int i, int j, int n) { 19 | if (n == 1) { 20 | m[i][j] = 1; 21 | return; 22 | } 23 | make(i, j, n / 2); 24 | make(i + n / 2, j, n / 2); 25 | make(i, j + n / 2, n / 2); 26 | make(i + n / 2, j + n / 2, n / 2); 27 | for (int x = i + n / 2; x < i + n; x++) 28 | for (int y = j + n / 2; y < j + n; y++) 29 | m[x][y] = -m[x][y]; 30 | } 31 | 32 | int main() { 33 | cin >> n; 34 | make(0, 0, n); 35 | rep (i, n) { 36 | rep (j, n) printf("%d ", m[i][j]); 37 | puts(""); 38 | } 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /2019牛客暑期多校训练营(第八场)/G.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int cnt = 0; 16 | vector seq; 17 | 18 | void enter(char ch) { 19 | seq.push_back(ch); 20 | if (seq.size() < 3) return; 21 | auto it = seq.rbegin(); 22 | if (it[0] == it[1] and it[1] == it[2]) { 23 | cnt++; 24 | seq.pop_back(); 25 | seq.pop_back(); 26 | seq.pop_back(); 27 | } 28 | } 29 | 30 | int main() { 31 | string str; 32 | cin >> str; 33 | for (char ch : str) enter(ch); 34 | cout << cnt << endl; 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /2019牛客暑期多校训练营(第六场)/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 2005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int T,n; 11 | string str; 12 | string tt; 13 | int main() 14 | { 15 | scanf("%d",&T); 16 | for(int t=1;t<=T;t++) 17 | { 18 | cin>>str; 19 | n=(int)str.size(); 20 | cin>>tt; 21 | int d=0,w=0,h=0; 22 | for(int i=0;i=n) puts("Harmful"); 30 | else if(10*h<=n) puts("Recyclable"); 31 | else if(w*2<=d) puts("Dry"); else puts("Wet"); 32 | } 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /2019牛客暑期多校训练营(第六场)/C.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/2019牛客暑期多校训练营(第六场)/C.cpp -------------------------------------------------------------------------------- /2019牛客暑期多校训练营(第四场)/I.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/2019牛客暑期多校训练营(第四场)/I.cpp -------------------------------------------------------------------------------- /2019牛客暑期多校训练营(第四场)/K.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 1e5 + 100; 4 | char s[maxn]; 5 | int sum[maxn]; 6 | int cnt[maxn][3]; 7 | int main(){ 8 | scanf("%s",s+1); 9 | int n = strlen(s+1); 10 | cnt[0][0] = 1; 11 | for (int i=1;i<=n;i++){ 12 | sum[i] = sum[i-1] + s[i] - '0'; 13 | sum[i] %= 3; 14 | for (int j=0;j<3;j++){ 15 | cnt[i][j] = cnt[i-1][j]; 16 | } 17 | cnt[i][sum[i]] ++; 18 | } 19 | long long ans = 0; 20 | //0 21 | for (int i=1;i<=n;i++){ 22 | if (s[i] == '0')ans ++; 23 | } 24 | //00 25 | for (int i=2;i<=n;i++){ 26 | if (s[i] == '0' && s[i-1] == '0')ans ++; 27 | } 28 | // x00 29 | for (int i=3;i<=n;i++){ 30 | if (s[i] == '0' && s[i-1] == '0'){ 31 | int sm = sum[i-2]; 32 | ans += cnt[i-3][sm]; 33 | } 34 | } 35 | cout< 2 | using namespace std; 3 | 4 | typedef long long LL; 5 | 6 | int main() { 7 | LL T, n; cin >> T; 8 | while (T--) { 9 | cin >> n; 10 | cout << n-1 << endl; 11 | } 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /ACM-ICPC 2018 徐州赛区网络预赛/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #ifdef __LOCAL_DEBUG__ 5 | # define _debug(fmt, ...) fprintf(stderr, "\033[94m%s: " fmt "\n\033[0m", \ 6 | __func__, ##__VA_ARGS__) 7 | #else 8 | # define _debug(...) ((void) 0) 9 | #endif 10 | #define rep(i, n) for (int i=0; i<(n); i++) 11 | #define Rep(i, n) for (int i=1; i<=(n); i++) 12 | #define range(x) (x).begin(), (x).end() 13 | typedef long long LL; 14 | typedef unsigned long long ULL; 15 | 16 | int n; 17 | char src[1000005], buf[2000005]; 18 | char* ptr; 19 | 20 | int main() { 21 | int T; scanf("%d", &T); 22 | while (T--) { 23 | char ch; 24 | scanf("%d %c%s", &n, &ch, src); 25 | ptr = buf; 26 | for (int i = 0; src[i]; i++) { 27 | int cur = abs(src[i] - ch); 28 | *ptr = cur / 10 + '0'; ptr++; 29 | *ptr = cur % 10 + '0'; ptr++; 30 | } 31 | char* beg = buf; 32 | while (*beg == '0') beg++; 33 | //printf("%s\n", buf); 34 | printf("%d\n", max(1, int(ptr - beg))); 35 | } 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /ACM-ICPC 2018 沈阳赛区网络预赛/K.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | vector sheet = {1,2,3,5,7,11,13,17,23,31,37,53,71,73,113,131,137,173,311,317}; 4 | char N[105]; 5 | int main(){ 6 | int T; 7 | scanf("%d",&T); 8 | int Case=1; 9 | while (T--){ 10 | scanf("%s",N); 11 | printf("Case #%d: ",Case++); 12 | if (strlen(N) > 3){ 13 | puts("317"); 14 | }else{ 15 | int n = atoi(N); 16 | int ans =1; 17 | for (int i=0;i 2 | using namespace std; 3 | 4 | int main() { 5 | int T; cin >> T; 6 | while (T--) { 7 | string str; cin >> str; 8 | for (char& ch : str) ch = tolower(ch); 9 | if (str == "jessie") cout << "Good guy!" << endl; 10 | else cout << "Dare you say that again?" << endl; 11 | } 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /ACM-ICPC 2018 焦作赛区网络预赛/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() { 5 | int a, b, c; 6 | while (cin >> a >> b >> c) { 7 | if ((a & 1) and (b & 1) and (c & 1)) { 8 | cout << "No" << endl; 9 | } else { 10 | cout << "Yes" << endl; 11 | } 12 | } 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /ACM-ICPC 2018 青岛赛区网络预赛/A.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: A.cpp 3 | > Author: Roundgod 4 | > Mail: wcysai@foxmail.com 5 | > Created Time: 2018-09-16 12:05:59 6 | ************************************************************************/ 7 | 8 | #pragma GCC optimize(3) 9 | #include 10 | #define MAXN 100005 11 | #define INF 1000000000 12 | #define MOD 1000000007 13 | #define F first 14 | #define S second 15 | using namespace std; 16 | typedef long long ll; 17 | typedef pair P; 18 | int T,n,m; 19 | int main() 20 | { 21 | scanf("%d",&T); 22 | while(T--) 23 | { 24 | scanf("%d%d",&n,&m); 25 | if(n==m) printf("%d %d\n",n,n); 26 | else if(m==0) printf("%d %d\n",0,0); 27 | else printf("%d %d\n",m,(m-1)/(n-m+1)+1); 28 | } 29 | return 0; 30 | } 31 | 32 | -------------------------------------------------------------------------------- /ACM-ICPC 2018 青岛赛区网络预赛/K.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | 13 | int main() { 14 | int T; scanf("%d", &T); 15 | while (T--) { 16 | int n; scanf("%d", &n); 17 | map mp; 18 | while (n--) { 19 | int a; scanf("%d", &a); 20 | mp[__builtin_clz(a)]++; 21 | } 22 | int ans = 0; 23 | for (auto& p : mp) ans = max(ans, p.second); 24 | printf("%d\n", ans); 25 | } 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /ACM-ICPC 2019 上海赛区网络预赛/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 305 3 | #define MAXM 150005 4 | #define INF 1000000000 5 | #define MOD 1000000007 6 | #define F first 7 | #define S second 8 | using namespace std; 9 | typedef long long ll; 10 | typedef pair P; 11 | int T,N,M; 12 | vector v; 13 | int main() 14 | { 15 | scanf("%d",&T); 16 | for(int tot=1;tot<=T;tot++) 17 | { 18 | scanf("%d%d",&N,&M); 19 | v.clear(); 20 | for(int i=0;i()); 27 | int state=0,ans=0; 28 | for(int i=0;i<(int)v.size();i++) 29 | { 30 | if(!state) ans+=v[i]; 31 | else ans-=v[i]; 32 | state=!state; 33 | } 34 | printf("Case #%d: %d\n",tot,ans); 35 | } 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /ACM-ICPC 2019 上海赛区网络预赛/L.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 1000005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int T,N,b; 11 | int sum[MAXN][11]; 12 | vector v; 13 | int main() 14 | { 15 | // memset(sum,0,sizeof(sum)); 16 | for(int i=1;i<=1000000;i++) 17 | { 18 | for(int b=2;b<=10;b++) 19 | { 20 | sum[i][b]=sum[i-1][b]; 21 | int tmp=i; 22 | while(tmp) sum[i][b]+=tmp%b,tmp/=b; 23 | } 24 | } 25 | scanf("%d",&T); 26 | for(int tot=1;tot<=T;tot++) 27 | { 28 | scanf("%d%d",&N,&b); 29 | printf("Case #%d: %d\n",tot,sum[N][b]); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /ACM-ICPC 2019 南京赛区网络预赛/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 1000005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int N,y; 11 | vector t; 12 | vector can[MAXN]; 13 | int main() 14 | { 15 | while(scanf("%d%d",&N,&y)==2) 16 | { 17 | t.clear(); 18 | for(int i=0;i=max(0,N-cnt);j--) mx=max(mx,t[j]+(N-j)*i); 30 | if(N-cnt>0) mx=max(mx,t[N-cnt-1]+y); 31 | printf("%d%c",mx,i==y?'\n':' '); 32 | } 33 | } 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /ACM-ICPC 2019 南昌赛区网络预赛/G.py: -------------------------------------------------------------------------------- 1 | for _ in range(input()) : 2 | print [0, 18000][input() == 1] 3 | -------------------------------------------------------------------------------- /ACM-ICPC 2019 徐州赛区网络预赛/A.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python2 2 | from fractions import gcd 3 | def modinv(q,m): 4 | if q==0: 5 | return 0 6 | a1,b1,a2,b2=m,0,q,1 7 | while a2!=1: 8 | t=a1/a2 9 | a1,a2,b1,b2=a2,a1-t*a2,b2,b1-t*b2%m 10 | if b2<0: 11 | b2+=m 12 | return b2 13 | 14 | def merge(a,b,c,d): 15 | c-=a 16 | dd=gcd(b,d) 17 | if c%dd!=0: 18 | return -1 19 | b,c,d=b/dd,c/dd,d/dd 20 | t=c*modinv(b,d)%d 21 | if t<0: 22 | t+=d 23 | return b*t*dd+a 24 | 25 | def CRT(d): 26 | r,x=1,0 27 | for p in d: 28 | if x!=-1: 29 | x=merge(x,r,p[1],p[0]) 30 | r=r/gcd(r,p[0])*p[0] 31 | return x 32 | 33 | n = input() 34 | d=[] 35 | 36 | for i in xrange(n): 37 | d.append(map(int,raw_input().split())) 38 | 39 | x=CRT(d) 40 | 41 | fib = [0, 1] 42 | for _ in range(100) : 43 | fib.append(fib[-1] + fib[-2]) 44 | 45 | if x==-1: 46 | print "Tankernb!" 47 | elif x not in fib: 48 | print "Zgxnb!" 49 | else: 50 | print 'Lbnb!' 51 | -------------------------------------------------------------------------------- /ACM-ICPC 2019 徐州赛区网络预赛/C.py: -------------------------------------------------------------------------------- 1 | x = input() 2 | print ['NO', 'YES'][x > 2 and x % 2 == 0] 3 | -------------------------------------------------------------------------------- /ACM-ICPC 2019 徐州赛区网络预赛/K.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int n; 16 | int x[1024], y[1024]; 17 | map mp; 18 | 19 | ULL encode(int x, int y) { 20 | union { 21 | struct { int xx, yy; }; 22 | LL ret; 23 | } s; 24 | s.xx = x; s.yy = y; 25 | return s.ret; 26 | } 27 | 28 | int main() { 29 | scanf("%d", &n); 30 | rep (i, n) scanf("%d%d", x + i, y + i); 31 | rep (i, n) rep (j, i) mp[encode(x[i] + x[j], y[i] + y[j])] += 2; 32 | rep (i, n) mp[encode(x[i] * 2, y[i] * 2)] ++; 33 | int ans = INT_MAX; 34 | for (auto p : mp) ans = min(ans, n - p.second); 35 | cout << ans << endl; 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /ACM-ICPC 2019 沈阳赛区网络预赛/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | const ll inf = 0x3f3f3f3f3f3f3f3fll; 5 | const int maxn = 1e3 + 100; 6 | const int maxm = 1e4 + 100; 7 | int n,m; 8 | int p[maxn]; 9 | int c[maxn]; 10 | ll dp[maxm]; 11 | void solve(){ 12 | for (int i=1;i<=n;i++){ 13 | scanf("%d%d",p+i,c+i); 14 | } 15 | for (int i=1;i=m;i--){ 24 | if (dp[i] < dp[b]){ 25 | b = i; 26 | } 27 | } 28 | cout< 2 | #define MAXN 5000005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int T,n,m; 11 | int main() 12 | { 13 | scanf("%d",&T); 14 | for(int tot=1;tot<=T;tot++) 15 | { 16 | scanf("%d%d",&n,&m); 17 | printf("Case #%d: ",tot); 18 | if(n==1) printf("%.6f ",1.0); else printf("%.6f ",0.5); 19 | printf("%.6f\n",(0.5+0.5*m)/m); 20 | } 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /Asia-Tsukuba 2017/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int n; 16 | LL t; 17 | LL h[100005]; 18 | LL psum[100005], pmax[100005]; 19 | 20 | int main() { 21 | scanf("%d%lld", &n, &t); 22 | rep (i, n) scanf("%lld", h + i); 23 | partial_sum(h, h + n, psum); 24 | partial_sum(h, h + n, pmax, [] (LL a, LL b) -> LL { return max(a, b); }); 25 | rep (i, n) { 26 | LL done = 1; 27 | LL cur = t - psum[i]; 28 | if (cur >= 0) { 29 | done += cur / pmax[i] + 1; 30 | } 31 | printf("%lld\n", done); 32 | } 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /Asia-Tsukuba 2017/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 200005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define x first 6 | #define y second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int n; 11 | P a[MAXN]; 12 | int s[MAXN],s1[MAXN],s2[MAXN]; 13 | int ans1,ans2; 14 | int main() 15 | { 16 | scanf("%d",&n); 17 | for(int i=1;i<=n;i++) scanf("%d%d",&a[i].x,&a[i].y); 18 | for(int i=1;i<=n;i++) {s[a[i].x]++; s[a[i].y]--;} 19 | for(int i=1;i<=100000;i++) 20 | { 21 | s[i]+=s[i-1]; 22 | ans2=max(ans2,s[i]); 23 | } 24 | for(int i=1;i<=n;i++) 25 | { 26 | s1[a[i].x]++; 27 | s2[a[i].y-1]++; 28 | } 29 | for(int i=1;i<=100000;i++) s2[i]+=s2[i-1]; 30 | for(int i=100000;i>=1;i--) s1[i]+=s1[i+1]; 31 | for(int i=1;i<=n;i++) 32 | { 33 | int cur=n-s2[a[i].x-1]-s1[a[i].y]; 34 | ans1=max(ans1,cur); 35 | } 36 | printf("%d %d\n",ans1,ans2); 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /Asia-Tsukuba 2017/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Asia-Tsukuba 2017/statements.pdf -------------------------------------------------------------------------------- /BAPC 2018/A.py: -------------------------------------------------------------------------------- 1 | n, k = map(int, raw_input().split()) 2 | x = map(int, raw_input().split()) 3 | x.sort() 4 | i = 0 5 | for i in range(0, n - 1) : 6 | if x[i] + x[i+1] > k : 7 | print i + 1 8 | exit(0) 9 | print n 10 | -------------------------------------------------------------------------------- /BAPC 2018/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | int V; 9 | int main() 10 | { 11 | scanf("%d",&V); 12 | int ans=INF; 13 | for(int i=1;i<=V;i++) 14 | { 15 | if(V%i) continue; 16 | int S=V/i; 17 | int t=sqrt(S)+1; 18 | for(int j=t;j>=1;j--) 19 | { 20 | if(S%j) continue; 21 | ans=min(ans,2*i*j+2*j*(S/j)+2*i*(S/j)); 22 | } 23 | } 24 | printf("%d\n",ans); 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /BAPC 2018/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 2000000000LL 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | ll n,M,p[MAXN],c[MAXN]; 10 | bool check(ll x) 11 | { 12 | ll sum=0; 13 | for(int i=1;i<=n;i++) 14 | { 15 | ll earn=p[i]*x-c[i]; 16 | if(earn>0) sum+=earn; 17 | if(sum>=M) return true; 18 | } 19 | return false; 20 | } 21 | int main() 22 | { 23 | scanf("%lld%lld",&n,&M); 24 | for(int i=1;i<=n;i++) scanf("%lld%lld",&p[i],&c[i]); 25 | ll l=0,r=INF+100; 26 | while(r-l>1) 27 | { 28 | ll mid=(l+r)/2; 29 | if(check(mid)) r=mid; else l=mid; 30 | } 31 | printf("%lld\n",r); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /BAPC 2018/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/BAPC 2018/statements.pdf -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 1/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 1/statements.pdf -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 2, Div A/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 2, Div A/statements.pdf -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 2, Div B/E: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 2, Div B/E -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 2, Div B/EE: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 2, Div B/EE -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 2, Div B/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 2, Div B/a.out -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 2, Div B/gen: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 2, Div B/gen -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 3, Div A/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 3, Div A/statements.pdf -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 3, Div B/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 3, Div B/statements.pdf -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 4, Div A/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 4, Div A/statements.pdf -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 4, Div B/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 4, Div B/statements.pdf -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 5. Div B/A: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 5. Div B/A -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 5. Div B/E.cpp: -------------------------------------------------------------------------------- 1 | #pragma GCC optimize(3) 2 | #include 3 | #define MAXN 100005 4 | #define INF 1000000000 5 | #define MOD 1000000007 6 | #define F first 7 | #define S second 8 | using namespace std; 9 | typedef long long ll; 10 | typedef pair P; 11 | int n; 12 | void solve(int from,int to,int cnt) 13 | { 14 | if(cnt==1) 15 | { 16 | printf("%d %d\n",from,to); 17 | return; 18 | } 19 | int pos=6-from-to; 20 | solve(from,pos,cnt-1); 21 | printf("%d %d\n",from,to); 22 | solve(pos,to,cnt-1); 23 | } 24 | int main() 25 | { 26 | scanf("%d",&n); 27 | solve(1,2,n); 28 | return 0; 29 | } 30 | 31 | -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 5. Div B/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 5. Div B/statements.pdf -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 6, The Final Contest/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, \ 9 | ##__VA_ARGS__) 10 | #else 11 | #define _debug(...) ((void) 0) 12 | #endif 13 | typedef long long LL; 14 | typedef unsigned long long ULL; 15 | 16 | int main() { 17 | double a, b; cin >> a >> b; a = b / a - 2; 18 | a /= sqrt(15) / 2.0; 19 | cout << (LL(a) & 1) + 1 << endl; 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 7, Blitz Contest/F.py: -------------------------------------------------------------------------------- 1 | 2 | x = input() 3 | if x % 2 : 4 | print 3 * x * x - 3 * x + 1 5 | else : 6 | print 3 * x * x - 6 * x + 4 7 | -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 7, Blitz Contest/G.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, \ 9 | ##__VA_ARGS__) 10 | #else 11 | #define _debug(...) ((void) 0) 12 | #endif 13 | typedef long long LL; 14 | typedef unsigned long long ULL; 15 | 16 | bool pos, neg; 17 | int a[3]; 18 | 19 | int main() { 20 | rep (i, 3) scanf("%d", a + i); 21 | rep (i, 3) { 22 | if (a[i] > 0) pos = true; 23 | if (a[i] < 0) neg = true; 24 | a[i] = abs(a[i]); 25 | } 26 | int x = __gcd(a[0], __gcd(a[1], a[2])); 27 | if (x == 0) { 28 | cout << 0 << endl; 29 | return 0; 30 | } 31 | double ans = 0.5 / x; 32 | if (pos and neg) ans *= 2; 33 | printf("%.12f\n", ans); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 7, Blitz Contest/J.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, \ 9 | ##__VA_ARGS__) 10 | #else 11 | #define _debug(...) ((void) 0) 12 | #endif 13 | typedef long long LL; 14 | typedef unsigned long long ULL; 15 | 16 | int n; 17 | int x[100005], y[100005], dx, dy; 18 | 19 | int main() { 20 | while (scanf("%d%d%d", &n, &dx, &dy), n) { 21 | rep (i, n) scanf("%d%d", x + i, y + i); 22 | int ans = INT_MAX; 23 | rep (i, n) ans = min(ans, max(abs(dx - x[i]), abs(dy - y[i]))); 24 | printf("%d\n", ans); 25 | } 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 7, Blitz Contest/L.py: -------------------------------------------------------------------------------- 1 | def f(n) : 2 | if n == 1 : return 1 3 | if n % 2 == 0 : 4 | return 2 * f(n / 2) - 1 5 | else : 6 | return 2 * f(n / 2) + 1 7 | 8 | while True : 9 | n = input() 10 | if n == 0: break 11 | print f(n) 12 | -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 7, Blitz Contest/Q.py: -------------------------------------------------------------------------------- 1 | n = input() 2 | cnt = 0 3 | a = map(int, raw_input().split()) 4 | for i in range(1, n) : 5 | if a[i-1] >= a[i] : 6 | cnt += 1 7 | 8 | print pow(2, cnt) 9 | -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 7, Blitz Contest/R.cpp: -------------------------------------------------------------------------------- 1 | #pragma GCC optimize(3) 2 | #include 3 | #define MAXN 2000005 4 | #define INF 1000000001 5 | #define MOD 998244353 6 | using namespace std; 7 | int V,E,F; 8 | int p,q; 9 | int sum[MAXN]; 10 | set> ss = { 11 | {4,4},{6,8},{8,6},{12,20},{20,12} 12 | }; 13 | 14 | 15 | int main() 16 | { 17 | while(scanf("%d%d",&p,&q)==2) 18 | { 19 | if(!p&&!q) break; 20 | bool f=true; 21 | int s=4*p; 22 | int d=2*(p+q)-p*q; 23 | if(d<=0||s%d!=0) 24 | { 25 | f=false; 26 | puts("-1 -1 -1"); 27 | continue; 28 | } 29 | V=s/d; 30 | if(q%2==1&&V%2==1) f=false; 31 | else E=q*V/2; 32 | F=E-V+2; 33 | if(f&&ss.count(make_pair(V,F))) 34 | { 35 | printf("%d %d %d\n",V,E,F); 36 | } 37 | else puts("-1 -1 -1"); 38 | } 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 7, Blitz Contest/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/ByteDance - Moscow Workshops ICPC Programming Camp 2019. Day 7, Blitz Contest/statements.pdf -------------------------------------------------------------------------------- /CCPC 2016-2017, Finals/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int t,n,a[MAXN]; 11 | int main() 12 | { 13 | scanf("%d",&t); 14 | int kase=0; 15 | while(t--) 16 | { 17 | kase++; 18 | printf("Case #%d: ",kase); 19 | scanf("%d",&n); 20 | int sum=0; 21 | for(int i=0;i=0;i-=3) 28 | sum-=a[i]; 29 | printf("%d\n",sum); 30 | } 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /Discover Vladivostok 2019. Division A Day 1/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int n; 16 | char str[1 << 23]; 17 | bool x[1 << 23]; 18 | bool y[1 << 23]; 19 | bool dp[24][1 << 23]; 20 | 21 | int main() { 22 | scanf("%d", &n); scanf("%s", str); 23 | rep (i, n) dp[0][i] = x[i] = str[i] == '-'; 24 | Rep (d, 23) rep (i, n) { 25 | dp[d][i] = dp[d-1][i]; 26 | if (i & (1 << (d - 1))) dp[d][i] ^= dp[d-1][i - (1 << (d - 1))]; 27 | } 28 | rep (i, n) putchar(dp[23][i] ? '-' : '+'); 29 | putchar('\n'); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /Discover Vladivostok 2019. Division A Day 1/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int pos[MAXN],p[MAXN]; 11 | int n; 12 | string str; 13 | void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;} 14 | void dec(int &a,int b) {a-=b; if(a<0) a+=MOD;} 15 | int main() 16 | { 17 | p[0]=1; 18 | for(int i=1;i<=100000;i++) p[i]=2LL*p[i-1]%MOD; 19 | scanf("%d",&n); 20 | cin>>str; 21 | for(int i=0;i=1;i--) 25 | { 26 | if(pos[i]==need) continue; 27 | need=6-pos[i]-need; 28 | add(ans,p[i-1]); 29 | } 30 | printf("%d\n",ans); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /Discover Vladivostok 2019. Division A Day 1/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Discover Vladivostok 2019. Division A Day 1/statements.pdf -------------------------------------------------------------------------------- /Discover Vladivostok 2019. Division A Day 2/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int n,k; 11 | double p; 12 | int main() 13 | { 14 | freopen("stat.in","r",stdin); 15 | freopen("stat.out","w",stdout); 16 | scanf("%d%d%lf",&n,&k,&p); 17 | double prob=pow((1-p)/(2-p),k); 18 | printf("%.20lf\n",(1.0-prob)*(n-1)+1); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /Discover Vladivostok 2019. Division A Day 2/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Discover Vladivostok 2019. Division A Day 2/statements.pdf -------------------------------------------------------------------------------- /Discover Vladivostok 2019. Division A Day 3/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 1000005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef __int128_t ll; 9 | typedef pair P; 10 | int N; 11 | long long cnt[MAXN]; 12 | ll add; 13 | int main() 14 | { 15 | scanf("%d",&N); 16 | for(int i=1;i<=N;i++) 17 | { 18 | int x; 19 | long long y; 20 | scanf("%d%lld",&x,&y); 21 | if(x>1000000) 22 | { 23 | puts("No"); 24 | return 0; 25 | } 26 | cnt[x]+=y; 27 | } 28 | for(int i=1000000;i>=2;i--) 29 | { 30 | if((cnt[i]+add)%i) 31 | { 32 | puts("No"); 33 | return 0; 34 | } 35 | add+=(cnt[i]+add)/i; 36 | } 37 | puts("Yes"); 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /Discover Vladivostok 2019. Division A Day 3/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 1000005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P;; 10 | ll K; 11 | vector

v; 12 | int main() 13 | { 14 | scanf("%lld",&K); 15 | for(int i=1;;i++) 16 | { 17 | if(!K) break; 18 | int rem=K%(i+1); 19 | if(rem) v.push_back(make_pair(i,rem)); 20 | K-=rem; 21 | } 22 | for(auto p:v) printf("%d %d\n",p.F,p.S); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /Discover Vladivostok 2019. Division A Day 3/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Discover Vladivostok 2019. Division A Day 3/statements.pdf -------------------------------------------------------------------------------- /Discover Vladivostok 2019. Division A Day 4/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | const LL mod = 1'000'000'009; 16 | int n, k; 17 | 18 | // len(pref) maxdep curdep 19 | LL dp[305][305][305]; 20 | 21 | int main() { 22 | cin >> n >> k; 23 | dp[0][0][0] = 1; 24 | for (int i = 0; i <= n; i++) for (int md = 0; md <= k; md++) for (int d = 0; d <= k; d++) { 25 | LL now = (dp[i][md][d] %= mod); 26 | dp[i+1][md][d] += now; // 0 27 | if (d) dp[i+1][md][d-1] += now; // ) 28 | dp[i+1][max(md, d+1)][d+1] += now; // ( 29 | } 30 | cout << dp[n][k][0] << endl; 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /Discover Vladivostok 2019. Division A Day 4/H.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int n,s,f,ans; 11 | int main() 12 | { 13 | scanf("%d%d%d",&n,&s,&f); 14 | ans=0; 15 | if(s>f) swap(s,f); 16 | if(s==f) 17 | { 18 | if(n==1) puts("0"); else puts("-1"); 19 | return 0; 20 | } 21 | int dist=f-s; 22 | if(s!=1) {dist--; ans++;} 23 | if(f!=n) {dist--; ans++;} 24 | if(dist<=-1) {puts("-1"); return 0;} 25 | ans+=(dist/3)+dist%3; 26 | printf("%d\n",ans); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /Discover Vladivostok 2019. Division A Day 4/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Discover Vladivostok 2019. Division A Day 4/statements.pdf -------------------------------------------------------------------------------- /Helvetic Coding Contest 2018 online mirror/B1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 1e3+100; 4 | int d[maxn]; 5 | int n; 6 | inline void addEdge(int x,int y){ 7 | d[x]++; 8 | d[y]++; 9 | } 10 | int main(){ 11 | cin>>n; 12 | for (int i=0;i>u>>v; 15 | addEdge(u,v); 16 | } 17 | int ans =0; 18 | for (int i=1;i<=n;i++){ 19 | ans += (d[i]==1); 20 | } 21 | cout< 2 | using namespace std; 3 | const int maxn = 1e5+100; 4 | typedef long long LL; 5 | int a[maxn]; 6 | LL sum[maxn]; 7 | int n,p; 8 | int main(){ 9 | cin>>n>>p; 10 | for (int i=1;i<=n;i++){ 11 | scanf("%d",a+i); 12 | sum[i] = sum[i-1]+a[i]; 13 | } 14 | LL ans =0; 15 | for (int i=1;i<=n-1;i++){ 16 | LL ans1 = sum[i]%p; 17 | LL ans2 = sum[n]-ans1; 18 | ans2%=p; 19 | ans = max(ans,ans1+ans2); 20 | } 21 | cout< 2 | using namespace std; 3 | 4 | #define DEBUG(fmt, ...) fprintf(stderr, "%s: " fmt "\n", __func__, ##__VA_ARGS__) 5 | #define rep(i, n) for (int i=0; i<(n); i++) 6 | #define Rep(i, n) for (int i=1; i<=(n); i++) 7 | #define range(x) (x).begin(), (x).end() 8 | typedef long long LL; 9 | typedef unsigned long long ULL; 10 | 11 | map, int> cnt; 12 | pair pos[200006]; 13 | 14 | int gcd(int a, int b) { 15 | if (!b) return a; 16 | return gcd(b, a%b); 17 | } 18 | 19 | int n; 20 | char str[100]; 21 | int main() { 22 | cin >> n; 23 | rep (i, n) { 24 | int a, b, c; 25 | cin >> str; 26 | sscanf(str, "(%d %d)/%d", &a, &b, &c); 27 | a+=b; 28 | int g = gcd(a, c); 29 | a/=g; c/=g; 30 | pos[i] = make_pair(a, c); 31 | cnt[pos[i]] += 1; 32 | } 33 | rep (i, n) { 34 | cout << cnt[pos[i]] << ' '; 35 | } 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /Helvetic Coding Contest 2018 online mirror/E2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #pragma GCC optimize("O3") 3 | #define MAXN 500005 4 | #define MAXK 5005 5 | #define INF 1000000000000000000 6 | #define MOD 1000000007 7 | #define F first 8 | #define S second 9 | using namespace std; 10 | typedef long long ll; 11 | #define ll int 12 | ll dp[3][MAXK]; 13 | ll k,n,t[MAXN]; 14 | int main() 15 | { 16 | scanf("%d%d",&k,&n); 17 | for(ll i=1;i<=n;i++) scanf("%d",&t[i]); 18 | sort(t+1,t+n+1); 19 | for(ll i=1;i 2 | #define MAXN 105 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int n,m,a[MAXN],k[MAXN],now[MAXN]; 11 | int main() 12 | { 13 | scanf("%d%d",&n,&m); 14 | for(int i=0;i 3 | #define MAXN 105 4 | #define INF 1000000000 5 | #define MOD 1000000007 6 | #define F first 7 | #define S second 8 | using namespace std; 9 | typedef long long ll; 10 | typedef pair P; 11 | int n,m; 12 | char str[MAXN][MAXN]; 13 | int main() 14 | { 15 | scanf("%d%d",&n,&m); 16 | int ans=0; 17 | for(int i=1;i<=n;i++) 18 | { 19 | scanf("%s",str[i]+1); 20 | bool f=false; 21 | int len=strlen(str[i]+1); 22 | for(int j=1;j<=len;j++) if(str[i][j]=='+') f=true; 23 | if(f) ans++; 24 | } 25 | printf("%d\n",ans); 26 | return 0; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day2/B.cpp: -------------------------------------------------------------------------------- 1 | #pragma GCC optimize(3) 2 | #include 3 | #define MAXN 100005 4 | #define INF 1000000000 5 | #define MOD 1000000007 6 | #define F first 7 | #define S second 8 | using namespace std; 9 | typedef long long ll; 10 | typedef pair P; 11 | int n,l,w,x,y,a; 12 | int main() 13 | { 14 | freopen("aisle.in","r",stdin); 15 | freopen("aisle.out","w",stdout); 16 | scanf("%d%d%d%d%d%d",&n,&l,&w,&x,&y,&a); 17 | int num=l/x; 18 | int ans=-1; 19 | for(int i=1;i*a<=w;i++) 20 | { 21 | int cnt=(w-i*a)/y; 22 | if(cnt*num 3 | #define MAXN 100005 4 | #define INF 1000000000000000000LL 5 | #define MOD 1000000007 6 | #define F first 7 | #define S second 8 | using namespace std; 9 | typedef long long ll; 10 | typedef pair P; 11 | ll n,k,a[MAXN]; 12 | ll count(ll x) 13 | { 14 | ll ans=0,mult=1; 15 | x/=k; 16 | while(x) 17 | { 18 | ans+=mult*x; 19 | mult=-mult; 20 | x/=k; 21 | } 22 | return ans; 23 | } 24 | int main() 25 | { 26 | freopen("numbers.in","r",stdin); 27 | freopen("numbers.out","w",stdout); 28 | scanf("%lld%lld",&n,&k); 29 | ll l=0,r=INF; 30 | while(r-l>1) 31 | { 32 | ll mid=(l+r)/2; 33 | if(count(mid)>=n) r=mid; else l=mid; 34 | } 35 | printf("%lld\n",r); 36 | return 0; 37 | } 38 | 39 | -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day2/M.cpp: -------------------------------------------------------------------------------- 1 | #pragma GCC optimize(3) 2 | #include 3 | #define MAXN 105 4 | #define INF 1000000000 5 | #define MOD 1000000007 6 | #define F first 7 | #define S second 8 | using namespace std; 9 | typedef long long ll; 10 | typedef pair P; 11 | int n,C,p[MAXN],d[MAXN],v[MAXN]; 12 | int main() 13 | { 14 | scanf("%d%d",&n,&C); 15 | int ans=INF; 16 | for(int i=1;i<=n;i++) 17 | { 18 | scanf("%d%d%d",&p[i],&d[i],&v[i]); 19 | ans=min(ans,p[i]+d[i]+v[i]*C); 20 | } 21 | printf("%d\n",ans); 22 | return 0; 23 | } 24 | 25 | -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day2/d.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | 8 | int n, k; 9 | vector strs, sel; 10 | 11 | int main() { 12 | freopen("codes.in","r",stdin); 13 | freopen("codes.out","w",stdout); 14 | ios::sync_with_stdio(false); cin.tie(0); 15 | cin >> n >> k; k++; 16 | for (int i = 0; i < n; i++) { 17 | string str; cin >> str; 18 | strs.push_back(str); 19 | } 20 | sort(range(strs)); 21 | for (string& str : strs) { 22 | if (sel.empty() or str.size() < k or sel.back().size() < k or 23 | str.substr(0, k) != sel.back().substr(0, k)) 24 | sel.push_back(str); 25 | } 26 | cout << sel.size() << endl; 27 | for (string& str : sel) 28 | cout << str << endl; 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day2/g.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #define PROBLEM "gems" 8 | 9 | int n, k; 10 | vector pre[32]; 11 | int occ[32]; 12 | char str[1 << 20]; 13 | typedef long long LL; 14 | int main() { 15 | freopen(PROBLEM ".in","r",stdin); 16 | freopen(PROBLEM ".out","w",stdout); 17 | scanf("%d%d", &n, &k); 18 | scanf("%s", str); 19 | rep (i, k) { 20 | char buf[8]; scanf("%s", buf); 21 | pre[buf[1]-'a'].push_back(buf[0]-'a'); 22 | } 23 | rep (i, 26) { 24 | sort(range(pre[i])); 25 | pre[i].erase(unique(range(pre[i])), pre[i].end()); 26 | } 27 | rep (i, n) str[i] -= 'a'; 28 | LL ans = 0; 29 | rep (i, n) { 30 | for (int x : pre[str[i]]) ans += occ[x]; 31 | occ[str[i]] ++; 32 | } 33 | cout << ans << endl; 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day2/l.py: -------------------------------------------------------------------------------- 1 | a, b, c = open('sum.in', 'rU').read().splitlines() 2 | fo = open('sum.out', 'w') 3 | aa, bb, cc = a, b, c 4 | n, m, k = map(len, (a, b, c)) 5 | c += 100005 * '0' 6 | 7 | def ok() : 8 | fo.write('YES\n') 9 | fo.write(' '.join(map(str, (len(a) - n, len(b) - m, len(c) - k)))) 10 | fo.write('\n') 11 | exit(0) 12 | 13 | a += (len(c) - len(a)) * '0' 14 | if a > c : a = a[:-1] 15 | bp = str(int(c) - int(a)) 16 | if len(bp) >= len(b) and bp[:len(b)] == b and int(bp[len(b):]) == 0: 17 | b = bp 18 | ok() 19 | 20 | a, b = aa, bb 21 | b += (len(c) - len(b)) * '0' 22 | if b > c : b = b[:-1] 23 | ap = str(int(c) - int(b)) 24 | if len(ap) >= len(a) and ap[:len(a)] == a and int(ap[len(a):]) == 0: 25 | a = ap 26 | ok() 27 | 28 | fo.write('NO\n') 29 | 30 | -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day3/20190123.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/ITMO Winter Camp 2019/Day3/20190123.pdf -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day3/F.cpp: -------------------------------------------------------------------------------- 1 | #pragma GCC optimize(3) 2 | #include 3 | #define MAXN 100005 4 | #define INF 1000000000 5 | #define MOD 1000000007 6 | #define F first 7 | #define S second 8 | using namespace std; 9 | typedef long long ll; 10 | typedef pair P; 11 | int n,k,a[MAXN]; 12 | vector v; 13 | int main() 14 | { 15 | freopen("perm.in","r",stdin) 16 | freopen("perm.out","w",stdout); 17 | scanf("%d",&n); 18 | int t=(int)sqrt(n); 19 | while(t*t=now;j--) printf("%d ",j); 28 | now=last+1; 29 | } 30 | return 0; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day3/L.cpp: -------------------------------------------------------------------------------- 1 | #pragma GCC optimize(3) 2 | #include 3 | #define MAXN 100005 4 | #define INF 1000000000 5 | #define MOD 10007 6 | #define F first 7 | #define S second 8 | using namespace std; 9 | typedef long long ll; 10 | typedef pair P; 11 | map,int> mp; 12 | vector states[MAXN]; 13 | int R,C; 14 | vector a; 15 | int dfs(int now,int last) 16 | { 17 | if(now==C+1) 18 | { 19 | mp[a]=++tot; 20 | states[tot]=a; 21 | } 22 | for() 23 | } 24 | int main() 25 | { 26 | return 0; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day3/b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | string s, ss, t; 5 | map mp = { 6 | {'A', 'T'}, 7 | {'G', 'C'}, 8 | {'C', 'G'}, 9 | {'T', 'A'} 10 | }; 11 | 12 | int main() { 13 | freopen("dna.in", "r", stdin); 14 | freopen("dna.out", "w", stdout); 15 | cin >> s >> t; 16 | for (char ch : s) ss.push_back(mp[ch]); 17 | reverse(ss.begin(), ss.end()); 18 | puts((strstr(s.c_str(), t.c_str()) != NULL or strstr(ss.c_str(), t.c_str()) != NULL) ? 19 | "Yes" : "No"); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day3/i.py: -------------------------------------------------------------------------------- 1 | n = int(open('string.in', 'r').read()) 2 | s = '' 3 | for i in range(1, n+1) : 4 | if s.find(str(i)) == -1 : 5 | s += str(i) 6 | open('string.out','w').write(s) 7 | -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day4/20190124.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/ITMO Winter Camp 2019/Day4/20190124.pdf -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day4/a.py: -------------------------------------------------------------------------------- 1 | b1, d1 = map(int, input().split()) 2 | b2, d2 = map(int, input().split()) 3 | l1 = b1**(d1-1) 4 | r1 = (b1**d1)-1 5 | l2 = b2**(d2-1) 6 | r2 = (b2**d2)-1 7 | l = max(l1, l2) 8 | r = min(r1, r2) 9 | print( max(0, r - l+1)) 10 | -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day4/b.py: -------------------------------------------------------------------------------- 1 | n = int(input()) 2 | a = list(map(int, input().split())) 3 | r1 = a[0] 4 | x1 = a[1:] 5 | a = list(map(int, input().split())) 6 | r2 = a[0] 7 | x2 = a[1:] 8 | dist = sum(map(lambda x, y:(x-y)*(x-y), x1, x2)); 9 | out = (r1+r2)*(r1+r2) 10 | inn = (r1-r2)*(r1-r2) 11 | 12 | if dist > out : 13 | print(0) 14 | elif dist == out : 15 | print(1) 16 | elif dist > inn and dist < out : 17 | print(2 if n == 2 else -1) 18 | elif dist == inn : 19 | print(-1 if dist == 0 else 1) 20 | else : 21 | print(0) 22 | -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day4/c.py: -------------------------------------------------------------------------------- 1 | k, l, m = map(int, input().split()) 2 | print([0,2,1][(4*k-l+m)%3]) 3 | -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day4/gen.py: -------------------------------------------------------------------------------- 1 | from random import * 2 | import sys 3 | n = int(sys.argv[1]) 4 | k = int(sys.argv[2]) 5 | a, b = [list(range(1, n + 1)) for _ in range(2)] 6 | shuffle(a) 7 | shuffle(b) 8 | print(n, k) 9 | print(*a) 10 | print(*b) 11 | -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day4/i.py: -------------------------------------------------------------------------------- 1 | n, k = map(int, input().split()) 2 | p = [0] + list(map(int, input().split())) 3 | q = [0] + list(map(int, input().split())) 4 | a = [0] * (n + 1) 5 | b = [0] * (n + 1) 6 | for i in range(1, n + 1) : q[i] = n + 1 - q[i] 7 | for i in range(1, n + 1) : b[q[i]] = i 8 | for i in range(1, n + 1) : 9 | if k == 0 : 10 | a[p[i]] = n 11 | elif k < n - p[i] : 12 | a[p[i]] = sorted(b[p[i]+1:], reverse=1)[k] 13 | k = 0 14 | else : 15 | a[p[i]] = 0 16 | k -= n - p[i] 17 | for i in range(1, n + 1) : b[i] = -b[i] 18 | print('Yes') 19 | print(*a[1:]) 20 | print(*b[1:]) 21 | -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day5/20190125.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/ITMO Winter Camp 2019/Day5/20190125.pdf -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day5/g.py: -------------------------------------------------------------------------------- 1 | from random import * 2 | 3 | T = 1 4 | n = 40000 5 | m = 10000 6 | d = 10000 7 | w = [randint(0, 10000) for _ in range(n)] 8 | print(T) 9 | print(n, m, d) 10 | print(*w) 11 | -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day6/20190126.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/ITMO Winter Camp 2019/Day6/20190126.pdf -------------------------------------------------------------------------------- /ITMO Winter Camp 2019/Day6/L.cpp: -------------------------------------------------------------------------------- 1 | #pragma GCC optimize(3) 2 | #include 3 | #define MAXN 100005 4 | #define INF 1000000000 5 | #define MOD 1000000007 6 | #define F first 7 | #define S second 8 | using namespace std; 9 | typedef long long ll; 10 | typedef pair P; 11 | int N,T; 12 | int main() 13 | { 14 | freopen("local.in","r",stdin); 15 | freopen("local.out","w",stdout); 16 | scanf("%d",&N); 17 | for(int i=1;i<=N;i++) 18 | { 19 | int ans=0; 20 | scanf("%d",&T); 21 | for(int j=0;j 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | set s = {0, 1, 2}; 16 | 17 | LL sqrtu(LL x) { 18 | LL r = sqrt(x); 19 | while (r * r < x) r++; 20 | return r; 21 | } 22 | 23 | void solve(LL x) { 24 | if (s.count(x)) return; 25 | LL rt = sqrtu(x), rem = rt * rt - x; 26 | solve(rt); solve(rem); 27 | printf("%lld %lld\n", rt, rem); 28 | s.insert(x); 29 | } 30 | 31 | int main() { 32 | LL n; cin >> n; 33 | solve(n); 34 | return 0; 35 | } -------------------------------------------------------------------------------- /MEX Foundation Contest/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int n, m; 16 | int val[500005]; 17 | vector adj[500005]; 18 | 19 | bool check(int u) { 20 | if (val[u]) return false; 21 | for (int v : adj[u]) 22 | if (val[v] != 1) return false; 23 | return true; 24 | } 25 | 26 | int main() { 27 | scanf("%d%d", &n, &m); 28 | Rep (i, n) scanf("%d", val + i); 29 | rep (_, m) { 30 | int u, v; scanf("%d%d", &u, &v); 31 | adj[u].push_back(v); 32 | adj[v].push_back(u); 33 | } 34 | Rep (i, n) if (check(i)) return printf("%d\n", i), 0; 35 | return 0; 36 | } -------------------------------------------------------------------------------- /MEX Foundation Contest/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/MEX Foundation Contest/statements.pdf -------------------------------------------------------------------------------- /Moscow Pre-Finals Workshop 2016. Kent Nikaido Contest 1/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int n; 16 | char g[64][64]; 17 | int cnt[4]; 18 | 19 | int main() { 20 | cin >> n; 21 | for (int i = n - 1; i >= 0; i--) cin >> g[i]; 22 | rep (i, n) rep (j, n) if (g[i][j] == 'o') cnt[(i-j)&3] ^= 1; 23 | cout << cnt[0] << endl; 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /Moscow Pre-Finals Workshop 2016. Kent Nikaido Contest 1/K.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int n,a[MAXN],sum; 11 | int main() 12 | { 13 | scanf("%d",&n); 14 | int minx=INF; 15 | for(int i=1;i<=n;i++) 16 | { 17 | scanf("%d",&a[i]); 18 | minx=min(minx,a[i]); 19 | sum+=a[i]; 20 | } 21 | if(n&1) 22 | { 23 | if(sum&1) puts("Iori"); else puts("Yayoi"); 24 | } 25 | else 26 | { 27 | if(minx&1) puts("Iori"); 28 | else 29 | { 30 | if(sum&1) puts("Iori"); else puts("Yayoi"); 31 | } 32 | } 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /Moscow Pre-Finals Workshop 2016. Kent Nikaido Contest 1/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Moscow Pre-Finals Workshop 2016. Kent Nikaido Contest 1/statements.pdf -------------------------------------------------------------------------------- /Moscow Pre-Finals Workshop 2016. National Taiwan U Selection/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Moscow Pre-Finals Workshop 2016. National Taiwan U Selection/statements.pdf -------------------------------------------------------------------------------- /Moscow Pre-Finals Workshop 2019. KAIST Contest/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Moscow Pre-Finals Workshop 2019. KAIST Contest/statements.pdf -------------------------------------------------------------------------------- /NWERC 2018/H.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 500005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int n,c,b; 11 | int z[MAXN]; 12 | int ans[MAXN]; 13 | int main() 14 | { 15 | scanf("%d%d%d",&n,&c,&b); 16 | for(int i=1;i<=b;i++) scanf("%d",&z[i]); 17 | for(int i=b;i>1;i--) 18 | { 19 | int dif=z[i]-z[i-1]; 20 | int now=z[i]-1; 21 | while(c>=2&&now>z[i-1]) 22 | { 23 | ans[now]=1; 24 | now-=2; 25 | c-=2; 26 | } 27 | } 28 | int now=z[1]-1; 29 | while(c>=2&&now>=1) 30 | { 31 | ans[now]=1; 32 | now-=2; 33 | c-=2; 34 | } 35 | assert(c<2); 36 | if(c==1) 37 | { 38 | assert(ans[2]!=1); 39 | ans[1]=1; 40 | } 41 | for(int i=1;i<=n;i++) printf("%d",ans[i]); 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /NWERC 2018/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int n; 16 | int a[1 << 20], b[1 << 20]; 17 | 18 | int main() { 19 | scanf("%d", &n); 20 | rep (i, n) scanf("%d", a + i); 21 | sort(a, a + n); 22 | iota(b, b + n, 1); 23 | rep (i, n) { 24 | if (a[i] > b[i]) { 25 | puts("impossible"); 26 | return 0; 27 | } 28 | } 29 | double ans = 1.0; 30 | rep (i, n) ans = min(ans, 1.0 * a[i] / b[i]); 31 | printf("%.7f\n", ans); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /NWERC 2018/K.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int n,m; 4 | char a[35],b[105]; 5 | char ans[105]; 6 | int main() 7 | { 8 | scanf("%d%d",&n,&m); 9 | scanf("%s",a+1);scanf("%s",b+1); 10 | for(int i=m-n+1;i<=m;i++) ans[i]=a[i-(m-n)]; 11 | for(int i=m-n;i>=1;i--) 12 | { 13 | int x=b[i+n]-ans[i+n]; 14 | if(x<0) x+=26; 15 | ans[i]=x+'a'; 16 | } 17 | printf("%s\n",ans+1); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /NWERC 2018/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/NWERC 2018/statements.pdf -------------------------------------------------------------------------------- /NWERC 2019/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int readint() { 16 | double x; scanf("%lf", &x); 17 | return lround(x * 100); 18 | } 19 | 20 | int main() { 21 | int t[4]; rep (i, 4) t[i] = readint(); 22 | int target = readint() * 3; 23 | sort(range(t)); 24 | if (t[0] + t[1] + t[2] > target) { 25 | puts("impossible"); 26 | } else if (t[1] + t[2] + t[3] <= target) { 27 | puts("infinite"); 28 | } else { 29 | printf("%.2f\n", (target - t[1] - t[2]) / 100.); 30 | } 31 | return 0; 32 | } 33 | 34 | -------------------------------------------------------------------------------- /NWERC 2019/G.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int n, k; 16 | double p[512], q[512], r[512]; 17 | 18 | int main() { 19 | scanf("%d%d", &n, &k); 20 | rep (i, n) scanf("%lf", p + i); 21 | reverse(p, p + n); 22 | q[0] = 1. * k / n; 23 | for (int i = 1; n - i != k - 1; i++) q[i] = q[i-1] * (1. - 1. * (k - 1) / (n - i)); 24 | rep (i, n) rep (j, n) r[i] += p[(i+j)%n] * q[j]; 25 | reverse(r, r + n); 26 | rep (i, n) printf("%.9f ", r[i]); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /NWERC 2019/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/NWERC 2019/statements.pdf -------------------------------------------------------------------------------- /North American Southeast Regional 2019 (Div 1)/H.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | alpha = set(input()) 3 | t = input() 4 | r = [] 5 | for i in range(len(t)) : 6 | r.append(t[:i] + t[i+1:]) 7 | for i in range(len(t)) : 8 | for ch in alpha : 9 | r.append(t[:i] + ch + t[i+1:]) 10 | for i in range(len(t) + 1) : 11 | for ch in alpha : 12 | r.append(t[:i] + ch + t[i:]) 13 | r = sorted(set(r)) 14 | for res in r : 15 | print(res) 16 | -------------------------------------------------------------------------------- /North American Southeast Regional 2019 (Div 1)/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/North American Southeast Regional 2019 (Div 1)/statements.pdf -------------------------------------------------------------------------------- /Petrozavodsk Summer-2014. Andrew Stankevich Contest 46/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Petrozavodsk Summer-2014. Andrew Stankevich Contest 46/statements.pdf -------------------------------------------------------------------------------- /Petrozavodsk Summer-2015. Andrew Stankevich Contest 48/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 998244353 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int n; 11 | void add(int &a,int b) {a+=b; if(a>=MOD) a-=MOD;} 12 | int pow_mod(int a,int i) 13 | { 14 | int s=1; 15 | while(i) 16 | { 17 | if(i&1) s=1LL*s*a%MOD; 18 | a=1LL*a*a%MOD; 19 | i>>=1; 20 | } 21 | return s; 22 | } 23 | int main() 24 | { 25 | freopen("cover.in","r",stdin); 26 | freopen("cover.out","w",stdout); 27 | while(true) 28 | { 29 | scanf("%d",&n); 30 | if(n==0) break; 31 | int ans=0; 32 | for(int k=1;k<=n;k++) 33 | { 34 | int rem=(k-n%k); if(rem>=k) rem-=k; 35 | add(ans,pow_mod(2,k-rem)); 36 | } 37 | printf("%d\n",ans); 38 | } 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /Petrozavodsk Summer-2015. Andrew Stankevich Contest 48/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Petrozavodsk Summer-2015. Andrew Stankevich Contest 48/statements.pdf -------------------------------------------------------------------------------- /Petrozavodsk Summer-2015. Moscow IPT Contest/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Petrozavodsk Summer-2015. Moscow IPT Contest/statements.pdf -------------------------------------------------------------------------------- /Petrozavodsk Summer-2015. Xudyh Contest/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Petrozavodsk Summer-2015. Xudyh Contest/statements.pdf -------------------------------------------------------------------------------- /Petrozavodsk Summer-2016. Warsaw U Contest, XVI Open Cup Onsite/G.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | k, a, b = map(int, input().split()) 3 | ans = 0 4 | for fn in range(1, 5000) : 5 | n = k * fn 6 | if n < a or n > b : continue 7 | s = 0 8 | for ch in str(n) : 9 | s += int(ch) ** 2 10 | if s == fn : ans += 1 11 | print(ans) 12 | -------------------------------------------------------------------------------- /Petrozavodsk Summer-2016. Warsaw U Contest, XVI Open Cup Onsite/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Petrozavodsk Summer-2016. Warsaw U Contest, XVI Open Cup Onsite/statements.pdf -------------------------------------------------------------------------------- /Petrozavodsk Summer-2017. JOI TST 2012 Selection/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Petrozavodsk Summer-2017. JOI TST 2012 Selection/statements.pdf -------------------------------------------------------------------------------- /Petrozavodsk Summer-2017. MIPT Contest/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN (1<<20) 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int n,a[MAXN]; 11 | int dp[MAXN]; 12 | int query(int x,int t) 13 | { 14 | int mask=0; 15 | for(int i=19;i>=0;i--) 16 | { 17 | if(!((x>>i)&1)) 18 | { 19 | if(dp[mask^(1<=0;j--) 35 | if(!((j>>i)&1)) dp[j]=min(dp[j^(1< 2 | #define MAXN 500005 3 | #define INF 1000000001 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | int n,m,a[MAXN],b[MAXN],dp[MAXN]; 10 | int ans=0; 11 | int main() 12 | { 13 | scanf("%d",&n); 14 | for(int i=0;i 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | ll n,m; 11 | int main() 12 | { 13 | scanf("%lld%lld",&n,&m); 14 | ll ans; 15 | if(m<=n-1) 16 | { 17 | ans=(n-1-m)*(n-2-m)*n+(n-1-m)*(m+1)*n*2+m*2+m*(m-1)*2; 18 | printf("%lld\n",ans); 19 | } 20 | else if(m>=n*(n-1)/2) 21 | { 22 | printf("%lld\n",n*(n-1)); 23 | return 0; 24 | } 25 | else 26 | { 27 | ans=(n-1)*(n-2)*2+(n-1)*2; 28 | ans-=(m-n+1)*2; 29 | printf("%lld\n",ans); 30 | } 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /Petrozavodsk Summer-2017. Ruyi Li Contest 2/H.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | ll n,m,b[MAXN],c[MAXN]; 11 | ll now; 12 | vector v; 13 | int main() 14 | { 15 | scanf("%lld%lld",&n,&m); 16 | for(ll i=0;i<=m;i++) scanf("%lld",&b[i]); 17 | now=1; 18 | for(ll i=1;i<=n;i++) 19 | { 20 | while(!b[now]&&now<=m) now++; 21 | assert(now<=m); 22 | v.push_back(now); 23 | memset(c,0,sizeof(c)); 24 | for(ll j=0;j+now<=m;j++) 25 | { 26 | if(b[j]) 27 | { 28 | assert(b[j+now]>=b[j]); 29 | c[j]=b[j];b[j+now]-=b[j]; 30 | } 31 | } 32 | for(ll j=0;j<=m;j++) b[j]=c[j]; 33 | } 34 | for(ll i=0;i 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int n,K,a[MAXN]; 11 | int main() 12 | { 13 | scanf("%d%d",&n,&K); 14 | for(int i=0;i=0;i--) 18 | { 19 | if(last-a[i]>K) break; 20 | else {ans++; last=a[i];} 21 | } 22 | printf("%d\n",ans); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /Petrozavodsk Summer-2017. Ruyi Li Contest 2/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Petrozavodsk Summer-2017. Ruyi Li Contest 2/statements.pdf -------------------------------------------------------------------------------- /Petrozavodsk Summer-2017. Songyang Chen Contest 1/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int n; 16 | int a[100005]; 17 | mt19937 gen(time(NULL)); 18 | 19 | int main() { 20 | scanf("%d", &n); 21 | rep (i, n) scanf("%d", a + i); 22 | int c[2] = {0, 0}; 23 | rep (i, n) c[a[i] & 1]++; 24 | if (c[0] > c[1]) puts("2 0"); 25 | else puts("2 1"); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /Petrozavodsk Summer-2017. Songyang Chen Contest 1/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Petrozavodsk Summer-2017. Songyang Chen Contest 1/statements.pdf -------------------------------------------------------------------------------- /Petrozavodsk Summer-2017. UESTC Selection/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 1000005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | int n; 9 | int s[MAXN]; 10 | int sg[MAXN],mex[MAXN]; 11 | int main() 12 | { 13 | /* sg[0]=0; 14 | for(int i=1;i<=100;i++) 15 | { 16 | for(int j=0;j 2 | #define MAXN 2000005 3 | using namespace std; 4 | int n,t,a[MAXN]; 5 | int main() 6 | { 7 | scanf("%d%d",&n,&t); 8 | for(int i=1;i<=(1<=1;i--) printf("%d%c",a[i],i==1?'\n':' '); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /Petrozavodsk Summer-2017. Warsaw U Contest, XVII OpenCup Onsite/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Petrozavodsk Summer-2017. Warsaw U Contest, XVII OpenCup Onsite/statements.pdf -------------------------------------------------------------------------------- /Petrozavodsk Winter-2014. Andrew Stankevich Contest 47/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Petrozavodsk Winter-2014. Andrew Stankevich Contest 47/statements.pdf -------------------------------------------------------------------------------- /Petrozavodsk Winter-2016. JAG Contest/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 1e3 + 10; 4 | int n,m; 5 | bool dp[maxn][maxn][2]; 6 | char s[maxn]; 7 | char t[maxn]; 8 | int main(){ 9 | cin>>s+1; 10 | cin>>t+1; 11 | n = strlen(s+1); 12 | m = strlen(t+1); 13 | dp[0][0][0] = dp[0][0][1] = 1; 14 | for (int i=0;i<=n;i++){ 15 | for (int j=0;j<=m;j++){ 16 | // 0 match with a. 17 | if (dp[i][j][0]){ 18 | if (j + 1 <= m and i + 1 <= n and t[j+1] == s[i+1])dp[i+1][j+1][1] = 1; 19 | } 20 | // 1 match with a. 21 | if (dp[i][j][1]){ 22 | if (i + 1 <= n)dp[i+1][j][0] = 1; 23 | } 24 | // b not used 25 | if (dp[i][j][0])dp[i][j+1][0] = 1; 26 | } 27 | } 28 | bool succ = false; 29 | for (int i=0;i<=m;i++){ 30 | succ |= dp[n][i][0]; 31 | succ |= dp[n][i][1]; 32 | } 33 | if (succ)cout<<"Yes"< 3 | #define MAXN 100005 4 | #define INF 1000000000 5 | #define MOD 1000000007 6 | #define F first 7 | #define S second 8 | using namespace std; 9 | typedef long long ll; 10 | typedef pair P; 11 | int n,k,a[MAXN]; 12 | string str; 13 | int ask(int x) 14 | { 15 | printf("%d\n",x);fflush(stdout); 16 | cin>>str; 17 | if(str=="Vacant") exit(0); 18 | if(str=="Male") return 0; else return 1; 19 | } 20 | void solve(int l,int r,int cur) 21 | { 22 | assert(l<=r); 23 | int len=(r-l+1); 24 | int mid=(l+r)/2; 25 | int now=ask(mid); 26 | int rest=(len-1)/2; 27 | if(rest&1) 28 | { 29 | if(now==cur) solve(mid+1,r,now); 30 | else solve(l,mid-1,cur); 31 | } 32 | else 33 | { 34 | if(now==cur) solve(l,mid-1,cur); 35 | else solve(mid+1,r,now); 36 | } 37 | } 38 | int main() 39 | { 40 | scanf("%d",&n); 41 | int now=ask(0);ask(n-1); 42 | solve(1,n-2,now); 43 | return 0; 44 | } 45 | 46 | -------------------------------------------------------------------------------- /Petrozavodsk Winter-2018. Atcoder Contest/H.cpp: -------------------------------------------------------------------------------- 1 | #pragma GCC optimize(3) 2 | #include 3 | #define MAXN 100005 4 | #define INF 1000000000 5 | #define MOD 1000000007 6 | #define F first 7 | #define S second 8 | using namespace std; 9 | typedef long long ll; 10 | typedef pair P; 11 | int n,k,p[MAXN],a[MAXN],dep[MAXN],deg[MAXN]; 12 | vector G[MAXN]; 13 | void add_edge(int u,int v) 14 | { 15 | G[u].push_back(v); 16 | G[v].push_back(u); 17 | } 18 | int main() 19 | { 20 | scanf("%d",&n); 21 | for(int i=2;i<=n;i++) 22 | { 23 | scanf("%d",&p[i]); 24 | p[i]++;add_edge(i,p[i]); 25 | deg[i]++;deg[p[i]]++; 26 | } 27 | for(int i=1;i<=n;i++) 28 | { 29 | scanf("%d",&a[i]); 30 | a[i]++; 31 | } 32 | return 0; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /Petrozavodsk Winter-2018. Carnegie Mellon U Contest/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | int N,Q,P; 9 | int d; 10 | set pos; 11 | int main() 12 | { 13 | scanf("%d%d%d",&N,&Q,&P); 14 | for(int i=0;i 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define F first 5 | #define S second 6 | using namespace std; 7 | typedef long long ll; 8 | typedef pair P; 9 | P dp[1<<24]; 10 | ll n,s; 11 | int w[25]; 12 | int main() 13 | { 14 | scanf("%d%d",&n,&s); 15 | for(ll i=0;i 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | typedef long double db; 15 | 16 | int n, k; 17 | 18 | db compute(LL i) { 19 | db ans = 0; 20 | if ((1 << i) > k) return 0; 21 | Rep (I, (1 << i) - 1) { 22 | ans += logl(k - I) - logl((1 << n) - I); 23 | } 24 | return expl(ans); 25 | } 26 | 27 | int main() { 28 | cin >> n >> k; 29 | k = (1< 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 998244353 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | ll save[305][305]; 11 | ll n,h,a[MAXN],dp[MAXN]; 12 | int main() 13 | { 14 | scanf("%lld%lld",&n,&h); 15 | for(ll i=1;i<=n;i++) scanf("%lld",&a[i]); 16 | a[n]=INF; 17 | dp[1]=1; 18 | for(ll i=1;i+h<=n;i+=h) if(a[i]!=h) dp[i+h]+=dp[i]; 19 | for(ll i=1;i<=n;i++) 20 | { 21 | for(ll j=1;j<=300;j++) 22 | { 23 | if(a[i]==j) continue; 24 | (dp[i]+=save[j][i%j])%=MOD; 25 | } 26 | if(a[i]>300) 27 | { 28 | for(ll j=i+a[i];j<=n;j+=a[i]) 29 | { 30 | if(a[j]!=a[i]) (dp[j]+=dp[i])%=MOD; 31 | } 32 | } else (save[a[i]][i%a[i]]+=dp[i])%=MOD; 33 | } 34 | printf("%lld\n",dp[n]); 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /Petrozavodsk Winter-2018. ITMO U 1 Contest/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Petrozavodsk Winter-2018. ITMO U 1 Contest/statements.pdf -------------------------------------------------------------------------------- /Petrozavodsk Winter-2018. Jagiellonian U Contest/F.cpp: -------------------------------------------------------------------------------- 1 | #pragma GCC optimize(3) 2 | #include 3 | #define MAXN 100005 4 | #define INF 1000000000 5 | #define MOD 1000000007 6 | #define F first 7 | #define S second 8 | using namespace std; 9 | typedef long long ll; 10 | typedef pair P; 11 | int T,x,y,z,r,a,b,c,d; 12 | const long double PI=acos(-1.0); 13 | int main() 14 | { 15 | scanf("%d",&T); 16 | while(T--) 17 | { 18 | scanf("%d%d%d%d%d%d%d%d",&x,&y,&z,&r,&a,&b,&c,&d); 19 | printf("%.15Lf\n",PI*r*r); 20 | } 21 | return 0; 22 | } 23 | 24 | -------------------------------------------------------------------------------- /Petrozavodsk Winter-2018. Jagiellonian U Contest/I.cpp: -------------------------------------------------------------------------------- 1 | #pragma GCC optimize(3) 2 | #include 3 | #define MAXN 100005 4 | #define INF 1000000000 5 | #define MOD 1000000007 6 | #define F first 7 | #define S second 8 | using namespace std; 9 | typedef long long ll; 10 | typedef pair P; 11 | int T,n; 12 | int main() 13 | { 14 | scanf("%d",&T); 15 | while(T--) 16 | { 17 | scanf("%d",&n); 18 | if(n&1) puts("B"); else puts("A"); 19 | } 20 | return 0; 21 | } 22 | 23 | -------------------------------------------------------------------------------- /Petrozavodsk Winter-2019. Japanese Contest/B.cpp: -------------------------------------------------------------------------------- 1 | #pragma GCC optimize(3) 2 | #include 3 | using namespace std; 4 | 5 | #define rep(i, n) for (int i = 0; i < int(n); i++) 6 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 7 | #define range(x) begin(x), end(x) 8 | #ifdef __LOCAL_DEBUG__ 9 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 10 | #else 11 | #define _debug(...) ((void) 0) 12 | #endif 13 | typedef long long LL; 14 | typedef unsigned long long ULL; 15 | 16 | int n; 17 | int a[5120]; 18 | int dp[5120][5120]; 19 | 20 | int main() { 21 | scanf("%d", &n); 22 | rep (i, n) scanf("%d", a + i); 23 | sort(a, a + n); 24 | rep (i, n) { 25 | rep (j, i) { 26 | int prev = a[j] - (a[i] - a[j]); 27 | int pos = lower_bound(a, a + j, prev) - a; 28 | if (a[pos] != prev) dp[i][j] = 1; 29 | else dp[i][j] = dp[j][pos] + 1; 30 | } 31 | } 32 | int ans = 0; 33 | rep (i, n) rep (j, i) ans = max(ans, dp[i][j]); 34 | cout << ans + 1 << endl; 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /Petrozavodsk Winter-2019. Japanese Contest/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int r, s, p; 16 | 17 | int main() { 18 | scanf("%d%d%d", &r, &s, &p); 19 | vector ts; 20 | while (p--) { 21 | int x, y; scanf("%d%d", &x, &y); swap(x, y); 22 | if (x <= s) x--; 23 | y = r - y; 24 | ts.push_back(abs(x - s) + y); 25 | // cout << ts.back() << endl; 26 | } 27 | int ans = 0; 28 | sort(range(ts)); 29 | for (int t : ts) { 30 | ans = max(ans + 1, t); 31 | } 32 | cout << ans + 1 << endl; 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /Petrozavodsk Winter-2019. Japanese Contest/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Petrozavodsk Winter-2019. Japanese Contest/statements.pdf -------------------------------------------------------------------------------- /Petrozavodsk Winter-2019. Oleksandr Kulkov Contest/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int n,a[250]; 4 | int main() 5 | { 6 | scanf("%d",&n); 7 | int s=0; 8 | for(int i=1;i<=n;i++) 9 | { 10 | scanf("%d",&a[i]); 11 | s+=a[i]; 12 | } 13 | printf("%d\n",(s+1)/2); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /Petrozavodsk Winter-2019. Oleksandr Kulkov Contest/K.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | const int mod = 1000000007; 5 | int main() { 6 | int a, b, c; cin >> a >> b >> c; 7 | cout << (b - c + mod) % mod << endl; 8 | 9 | } 10 | -------------------------------------------------------------------------------- /Petrozavodsk Winter-2019. Oleksandr Kulkov Contest/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Petrozavodsk Winter-2019. Oleksandr Kulkov Contest/statements.pdf -------------------------------------------------------------------------------- /Petrozavodsk Winter-2019. Petrozavodsk SU Contest/B.py: -------------------------------------------------------------------------------- 1 | n = input() 2 | a = map(int, raw_input().split()) 3 | x = [i % n for i in range(n+n)] 4 | s = [] 5 | for _ in range(n+n-1) : 6 | s.append(x[:-1]) 7 | x = x[1:] + x[:1] 8 | print len(s) 9 | for row in s : 10 | for col in row : 11 | print a[col], 12 | print 13 | -------------------------------------------------------------------------------- /Petrozavodsk Winter-2019. Petrozavodsk SU Contest/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int n; 11 | ll k; 12 | bool check(int x) 13 | { 14 | return k>=1LL*x*(x-1)/2&&k<=1LL*x*(x-1)/2+1LL*x*(n-x); 15 | } 16 | ll getans(int x) 17 | { 18 | return 1LL*x*(x-1)/2+1LL*(n-x)*(n-x-1)/2; 19 | } 20 | int main() 21 | { 22 | scanf("%d%lld",&n,&k); 23 | if(k>1LL*n*(n-1)/2) {puts("-1"); return 0;} 24 | ll ans=-INF; 25 | int l=-1,r=n; 26 | while(r-l>1) 27 | { 28 | int mid=(l+r)/2; 29 | if(1LL*mid*(mid-1)/2+1LL*mid*(n-mid)>=k) r=mid; else l=mid; 30 | } 31 | if(check(r)) ans=max(ans,getans(r)); 32 | l=0,r=n+1; 33 | while(r-l>1) 34 | { 35 | int mid=(l+r)/2; 36 | if(1LL*mid*(mid-1)/2<=k) l=mid; else r=mid; 37 | } 38 | if(check(l)) ans=max(ans,getans(l)); 39 | printf("%lld\n",ans); 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /Petrozavodsk Winter-2019. Petrozavodsk SU Contest/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Petrozavodsk Winter-2019. Petrozavodsk SU Contest/statements.pdf -------------------------------------------------------------------------------- /Petrozavodsk Winter-2019. Yandex Cup 2019/H.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int n; 16 | int a[512][512]; 17 | 18 | int main() { 19 | scanf("%d", &n); 20 | rep (i, n) rep (j, n) scanf("%d", &a[i][j]); 21 | int ans = 0; 22 | rep (i, n) ans = max(ans, *min_element(a[i], a[i] + n)); 23 | cout << ans << endl; 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /Petrozavodsk Winter-2019. Yandex Cup 2019/J.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int a,b; 11 | int go(int x) 12 | { 13 | if(x==0) a++; else b++; 14 | if(x==0) printf("+\n"); else printf("-\n"); 15 | fflush(stdout); 16 | int ret; 17 | scanf("%d",&ret); 18 | return 1-ret; 19 | } 20 | void win(int x) 21 | { 22 | printf("! "); 23 | if(x==0) puts("good"); 24 | else if(x==1) puts("bad"); 25 | else puts("ugly"); 26 | fflush(stdout); 27 | exit(0); 28 | } 29 | void get() 30 | { 31 | go(0); int x=go(1); 32 | int y=go(1); 33 | if(x==0) win(2); else if(y==0) win(0); else win(1); 34 | } 35 | int main() 36 | { 37 | a=0;b=0; 38 | ll cur=1; 39 | int type=1; 40 | while(true) 41 | { 42 | for(int i=0;i 2 | int T,cnt; 3 | int main() 4 | { 5 | scanf("%d",&T); 6 | while(T--) 7 | { 8 | int a,b,c,d; 9 | cnt=0; 10 | scanf("%d%d%d%d",&a,&b,&c,&d); 11 | if(a) cnt++; 12 | if(b) cnt++; 13 | if(c) cnt++; 14 | if(d) cnt++; 15 | if(cnt==0) puts("Typically Otaku"); 16 | else if(cnt==1) puts("Eye-opener"); 17 | else if(cnt==2) puts("Young Traveller"); 18 | else if(cnt==3) puts("Excellent Traveller"); 19 | else puts("Contemporary Xu Xiake"); 20 | } 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /The 43rd ACM ICPC Asia Jiaozuo Regional Contest/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | const double PI=acos(-1.0); 11 | int T,a,b,r,d; 12 | int main() 13 | { 14 | scanf("%d",&T); 15 | while(T--) 16 | { 17 | scanf("%d%d%d%d",&a,&b,&r,&d); 18 | double ang=(double)d/180.0*PI; 19 | //printf("%.12f %.12f\n",ang,atan((double)b/(a+r))); 20 | if(atan((double)b/(a+r)) 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int T,n,a[MAXN],sum[MAXN]; 11 | int main() 12 | { 13 | scanf("%d",&T); 14 | while(T--) 15 | { 16 | scanf("%d",&n); 17 | for(int i=1;i<=n-1;i++) scanf("%d",&a[i]); 18 | for(int i=1;i<=n-1;i++) sum[i]=sum[i-1]+a[i]; 19 | ll l=0,r=n-1,lsum=0,rsum=0; 20 | ll ans=0; 21 | for(int i=1;i<=n;i++) 22 | { 23 | if(i&1) 24 | { 25 | ans+=rsum-lsum; 26 | rsum+=sum[r];r--; 27 | } 28 | else 29 | { 30 | ans+=rsum-lsum-sum[l]; 31 | lsum+=sum[l];l++; 32 | } 33 | //printf("%d %d\n",lsum,rsum); 34 | printf("%lld%c",ans,i==n?'\n':' '); 35 | } 36 | } 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /The 43rd ACM ICPC Asia Jiaozuo Regional Contest/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/The 43rd ACM ICPC Asia Jiaozuo Regional Contest/statements.pdf -------------------------------------------------------------------------------- /The 43rd ACM ICPC Asia Nanjing Regional Contest/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/The 43rd ACM ICPC Asia Nanjing Regional Contest/statements.pdf -------------------------------------------------------------------------------- /The 43rd ACM ICPC Asia Qingdao Regional Contest (Mirror)/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/The 43rd ACM ICPC Asia Qingdao Regional Contest (Mirror)/statements.pdf -------------------------------------------------------------------------------- /The 43rd ACM ICPC Asia Shenyang Regional Contest/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | int T,n,k,q; 10 | int main() 11 | { 12 | scanf("%d",&T); 13 | for(int t=1;t<=T;t++) 14 | { 15 | scanf("%d%d%d",&n,&k,&q); 16 | int ans=1; 17 | if(n<=k) 18 | { 19 | for(int i=1;i<=n;i++) ans=1LL*ans*i%q; 20 | printf("Case #%d: %d\n",t,ans); 21 | continue; 22 | } 23 | for(int i=1;i<=k;i++) ans=1LL*ans*i%q; 24 | int cur=(1LL*(n-k-1)*(n-k-1)+1)%q; 25 | cur=(cur+1LL*k*(n-k))%q; 26 | cur=(cur+n-k-1)%q; 27 | ans=1LL*ans*cur%q; 28 | printf("Case #%d: %d\n",t,ans); 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /The 43rd ACM ICPC Asia Shenyang Regional Contest/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/The 43rd ACM ICPC Asia Shenyang Regional Contest/statements.pdf -------------------------------------------------------------------------------- /The 43rd ACM ICPC Asia Xuzhou Regional Contest/K: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/The 43rd ACM ICPC Asia Xuzhou Regional Contest/K -------------------------------------------------------------------------------- /The 43rd ACM ICPC Asia Xuzhou Regional Contest/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/The 43rd ACM ICPC Asia Xuzhou Regional Contest/statements.pdf -------------------------------------------------------------------------------- /Warsaw U Contest, Urozero 2015 Day 4/F.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int n,a,b,c,d; 11 | int get(int x,int y) 12 | { 13 | if(y>x) return INF; 14 | return x/(x/y); 15 | } 16 | int main() 17 | { 18 | scanf("%d",&n); 19 | while(n--) 20 | { 21 | scanf("%d%d%d%d",&a,&b,&c,&d); 22 | a--;c--; 23 | int last=-1,ans=0; 24 | for(int i=1;i<=max(b,d);i=last+1) 25 | { 26 | last=min(min(get(a,i),get(b,i)),min(get(c,i),get(d,i))); 27 | if((b/i-a/i>0)&&(d/i-c/i>0)) ans=max(ans,last); 28 | } 29 | printf("%d\n",ans); 30 | } 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /Warsaw U Contest, Urozero 2015 Day 4/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/Warsaw U Contest, Urozero 2015 Day 4/statements.pdf -------------------------------------------------------------------------------- /XIX Open Cup named after E.V. Pankratiev. Grand Prix of America/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int T; 11 | ll p,q,n; 12 | ll cal(ll a,ll b,ll c,ll n) 13 | { 14 | if(!a) return 0; 15 | if(a>=c||b>=c) 16 | { 17 | ll x=cal(a%c,b%c,c,n); 18 | return (a/c*n*(n+1)/2+b/c*(n+1)+x); 19 | } 20 | ll m=(a*n+b)/c; 21 | ll x=cal(c,c-b-1,a,m-1); 22 | return n*m-x; 23 | } 24 | int main() 25 | { 26 | scanf("%d",&T); 27 | while(T--) 28 | { 29 | scanf("%lld%lld%lld",&p,&q,&n); 30 | printf("%lld\n",p*n*(n+1)/2-q*cal(p,0,q,n)); 31 | } 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /XIX Open Cup named after E.V. Pankratiev. Grand Prix of America/J.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define MAXM 105 4 | #define INF 1000000000 5 | #define MOD 1000000007 6 | #define F first 7 | #define S second 8 | using namespace std; 9 | typedef long long ll; 10 | typedef pair P; 11 | char s[MAXN],t[MAXM]; 12 | int n,m; 13 | int dp[MAXN][MAXM]; 14 | int go(int pos,int x) 15 | { 16 | if(pos==n+1) return n+1; 17 | if(dp[pos][x]!=-1) return dp[pos][x]; 18 | if(s[pos]=='a'+x) return dp[pos][x]=pos; else return dp[pos][x]=go(pos+1,x); 19 | } 20 | int main() 21 | { 22 | scanf("%s",s+1);scanf("%s",t+1); 23 | n=strlen(s+1);m=strlen(t+1); 24 | memset(dp,-1,sizeof(dp)); 25 | ll ans=0; 26 | for(int i=1;i<=n;i++) 27 | { 28 | int pos=i-1; 29 | for(int j=1;j<=m;j++) 30 | { 31 | pos=go(pos+1,t[j]-'a'); 32 | if(pos==n+1) break; 33 | } 34 | ans+=n-pos+1; 35 | } 36 | printf("%lld\n",ans); 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /XIX Open Cup named after E.V. Pankratiev. Grand Prix of America/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XIX Open Cup named after E.V. Pankratiev. Grand Prix of America/statements.pdf -------------------------------------------------------------------------------- /XIX Open Cup named after E.V. Pankratiev. Grand Prix of China/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XIX Open Cup named after E.V. Pankratiev. Grand Prix of China/statements.pdf -------------------------------------------------------------------------------- /XIX Open Cup named after E.V. Pankratiev. Grand Prix of Eurasia/5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int main(){ 16 | int T; scanf("%d", &T); 17 | while (T--) { 18 | int t; scanf("%d", &t); 19 | int a = 1, b = - 1 - t, c = t; 20 | if (b == 0 || abs(b) > 1000000) { 21 | b = 1 - t; c = -t; 22 | } 23 | printf("%d %d %d\n", a, b, c); 24 | } 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /XIX Open Cup named after E.V. Pankratiev. Grand Prix of Eurasia/7.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: 7.cpp 3 | > Author: Roundgod 4 | > Mail: wcysai@foxmail.com 5 | > Created Time: 2018-10-15 22:18:53 6 | ************************************************************************/ 7 | 8 | #pragma GCC optimize(3) 9 | #include 10 | #define MAXN 100005 11 | #define INF 1000000000 12 | #define MOD 1000000007 13 | #define F first 14 | #define S second 15 | using namespace std; 16 | typedef long long ll; 17 | typedef pair P; 18 | int n,m; 19 | vector

G[MAXN]; 20 | int main() 21 | { 22 | scanf("%d%d",&n,&m); 23 | for(int i=0;i 2 | using namespace std; 3 | const int maxn = 10000 + 5; 4 | char s[maxn]; 5 | int main(){ 6 | scanf("%s",s); 7 | int len = strlen(s); 8 | for (int i = len-1;i>=0;i--){ 9 | if (s[i] == 'b'){printf("b");} 10 | else{ 11 | for (int o=0;o<5;o++){ 12 | printf("%c",s[i]); 13 | } 14 | } 15 | } 16 | puts(""); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /XIX Open Cup named after E.V. Pankratiev. Grand Prix of Peterhof/E.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 2000000+5; 4 | int x,y; 5 | double dp[maxn][2]; 6 | inline void gao(int son,int u){ 7 | double rest_0 = 0; 8 | double rest_1 = 0; 9 | rest_0 = dp[son][0] /2 + dp[u][0] / 2; 10 | rest_1 = dp[son][1] / 2 + dp[u][1] / 2; 11 | dp[u][0] = rest_0; 12 | dp[u][1] = rest_1; 13 | } 14 | void work(int u){ 15 | int lson = u * 2; 16 | int rson = lson + 1; 17 | if (lson <= x + y)work(lson); 18 | if (rson <= x+y) work(rson); 19 | if (u <= x){ 20 | dp[u][0] = 1; 21 | dp[u][1] = 0; 22 | }else{ 23 | dp[u][0] = 0; 24 | dp[u][1] = 1; 25 | } 26 | if (rson <= x+y){ 27 | gao(rson,u); 28 | } 29 | if (lson <= x + y){ 30 | gao(lson,u); 31 | } 32 | } 33 | int main(){ 34 | scanf("%d%d",&x,&y); 35 | work(1); 36 | printf("%.9lf\n",dp[1][1]); 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /XIX Open Cup named after E.V. Pankratiev. Grand Prix of Peterhof/F.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python2 2 | n = input() 3 | print ''.join(map(lambda x : 'B' if x % 5 == 0 else 'F', map(int, raw_input().split()))) 4 | -------------------------------------------------------------------------------- /XIX Open Cup named after E.V. Pankratiev. Grand Prix of Peterhof/H.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int main() 11 | { 12 | int l=1,r=INF; 13 | for(int i=1;i<=100;i++) 14 | { 15 | int x;scanf("%d",&x); 16 | int mid=(l+r)/2; 17 | if(l==r&&x==r) 18 | { 19 | printf("=\n"); fflush(stdout); 20 | return 0; 21 | } 22 | if(x<=mid) 23 | { 24 | printf(">\n"); fflush(stdout); 25 | l=max(l,x+1); 26 | } 27 | else 28 | { 29 | printf("<\n"); fflush(stdout); 30 | r=min(r,x-1); 31 | } 32 | } 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /XIX Open Cup named after E.V. Pankratiev. Grand Prix of Peterhof/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XIX Open Cup named after E.V. Pankratiev. Grand Prix of Peterhof/statements.pdf -------------------------------------------------------------------------------- /XIX Open Cup named after E.V. Pankratiev. Grand Prix of SPb, Division 1/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XIX Open Cup named after E.V. Pankratiev. Grand Prix of SPb, Division 1/statements.pdf -------------------------------------------------------------------------------- /XIX Open Cup named after E.V. Pankratiev. Grand Prix of Siberia/1.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python2 2 | n = input() 3 | x = map(int, raw_input().split()) 4 | nz = x.count(0) 5 | if nz == 1 : 6 | print 'No' 7 | exit(0) 8 | if nz > 1 : 9 | print 'Yes' 10 | print 0 11 | exit(0) 12 | prod = 1 13 | for a in x : 14 | prod *= a 15 | if abs(prod) > 1e18 + 5 : 16 | print 'No' 17 | exit(0) 18 | for a in x : 19 | if a * a == prod : 20 | print 'Yes' 21 | print a 22 | exit(0) 23 | print 'No' 24 | -------------------------------------------------------------------------------- /XIX Open Cup named after E.V. Pankratiev. Grand Prix of Siberia/4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int n; 16 | int d[2048][2048]; 17 | 18 | int main() { 19 | scanf("%d", &n); 20 | Rep (i, n) Rep (j, n) scanf("%d", &d[i][j]); 21 | Rep (k, n) Rep (i, n) { 22 | for (int j = (k != n and i != n) ? n : 1; j <= n; j++) { 23 | d[i][j] = min(d[i][j], d[i][k] + d[k][j]); 24 | } 25 | } 26 | Rep (i, n) Rep (j, n) printf("%d%c", d[i][j], j == n ? '\n' : ' '); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /XIX Open Cup named after E.V. Pankratiev. Grand Prix of Siberia/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XIX Open Cup named after E.V. Pankratiev. Grand Prix of Siberia/statements.pdf -------------------------------------------------------------------------------- /XVII Open Cup named after E.V. Pankratiev. Grand Prix of America (NAIPC-2017)/J.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 0; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int main() { 16 | string a; 17 | cin >> a; 18 | printf("%d", count(range(a), 'W') == count(range(a), 'B')); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /XVII Open Cup named after E.V. Pankratiev. Grand Prix of America (NAIPC-2017)/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XVII Open Cup named after E.V. Pankratiev. Grand Prix of America (NAIPC-2017)/statements.pdf -------------------------------------------------------------------------------- /XVII Open Cup named after E.V. Pankratiev. Grand Prix of Moscow Workshops/G.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 1000005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | string str; 9 | int main() 10 | { 11 | cin>>str; 12 | int n=(int)str.size(); 13 | int ans=0,lid=-1,rid=-1; 14 | for(int i=0;i=0;i--) 19 | { 20 | if(str[i]=='R') ans++; else {rid=i; break;} 21 | } 22 | if(lid>rid||lid==-1||rid==-1) printf("%d\n",ans); else printf("%d\n",ans+1); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /XVII Open Cup named after E.V. Pankratiev. Grand Prix of Moscow Workshops/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XVII Open Cup named after E.V. Pankratiev. Grand Prix of Moscow Workshops/statements.pdf -------------------------------------------------------------------------------- /XVII Open Cup named after E.V. Pankratiev. Grand Prix of Two Capitals/C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | int n,l,r; 5 | string str; 6 | int main() 7 | { 8 | scanf("%d%d%d",&n,&l,&r); 9 | for(int i=0;i<(r-l+1)/2;i++) str+="[]"; 10 | int a=l-1,b=n-r; 11 | while(a>b) str="()"+str,a-=2; 12 | while(b>a) str=str+"()",b-=2; 13 | while(a) str="("+str+")",a--; 14 | cout< 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int n; 16 | int x[100005], r[100005]; 17 | 18 | [[noreturn]] void fail() { 19 | cout << -1 << endl; 20 | exit(0); 21 | } 22 | 23 | int main() { 24 | scanf("%d", &n); 25 | rep (i, n) scanf("%d%d", x + i, r + i); 26 | int lptr = 0, xmax = x[0] + r[0]; 27 | for (int i = 1; i < n; i++) { 28 | if (x[i] > xmax) fail(); 29 | xmax = max(xmax, x[i] + r[i]); 30 | while (lptr < i and x[lptr] >= x[i] - r[i]) lptr++; 31 | } 32 | if (lptr != n - 1) fail(); 33 | cout << (x[n-1] - x[0]) * 3ll << endl; 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /XVII Open Cup named after E.V. Pankratiev. Grand Prix of Two Capitals/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XVII Open Cup named after E.V. Pankratiev. Grand Prix of Two Capitals/statements.pdf -------------------------------------------------------------------------------- /XVII Open Cup named after E.V. Pankratiev. XXI Ural Championship/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XVII Open Cup named after E.V. Pankratiev. XXI Ural Championship/statements.pdf -------------------------------------------------------------------------------- /XVIII Open Cup named after E.V. Pankratiev. Eastern Grand Prix/D.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | string str; 11 | vector v; 12 | 13 | int main() 14 | { 15 | cin>>str; 16 | int n=str.size(); 17 | bool f=true; 18 | v.resize(n); 19 | for(int i=n-1;i>=0;i--) 20 | { 21 | v[i]=f; 22 | if(str[i]!='9') f=false; 23 | } 24 | int cur=9; 25 | for(int i=0;i 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | LL a, b, tot; 16 | 17 | 18 | int main() { 19 | cin >> a >> b; a--; b--; 20 | tot = a + b; 21 | LL beg = (tot + 1) * (tot + 2) / 2; 22 | if (tot & 1) { 23 | beg -= b; 24 | } else { 25 | beg -= a; 26 | } 27 | cout << beg << endl; 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /XVIII Open Cup named after E.V. Pankratiev. Eastern Grand Prix/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int len; 16 | string str; 17 | bool occ; 18 | 19 | bool ok() { 20 | for (char& ch : str) { 21 | if (ch == 'A') { 22 | if (occ) return false; 23 | } else if (ch == '!') { 24 | occ = true; 25 | } else return false; 26 | } 27 | return str.front() == 'A' and str.back() == '!'; 28 | } 29 | 30 | int main() { 31 | cin >> str; 32 | len = str.size(); 33 | if (ok()) { 34 | puts("Panic!"); 35 | } else { 36 | puts("No panic"); 37 | } 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /XVIII Open Cup named after E.V. Pankratiev. Eastern Grand Prix/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XVIII Open Cup named after E.V. Pankratiev. Eastern Grand Prix/statements.pdf -------------------------------------------------------------------------------- /XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Eurasia/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Eurasia/statements.pdf -------------------------------------------------------------------------------- /XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Gomel/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | long long a,h; 9 | int main() 10 | { 11 | scanf("%lld%lld",&a,&h); 12 | printf("%lld\n",a*h); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Gomel/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Gomel/statements.pdf -------------------------------------------------------------------------------- /XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Khamovniki/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Khamovniki/statements.pdf -------------------------------------------------------------------------------- /XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Korea/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Korea/statements.pdf -------------------------------------------------------------------------------- /XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Peterhof/A.py: -------------------------------------------------------------------------------- 1 | fn = [ 2 | lambda x : 1 - 3 * x + 3 * x * x , 3 | lambda x : -2 * x + 3 * x * x, 4 | lambda x : -x + 3 * x * x, 5 | lambda x : 3 * x * x, 6 | lambda x : x + 3 * x * x, 7 | lambda x : 2 * x + 3 * x * x 8 | ] 9 | 10 | def f(x) : 11 | if x < 6 : return 0 12 | return fn[x % 6](x / 6) 13 | 14 | def bsch(x) : 15 | l, r = 0, 500000 16 | while l < r : 17 | mid = (l + r) / 2 18 | if f(mid) >= x : 19 | r = mid 20 | else : 21 | l = mid + 1 22 | return l 23 | 24 | print bsch(input()) 25 | -------------------------------------------------------------------------------- /XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Peterhof/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | string str; 11 | set s; 12 | char ch[4]={'N','W','E','S'}; 13 | int main() 14 | { 15 | cin>>str; 16 | for(int i=0;i<(int)str.size();i++) s.insert(str[i]); 17 | if(s.size()<2) 18 | { 19 | puts("X"); 20 | return 0; 21 | } 22 | if(s.size()==2&&s.count('E')&&s.count('W')) {puts("X"); return 0;} 23 | if(s.size()==2&&s.count('N')&&s.count('S')) {puts("X"); return 0;} 24 | vector v; v.clear(); 25 | for(int i=0;i<4;i++) if(!s.count(ch[i])) v.push_back(ch[i]); 26 | for(int i=0;i<(int)v.size();i++) 27 | for(int j=0;j<50;j++) 28 | printf("%c",v[i]); 29 | printf("\n"); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Peterhof/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Peterhof/statements.pdf -------------------------------------------------------------------------------- /XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Romania/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Romania/statements.pdf -------------------------------------------------------------------------------- /XVIII Open Cup named after E.V. Pankratiev. Grand Prix of SPb/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 2000005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | int n,a[MAXN]; 10 | string str; 11 | int main() 12 | { 13 | cin>>str;n=str.size(); 14 | for(int i=0;i<(int)str.size();i++) 15 | if(str[i]=='1') a[n-1-i]++; 16 | cin>>str;n=str.size(); 17 | for(int i=0;i<(int)str.size();i++) 18 | if(str[i]=='1') a[n-1-i]++; 19 | for(int i=0;i<=2000000;i++) 20 | if(a[i]>=2) 21 | { 22 | a[i+2]+=a[i]/2;a[i+3]+=a[i]/2; 23 | a[i]%=2; 24 | } 25 | bool f=false; 26 | for(int i=2000000;i>=0;i--) 27 | { 28 | if(a[i]) f=true; 29 | if(f) printf("%d",a[i]); 30 | } 31 | if(!f) puts("0"); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /XVIII Open Cup named after E.V. Pankratiev. Grand Prix of SPb/L.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | ll n,x,s; 11 | int main() 12 | { 13 | scanf("%lld",&n); 14 | s=0; 15 | for(int i=0;i ord(v) : b += 1 5 | 6 | print(a) 7 | print(b) 8 | -------------------------------------------------------------------------------- /XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Siberia/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Siberia/statements.pdf -------------------------------------------------------------------------------- /XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Ukraine/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | typedef long long ll; 9 | typedef pair P; 10 | int N,M,mx,x; 11 | map cnt; 12 | int main() 13 | { 14 | scanf("%d%d",&N,&M); 15 | x=mx=0; 16 | for(int i=0;i 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | using namespace std; 7 | typedef long long ll; 8 | typedef pair P; 9 | ll L,R,Q; 10 | int main() 11 | { 12 | scanf("%lld%lld%lld",&L,&R,&Q); 13 | if(Q>R) {puts("infinity"); return 0;} 14 | L=max(L,Q); 15 | ll l=L-L%Q,r=R-R%Q; 16 | if(l==r) 17 | { 18 | if(r==0) {puts("infinity"); return 0;} 19 | ll ans=0; 20 | for(ll i=1;i*i<=l;i++) 21 | { 22 | if(l%i) continue; 23 | ans++; 24 | if(i*i!=l) ans++; 25 | } 26 | printf("%lld\n",ans); 27 | return 0; 28 | } 29 | ll ans=0; 30 | for(ll i=1;i*i<=Q;i++) 31 | { 32 | if(Q%i) continue; 33 | ans++; 34 | if(i*i!=Q) ans++; 35 | } 36 | printf("%lld\n",ans); 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Urals/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XVIII Open Cup named after E.V. Pankratiev. Grand Prix of Urals/statements.pdf -------------------------------------------------------------------------------- /XX Open Cup named after E.V. Pankratiev. Grand Prix of Kazan/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XX Open Cup named after E.V. Pankratiev. Grand Prix of Kazan/statements.pdf -------------------------------------------------------------------------------- /XX Open Cup named after E.V. Pankratiev. Grand Prix of SPb/A.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | import sys 3 | mod = 1000000007 4 | 5 | def polymul(a, b) : 6 | p = [0] * (len(a) + len(b) - 1) 7 | for e1, c1 in enumerate(a) : 8 | for e2, c2 in enumerate(b) : 9 | p[e1+e2] += c1 * c2 % mod 10 | return p 11 | 12 | def interpol(x, y, n) : 13 | lj = [reduce(polymul, [[-x[m] * pow(x[j]-x[m], mod - 2, mod), pow(x[j]-x[m], mod - 2, mod)] 14 | for m in range(n) if m != j]) for j in range(n)] 15 | return map(sum, zip(*map(lambda a, b : [x*a for x in b], y, lj))) 16 | 17 | def ask(x) : 18 | print 'ask', x 19 | sys.stdout.flush() 20 | return input() 21 | 22 | x = [0] 23 | y = [ask(0)] 24 | for deg in range(1, 100) : 25 | x.append(deg) 26 | y.append(ask(deg)) 27 | poly = interpol(x, y, len(x)) 28 | if poly[-1] % mod == 0 : 29 | print 'degree', deg - 1 30 | exit(0) 31 | 32 | -------------------------------------------------------------------------------- /XX Open Cup named after E.V. Pankratiev. Grand Prix of SPb/E.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python2 2 | for _ in range(input()) : 3 | x, y = map(int, raw_input().split()) 4 | if not y : 5 | print 'Yes' 6 | else : 7 | while y % 2 == 0 : y >>= 1 8 | if bin(y)[2:] in bin(x) : 9 | print 'Yes' 10 | else : 11 | print 'No' 12 | -------------------------------------------------------------------------------- /XX Open Cup named after E.V. Pankratiev. Grand Prix of SPb/I.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define MAXN 100005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | string s,t; 9 | int n,m,now; 10 | int parity=0; 11 | int main() 12 | { 13 | cin>>s; 14 | cin>>t; 15 | n=(int)s.size(); m=(int)t.size(); 16 | if((n&1)!=(m&1)) {puts("NO"); return 0;} 17 | for(int i=0;i 2 | using namespace std; 3 | const int maxn = 1e5 + 100; 4 | typedef long long ll; 5 | ll a[maxn]; 6 | ll sum[maxn]; 7 | ll n,L; 8 | int main(){ 9 | cin>>n; 10 | for (int i=1;i<=n;i++){ 11 | int A,B; 12 | cin>>A>>B; 13 | a[i] = min(A,B); 14 | } 15 | cin>>L; 16 | sort(a + 1,a + 1 + n); 17 | for (int i=1;i<=n;i++){ 18 | sum[i] = sum[i-1] + a[i]; 19 | } 20 | for (int ans = n;ans >= 0;ans --){ 21 | if (ans == 1){ 22 | cout<<1<=2){ 27 | temp = sum[ans - 2] + 1.0 * (a[ans] + a[ans-1]) / 2; 28 | }else{ 29 | temp = 1.0 *sum[ans] / 2; 30 | } 31 | if (temp < L){ 32 | cout< 2 | #define MAXN 1005 3 | #define INF 1000000000 4 | #define MOD 1000000007 5 | #define F first 6 | #define S second 7 | using namespace std; 8 | int n,m; 9 | char str[MAXN][MAXN]; 10 | int ans1,ans2; 11 | int main() 12 | { 13 | scanf("%d%d",&n,&m); 14 | for(int i=0;i 2 | using namespace std; 3 | 4 | #define rep(i, n) for (int i = 0; i < int(n); i++) 5 | #define Rep(i, n) for (int i = 1; i <=int(n); i++) 6 | #define range(x) begin(x), end(x) 7 | #ifdef __LOCAL_DEBUG__ 8 | #define _debug(fmt, ...) fprintf(stderr, "[%s] " fmt "\n", __func__, ##__VA_ARGS__) 9 | #else 10 | #define _debug(...) ((void) 0) 11 | #endif 12 | typedef long long LL; 13 | typedef unsigned long long ULL; 14 | 15 | int n; 16 | int a[1024]; 17 | 18 | int main() { 19 | scanf("%d", &n); 20 | rep (i, n) scanf("%d", a + i); 21 | for (int i = 1; i < n; i++) a[i] = (a[i-1] / a[i] + 1) * a[i]; 22 | rep (i, n) printf("%d ", a[i]); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /XX Open Cup named after E.V. Pankratiev. Grand Prix of Siberia/statements.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wcysai/Calabash/9527fa7ffa7e30e245c2d224bb2fb77a03600ac2/XX Open Cup named after E.V. Pankratiev. Grand Prix of Siberia/statements.pdf -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | This is the code library of ACM/ICPC Team Calabash! from Nanjing University. 2 | 3 | The team members: 4 | 5 | Chen Shaoyuan (sy_chen) 6 | 7 | Wang Dongyang (calabash_boy) 8 | 9 | Wang Chunyang (Roundgod) 10 | 11 | The team wiki: https://wiki-calabash.icpc.camp 12 | -------------------------------------------------------------------------------- /sh.exe.stackdump: -------------------------------------------------------------------------------- 1 | Stack trace: 2 | Frame Function Args 3 | 00000010000 0018006133E (0018025BEB0, 0018024E199, 00000010000, 000FFFFBA00) 4 | 00000010000 00180049229 (00100002000, 00000000002, 00000000002, 00180339530) 5 | 00000010000 00180049262 (00000000002, 00180339840, 00000010000, 00000000008) 6 | 00000010000 0018005A98C (00000000000, 0018024E48F, 0018004A6FE, 635C655C785C655C) 7 | 000FFFFCCD0 0018005AA30 (745C685C275C205C, 3A5C735C705C745C, 695C675C2F5C2F5C, 625C755C685C745C) 8 | 000FFFFCCD0 001800499EC (00000000000, 00000000000, 00000000000, 00000000000) 9 | 00000000000 00180048343 (00000000000, 00000000000, 00000000000, 00000000000) 10 | 000FFFFFFF0 001800483F4 (00000000000, 00000000000, 00000000000, 00000000000) 11 | End of stack trace 12 | --------------------------------------------------------------------------------