【CF Round #545】C. Museums Tour

Description:


一张\(n\)个点\(m\)条边的有向图,每个点有一个博物馆,一个星期有\(d\)天,每个博物馆在一周中某几天固定开放,初始时在\(1\)号点,星期\(1\),如果当天你所在的点的博物馆开放,则可以进入参观,每天结束时,可以沿着有向边进入相邻的点。

问最多可以参观多少个不同的博物馆。

\(n,m\leq 10^5, d\leq 50\)

Examples:


input1 output1
4 5 3
3 1
1 2
2 4
4 1
2 3
011
110
111
001
3
input2 output2
3 3 7
1 2
1 3
2 3
1111111
0000000
0111111
2

Solution:


首先拆点,将每个点拆成\(d\)个,代表不同星期,原图中的每条边改为\(d\)条。

这样用tarjan缩点后剩下的DAG中每个SCC中的点都可以互相到达,于是统计每个SCC中开放的不同的博物馆的数量。之后在DAG上DP。

会有个问题就是可能同一个点在不同SCC中重复计算了。但仔细思考后发现不会有这样的情况。原因如下:

假设第\(i\)个点星期\(j\)代表的点为\((i, j)\),如果存在路径\((i, j) \rightarrow (i, j’) (j \neq j’) \),则设\(\Delta T=(j’-j+d)\%d \),必同时存在路径\((i, k) \rightarrow (i, (k + \Delta T)\%d) \), \((k\in (0, d – 1))\),因此,若\( j’ + k\Delta T \equiv j (\mathbf {mod}\;d)\)有正整数解,则同时存在路径\((i,j’) \rightarrow (i, j)\),又因为\(j + \Delta T \equiv j’ (\mathbf {mod}\;d)\),带入原方程可化为\((k + 1)\Delta T \equiv 0 (\mathbf {mod} \; d)\), 显然存在正整数解\(k=2d-1\),因此\((i,j),(i,j’)\),在同一个SCC中。

所以DAG上直接DP就可以了。

Code:

 


82 评论

  1. Berberis vulgaris es un medicamento homeopГЎtico obtenido a partir del agracejo, un arbusto de la familia de las berberidГЎceas que tiene la particularidad
    vena cava
    Cancer de riГ±Гіn contractura lumbar sintomas

  2. Pensacola Beach, Florida, es uno de los destinos mГЎs populares de la Costa del Golfo en el noroeste de Florida. Alineada con lujosos condominios frente
    social security medicare
    Recursos disponibles para los residentes del condado de Fremont durante el cierre del gobierno Canon City Daily registra mi cuenta de seguridad social Obtenga una nueva tarjeta de seguridad social, nГєmero de telГ©fono de seguridad social, cambio de nombre de seguridad social, oficina de administraciГіn de seguridad social, oficinas de seguridad social

  3. 萨姆拉酒店 е­џд№° – 2星级酒店. 2星级优雅的Hotel SamrajжЏђдѕ›24е°Џж—¶жњЌеЉЎеЏ°жњЌеЉЎпјЊйљЏеЏ«дёЉй—ЁеЊ»з”џжњЌеЉЎе’ЊжЉҐе€ЉжњЌеЉЎгЂ‚
    What is reflexology good for

  4. No.0001 – Login – Dataпјљ2005/10/18 Last Updateпјљ2005/11/07 еђЌ е‰Ќпјљ гЃѕгЃЎг‚ѓ: жЂ§ 別: 女: гѓ¬гѓ™гѓ«пјљ 37: タイプ: スピリチュアリスト
    Haldol in elderly

  5. Feminist theory is one of the major contemporary sociological theories, which analyzes the status of women and men in society with the purpose of using that knowledge to better womens lives. Feminist theory is most concerned with giving a voice to women and highlighting the various ways women have contributed to society.
    anxiety meaning in hindi symptoms

  6. Other more rare causes of abdominal muscle spasms are diverticulitis, intussusception, hernia, cholecystitis, and bowel obstruction. Treatment for Abdominal Muscle Spasms After discovering the cause of your abdominal muscle spasms, you must seek treatment options.
    north korea

  7. Hello! kkeevviinnn.com

    We suggesting

    Sending your business proposition through the feedback form which can be found on the sites in the Communication partition. Contact form are filled in by our program and the captcha is solved. The superiority of this method is that messages sent through feedback forms are whitelisted. This method improve the chances that your message will be read.

    Our database contains more than 25 million sites around the world to which we can send your message.

    The cost of one million messages 49 USD

    FREE TEST mailing of 50,000 messages to any country of your choice.

    This message is automatically generated to use our contacts for communication.

    Contact us.
    Telegram – @FeedbackFormEU
    Skype FeedbackForm2019
    Email – FeedbackForm@make-success.com
    WhatsApp – +44 7598 509161

  8. It starts with plaque accumulation on the surface of the teeth, which then turns into tartar. This traps oral bacteria at the gum line, causing bad breath. The trapped bacteria multiply and produce toxins that can lead to painful infections, loosening of the attachments of gums to teeth, bone loss and eventual tooth loss. Even worse, these toxins dont remain only inside the mouth of the cat
    Tartar buildup on teeth removal

  9. Hello! kkeevviinnn.com

    We present oneself

    Sending your commercial offer through the feedback form which can be found on the sites in the contact section. Contact form are filled in by our program and the captcha is solved. The advantage of this method is that messages sent through feedback forms are whitelisted. This technique improve the chances that your message will be open.

    Our database contains more than 25 million sites around the world to which we can send your message.

    The cost of one million messages 49 USD

    FREE TEST mailing of 50,000 messages to any country of your choice.

    This message is automatically generated to use our contacts for communication.

    Contact us.
    Telegram – @FeedbackFormEU
    Skype FeedbackForm2019
    WhatsApp – +44 7598 509161
    Email – FeedbackForm@make-success.com

  10. 关于ELISA实验,我用biotin小分子(没有连接蛋白分子)直接包被,然后再与streptavidin结合可以吗?用什么包被液呢? 回复此楼: » 猜你喜欢
    Foods that contain biotin

  11. Causes. Descriptions. Trauma. Trauma to the nail bed (slamming it in the car door), excessive stress to the nails (think acrylics and frequent polish changes), and other damage can cause brittle nails. Bad Habits. Smoking, excessive alcohol consumption and biting the nails all can cause weak, brittle nails. Aging. As we age, the fingernail also ages. The aging process causes lack of collagen and keratin, a decrease in moisture, and dull, yellowish nails.
    Brittle flaky nails

  12. eGifter is a popular gift card site and mobile app that lets users buy gift cards for all sorts of places, including Amazon, JCPenny, Sephora, Home Depot, Kohls and more. eGifter uses Coinbase as their bitcoin partner.
    bitcoin pool

  13. Per Bloomberg, the new rules will apply to a wide gamut of businesses dealing with cryptocurrencies and tokens — including crypto exchanges, custodians and crypto hedge funds. FATF is an intergovernmental organization established on the initiative of the G7 to promote the implementation of legal, regulatory and operational measures to fight money laundering.
    bitcoin crash

  14. minutes. over half of them are dying in a home environment. they are not dying in alleys, they are dying in bathrooms and bedrooms and garages and until we can invent an ambulance that can get to your house in 4 to 6 minutes which is the amount of time it takes for anoxic brain injury to occur, we are not going to turn around the opioid overdose epidemic until more people are willing to carry
    postanoxic encephalopathy

  15. Hi! kkeevviinnn.com

    We put up of the sale

    Sending your commercial proposal through the Contact us form which can be found on the sites in the contact section. Feedback forms are filled in by our software and the captcha is solved. The advantage of this method is that messages sent through feedback forms are whitelisted. This technique improve the probability that your message will be open.

    Our database contains more than 25 million sites around the world to which we can send your message.

    The cost of one million messages 49 USD

    FREE TEST mailing of 50,000 messages to any country of your choice.

    This message is automatically generated to use our contacts for communication.

    Contact us.
    Telegram – @FeedbackFormEU
    Skype FeedbackForm2019
    WhatsApp – +44 7598 509161
    Email – FeedbackForm@make-success.com

  16. Excellent post. I was checking constantly this blog and I’m impressed! Extremely useful information specially the last part 🙂 I care for such information a lot. I was seeking this certain info for a very long time. Thank you and good luck.

  17. I loved as much as you’ll receive carried out right here. The sketch is tasteful, your authored material stylish. nonetheless, you command get got an shakiness over that you wish be delivering the following. unwell unquestionably come more formerly again since exactly the same nearly very often inside case you shield this increase.

  18. Normally I don’t read post on blogs, however I wish to say that this write-up very pressured me to take a look at and do it! Your writing style has been amazed me. Thank you, very great post.

  19. Hello! kkeevviinnn.com

    We offer

    Sending your commercial offer through the Contact us form which can be found on the sites in the Communication partition. Contact form are filled in by our software and the captcha is solved. The advantage of this method is that messages sent through feedback forms are whitelisted. This method improve the chances that your message will be open.

    Our database contains more than 25 million sites around the world to which we can send your message.

    The cost of one million messages 49 USD

    FREE TEST mailing of 50,000 messages to any country of your choice.

    This message is automatically generated to use our contacts for communication.

    Contact us.
    Telegram – @FeedbackFormEU
    Skype FeedbackForm2019
    Email – FeedbackForm@make-success.com
    WhatsApp – +44 7598 509161

  20. We buy all crypto currencies at good rate, with reasonable commission between sellers and the mandates.

    Contact us with the informations below if you are or have a potential seller.

    Tel: +353 1 4378345
    Fax: +353 1 6865354
    Email: edwardm@lioncourtcrypto.com

    Thank you,
    Crypto currencies Purchase Department,
    Edward Molina.

  21. [url=https://egexefufohyv.tk/]buy zocor[/url] [url=https://dimenunefa.tk/]colchicine[/url] [url=https://onubyjiqaw.tk/]trimox without prescription[/url] [url=https://yzabykyfem.ga/]skelaxin[/url] [url=https://ofunogin.tk/]amoxil 500 mg[/url] [url=https://kekuwokupalu.tk/]buy prednisolone[/url] [url=https://picixutasudu.ga/]paroxetine cost without insurance[/url] [url=https://iqigulefij.ga/]himcolin[/url] [url=https://izasosifarit.tk/]stromectol online[/url] [url=https://opamitusuh.tk/]where to buy motilium[/url] [url=https://cobelexigamu.gq/]buy celebrex[/url] [url=https://ipudanisef.tk/]generic singulair cost[/url] [url=https://wegiragukene.ga/]malegra fxt[/url] [url=https://etyjosikulaz.tk/]albuterol without a prescription[/url] [url=https://owitapenuf.tk/]buy oxytrol[/url] [url=https://vegedyzotesy.tk/]buy brahmi[/url] [url=https://havakadowu.tk/]over the counter sildenafil[/url] [url=https://wyjiruce.tk/]crestor medication[/url] [url=https://pexujujixa.gq/]pamelor aventyl[/url] [url=https://madenopufy.ml/]buy clomid[/url] [url=https://orirateler.tk/]where to buy augmentin[/url] [url=https://akywoduk.tk/]buy kamagra jelly[/url] [url=https://vynybehinovu.tk/]skelaxin drug[/url] [url=https://exacikif.tk/]buy artane[/url] [url=https://eronupyl.tk/]cost of proscar[/url] [url=https://jusevucitave.tk/]buy vasotec[/url] [url=https://silygobolidy.gq/]buy atarax[/url] [url=https://cusumapimiki.tk/]cleocin gel for acne[/url]

发表评论

电子邮件地址不会被公开。 必填项已用*标注