Blog de Qingyu✨

Blogs

Tags
None

暂别

2021-08-03 00:00:00 By Qingyu

比赛可以鸽,暂别不行。

我们几个管理员 Qingyu, Qingyu, Qingyu 和我在过去的半年中,组织和举办了不少的比赛,也还算及时地将官方比赛题目上传到了 QOJ 中。

我一直非常喜欢 UOJ,在去年收到 Qingyu 的邀请后,我思考了一段时间,并决定来当 QOJ 管理,我想为这个美好的 OJ 献出自己的一份力量,让这个 OJ 变得更加好,如今看来,当时的目标也基本实现了。

在当管理的一年中,还是有很多事让我记忆深刻的,还记得 XXI Open Cup named after E.V. Pankratiev, Grand Prix of Siberia; XXI Open Cup named after E.V. Pankratiev, Grand Prix of Eurasia; 7 February, 2021 — Waterloo local contest; NOIP 2020; Petrozavodsk Winter 2021. Day 9. Grand Prix of Suwon; XXI Open Cup named after E.V. Pankratiev; Grand Prix of Suwon; Petrozavodsk Winter 2021. Day 8. Belarusian SU Contest; XXI Open Cup named after E.V. Pankratiev; Grand Prix of Belarus; Petrozavodsk Winter 2021. Day 7. North American Contest 1; Petrozavodsk Winter 2021. Day 6. PKU Contest 2; Petrozavodsk Winter 2021. Day 5. Almost Retired Dandelion Contest; XXI Open Cup named after E.V. Pankratiev; Grand Prix of Nizhny Novgorod; Petrozavodsk Winter 2021. Day 4. PKU Contest (Common Contest 1); Petrozavodsk Winter 2021. Day 3. Nordic+ Contest 2020 (NCPC-2020 with some BAPC/UKIEPC 2020); Petrozavodsk Winter 2021. Day 2. UPC Contest; Petrozavodsk Winter 2021. Day 1. Jagiellonian U Contest; XXI Open Cup named after E.V. Pankratiev; Grand Prix of Krakow; Nordic Collegiate Programming Contest 2020; Potyczki Algorytmiczne 2020; Runda 5; Potyczki Algorytmiczne 2020; Runda 4; Potyczki Algorytmiczne 2020; Runda 3; Potyczki Algorytmiczne 2020; Runda 2; Potyczki Algorytmiczne 2020; Runda 1; Potyczki Algorytmiczne 2020; Runda próbna; 2019-2020 ICPC Northwestern Europe Regional Contest; 2018-2019 ICPC Northwestern Europe Regional Contest; USACO 2020 January Contest (Platinum); USACO 2019 December Contest (Platinum); The 2020 Benelux Algorithm Programming Contest; USACO 2019 February Contest (Platinum); USACO 2019 January Contest (Platinum); USACO 2018 December Contest (Platinum); 2017-2018 ICPC Northwestern Europe Regional Contest; Nordic Collegiate Programming Contest 2019; 2019-2020 ICPC Southwestern Europe Regional Contest; 2020 Canadian Computing Olympiad Day 2; 2020 Canadian Computing Olympiad Day 1; International Olympiad in Informatics 2020 Day 2; International Olympiad in Informatics 2020 Day 1; Petrozavodsk Summer 2020. Day 6. Korean Contest; Petrozavodsk Summer 2020. Day 5. JAG Summer 2019+; Petrozavodsk Summer 2020. Day 4. Xi Lin Contest 6; Petrozavodsk Summer 2020. Day 3. Songyang Chen Contest; Petrozavodsk Summer 2020. Day 2. SPb SU LOUD ENOUGH Contest; XXI Open Cup named after E.V. Pankratiev; Grand Prix of SPb; Petrozavodsk Summer 2020. Day 1. Warsaw U Contest; USACO 2018 February Contest (Platinum); USACO 2018 January Contest (Platinum); USACO 2017 December Contest (Platinum); 2020-2021 ICPC North America - Pacific Northwest Regional Contest - Division 2; 2020-2021 ICPC North America - Pacific Northwest Regional Contest - Division 1; 2020-2021 ICPC North America - Mid-Atlantic USA Regional Contest; 2020-2021 ICPC North America - Mid-Central USA Programming Contest; 2020-2021 ICPC North America - East Central NA Regional Contest; 2020-2021 ICPC North America - Rocky Mountain Regional Contest; 2019-2020 ICPC North America - Rocky Mountain Regional Contest; Russia Open 2020 High School Team Programming Contest 2020-09-08 08:30:00 3 hours 30 minutes No ×0 IOI 2018 中国国家队清华集训 Day 4 (CTT 2017 Day 4); IOI 2018 中国国家队清华集训 Day 3 (CTT 2017 Day 3); IOI 2018 中国国家队清华集训 Day 2 (CTT 2017 Day 2); IOI 2018 中国国家队清华集训 Day 1 (CTT 2017 Day 1); 前 D 题发生了一系列事故,导致比赛前一天 Qingyu 哥哥晚上一点多写好 std,我三多造好数据,然后还发现了同样没睡在内卷的 hy,第二天起来一看 Qingyu 说他第一步假了,暴力和 std 都是错的,换上了现在的题意,11 点 Qingyu 写完 std 然后我造数据传好就弃疗了。以及后来的 QOJ Training Series 和 Qingyu 哥哥熬夜造 E 题等等 (主要原因还是我们太鸽),不过相信下一届管理员会比我们做得更好!

现在 NOI 也顺利结束了,又一批 OIer 完成了他们最重要的一战,而 QOJ 也到了换届的环节,下一届将有四个管理员,他们是:

QingyuQingyuQingyuQingyu

祝你们一切顺利,QOJ 越办越好!

一些比赛的资料

2021-06-18 00:32:24 By Qingyu

来自 HY 大神的提醒:注意账户安全,FTP 密码已重置

2021-05-11 12:20:33 By Qingyu

为了避免自己的账户泄露,建议不要在大机房中使用浏览器的“保存密码”功能!!

若认为自己的密码已经泄露,需要在修改密码后使用 登出所有活跃会话 功能,否则此前认证过的会话可能不会失效。

同时,为了避免权限组的题目泄露,hydd 大神指示各位 hy 的粉丝 使用强度较高的密码,请不要使用诸如 12345611451419260817hyakctsilovechino 的弱口令。

FTP 所有账户已重置,请有 FTP 权限的群友查看系统消息获取最新的用户密码。对于 Archive 中一些公开的测试数据,建议大家转至 Google Drive 镜像进行下载。

不建议在博客中写模拟赛题的题解,如果需要写内部题的题解,一定注意添加权限。所有内部题目的讨论博客需要拥有 access-secret-blogs 权限与校内团队(目前有 $12,16,17,19,22$ 五个团队)权限才可以查看。

本公告的最终解释权归 hydd 所有。

Judging environment of QOJ (2025 updated)

2021-03-23 20:32:30 By Qingyu

Last Updated: December 2025

Judgehost Specification

The judgehosts of QOJ are all hosted on Microsoft Azure. All judgehosts have the identical specifications:

  • OS: Ubuntu 24.04.1 LTS
  • RAM: 8 GiB
  • CPU: Intel(R) Xeon(R) Platinum 8570

Language Details

Unless specified in the problem meta page, you may submit your solution in any of our supported languages. Note that IOI and most other Olympiads support C++ exclusively, so problems with graders typically only support C++. Always check the problem meta information before starting!

  • C
  • C++
  • D
  • Fortran
  • Go
  • Haskell
  • Java
  • Kotlin
  • Lean 4.23.0
  • Pascal
  • Python 3 (CPython 3.13 or PyPy 3.11)
  • Ruby
  • Rust

C++ (C++98, C++11, C++14, C++17, C++20, C++23, C++26)

All C++ submissions are compiled using GCC 15.2.0. The detailed compilation tag is as follows:

g++ -o answer -x c++ answer.code -lm -O2 -DONLINE_JUDGE -std=c++XX

The -std=c++XX flag will be set according to your chosen standard (98, 11, 14, 17, 20, or 23).

C (C99, C11)

All C submissions are compiled using GCC 15.2.0. The detailed compilation tag is as follows:

gcc -o answer -x c answer.code -lm -O2 -DONLINE_JUDGE -std=cXX

The -std=cXX flag will be set to either c99 or c11 based on your selection.

Java (Java 8, Java 11, Java 17, Java 21)

Note: As of January 13, 2025, Java 7 and Java 14 are no longer supported by QOJ.

We use Open JDK for all Java submissions.

  • Java 8: openjdk version "1.8.0_462"
  • Java 11: openjdk 11.0.28
  • Java 17: openjdk 17.0.16
  • Java 21: openjdk 21.0.8

Flags -Xmx2048m, -Xss1024m, and -XX:ActiveProcessorCount=1 will be added when running Java programs.

Python (CPython 3.13 / PyPy 3.11)

Note: As of Dec 20, 2023, Python 2 is no longer supported by QOJ.

The Python Interpreters we used are CPython 3.13.7 and PyPy 3.11.

Rust

The Rust compiler we used is rustc 1.92.0 (ded5c06cf 2025-12-08). The detailed compilation tag is as follows:

rustc -o answer -C opt-level=3 --edition=2021 answer.code

D

The D compiler we used is DMD64 D Compiler v2.109.1. The detailed compilation tag is as follows:

dmd answer -O -release -inline -boundscheck=off

Pascal

The Pascal compiler we used is fpc, Free Pascal Compiler version 3.2.2. The detailed compilation tag is as follows:

fpc answer.code -O2

Haskell

The Haskell compiler we used is ghc, The Glorious Glasgow Haskell Compilation System, version 9.4.7. The detailed compilation tag is as follows:

ghc -O2 -rtsopts -XSafe -no-keep-hi-files -no-keep-o-files -static -o answer answer.hs

Kotlin

The Kotlin compiler we used is kotlinc-jvm 2.1.0 (JRE 21.0.5+11-Ubuntu-1ubuntu124.04). The JVM option we used to run Kotlin programs is the same as we used in Java programs.

Go

The Go compiler we used is go version go1.22.2 linux/amd64.

go build -o answer -ldflags -s -w -trimpath

Ruby

The Ruby version we used is Ruby 3.4.8.

Fortran 95 / Fortran 2018

The Fortran compiler we used is GNU Fortran 15.0.1. The detailed compilation tag is as follows:

gfortran -o answer answer.f90  -O2 -DONLINE_JUDGE -std=fX

The -std=fX flag will be set according to your chosen standard (95 or 2018).

Discovery Hailiang Teams

2021-03-01 07:09:20 By Qingyu

Discovery Hailiang Logins

这个东西在若干个群友监督下随机生成的,他们都表示直接通过!

随机生成器是 @Qingyu 瞎写的,有问题就喷他.

在随机现场的 @hydd, @Lenstar 表示这个真的是一次随机生成的.

Login Member 1 Member 2 Member 3
hailiang01 房俊哲 张涵硕 郭思博
hailiang02 贾皓博 楼元培 刘成果
hailiang03 杨久知 徐锐扬 赖可依
hailiang04 蒋帅泉 郑杞珩 胡昊
hailiang05 王鸿翼 时庆钰 潘大卫
hailiang06 姜圻圣 徐子恩 毛艺婷

Yandex Contest 比赛合集

2021-02-20 00:10:12 By Qingyu

因为一些原因去随便找了个爬虫爬了下来所有比赛名称。

下面是部分内容展示,完整版请见附件下载:

Part I: contest.yandex.ru

最后更新:2021.02.19,更新至比赛 id 25209

Название URL
Sample Contest https://contest.yandex.ru/contest/3/enter/
Admin Requests https://contest.yandex.ru/contest/4/enter/
Test Contest #1 - Eternal https://contest.yandex.ru/contest/5/enter/
713 https://contest.yandex.ru/contest/6/enter/
Open Cup in Programming 2008-2009. Round 7. Northern Grand Prix. High division. https://contest.yandex.ru/contest/7/enter/
Contest #187 - Jury Session https://contest.yandex.ru/contest/8/enter/
Ural SU Contest (Petrozavodsk Summer, 2008) https://contest.yandex.ru/contest/9/enter/
Contest #1326 - Jury Session https://contest.yandex.ru/contest/10/enter/
Rocky Mountain SF 2011 https://contest.yandex.ru/contest/11/enter/
Contest 6125 - Jury Session https://contest.yandex.ru/contest/12/enter/
ECNA 2011 https://contest.yandex.ru/contest/13/enter/
ECNA11 - Jury Session https://contest.yandex.ru/contest/14/enter/
Petrozavodsk Training Camp - 2008. Belarusian SU + Kazakhstan Contest https://contest.yandex.ru/contest/15/enter/
CTU Open 2011 https://contest.yandex.ru/contest/17/enter/
CTU Open 2011 - Jury Session https://contest.yandex.ru/contest/18/enter/
Unpredictable Contest 1 - Petrozavodsk Summer, 2008 https://contest.yandex.ru/contest/19/enter/
Unpredictable Contest 1 - Jury Session https://contest.yandex.ru/contest/20/enter/
Petrozavodsk SU WX Contest - Petrozavodsk Summer, 2008 https://contest.yandex.ru/contest/21/enter/
Petrozavodsk SU WX Contest - Jury Session https://contest.yandex.ru/contest/22/enter/
Petrazavodsk 2008, Japanese Contest https://contest.yandex.ru/contest/23/enter/
Andrew Stankevich Contest 18 https://contest.yandex.ru/contest/29/enter/
PTZ 2009, Japanese Contest https://contest.yandex.ru/contest/30/enter/
ACM World Finals 2002 https://contest.yandex.ru/contest/31/enter/
PTZ 2009, day 5 https://contest.yandex.ru/contest/32/enter/
PTZ 2009, day 2 https://contest.yandex.ru/contest/33/enter/
PTZ 2009, day 8 https://contest.yandex.ru/contest/35/enter/
World Finals 2004 https://contest.yandex.ru/contest/36/enter/
World Finals 2005 https://contest.yandex.ru/contest/39/enter/
World Finals 2007 https://contest.yandex.ru/contest/40/enter/
World Finals 2007 (With Standings) https://contest.yandex.ru/contest/41/enter/
ASC, 2009 OpenCup Onsite https://contest.yandex.ru/contest/42/enter/
South Eastern USA https://contest.yandex.ru/contest/43/enter/
PTZ 2009, Ufa tour https://contest.yandex.ru/contest/44/enter/
PTZ2009, ASC 35 https://contest.yandex.ru/contest/45/enter/
Archive https://contest.yandex.ru/contest/46/enter/
Blitz (26 problems) https://contest.yandex.ru/contest/48/enter/
MIPT training camp individual contest 1 https://contest.yandex.ru/contest/53/enter/
ICL Individual Contest virtual https://contest.yandex.ru/contest/54/enter/
MIPT training camp individual contest 2 https://contest.yandex.ru/contest/55/enter/
MIPT Virtual https://contest.yandex.ru/contest/56/enter/
MIPT Virtual 2 https://contest.yandex.ru/contest/57/enter/
A+B Virtual https://contest.yandex.ru/contest/59/enter/
CPR Beta 1 https://contest.yandex.ru/contest/60/enter/
TRGI Day-1 https://contest.yandex.ru/contest/61/enter/
TRGI Day-2 https://contest.yandex.ru/contest/62/enter/
TRGI Day-3 https://contest.yandex.ru/contest/63/enter/
Mirror of XI Open Cup Onsite https://contest.yandex.ru/contest/64/enter/
Moscow Subregional 2006 https://contest.yandex.ru/contest/65/enter/
Moscow Subregional 2008 https://contest.yandex.ru/contest/68/enter/
Moscow Subregional - 2009 https://contest.yandex.ru/contest/72/enter/
Computer Science Center, 1 семестр, упражнения https://contest.yandex.ru/contest/74/enter/
Northern Subregional 2006 https://contest.yandex.ru/contest/75/enter/
Dummy https://contest.yandex.ru/contest/76/enter/
Д/з 3 - A* https://contest.yandex.ru/contest/77/enter/
Яндекс.Контест https://contest.yandex.ru/contest/79/enter/
Northern Subregional 2007 https://contest.yandex.ru/contest/81/enter/
Northern Subregional 2008 https://contest.yandex.ru/contest/84/enter/
SPbAU Homework 1 https://contest.yandex.ru/contest/85/enter/
Test contest for monitoring https://contest.yandex.ru/contest/87/enter/
Яндекс.Контест https://contest.yandex.ru/contest/88/enter/
SPbAU Theoretical Minimum https://contest.yandex.ru/contest/92/enter/
Northern Subregional 2009 https://contest.yandex.ru/contest/93/enter/
Western Subregional 2009 https://contest.yandex.ru/contest/94/enter/
Quarterfinal 1: Moscow-2012 https://contest.yandex.ru/contest/96/enter/
Quarterfinal 2: Western-2012 https://contest.yandex.ru/contest/97/enter/
Quarterfinal 3: Northern-2012 https://contest.yandex.ru/contest/98/enter/
SPbAU Homework 2 https://contest.yandex.ru/contest/99/enter/
Яндекс.Контест https://contest.yandex.ru/contest/102/enter/
Computer Science Center, 1 семестр, домашнее задание https://contest.yandex.ru/contest/103/enter/
Семинар 19.10.12 - Алгоритмы на графах https://contest.yandex.ru/contest/105/enter/
Central Subregional 2012 https://contest.yandex.ru/contest/110/enter/
Southern Subregional 2012 https://contest.yandex.ru/contest/111/enter/
SPbAU Aftersolving https://contest.yandex.ru/contest/112/enter/
Eastern Subregional 2012 https://contest.yandex.ru/contest/113/enter/
WQF12-Pre https://contest.yandex.ru/contest/114/enter/
Д/з 5 - Биномиальная куча https://contest.yandex.ru/contest/115/enter/
Д/з 6 - Максимальный поток https://contest.yandex.ru/contest/116/enter/
Яндекс.Контест https://contest.yandex.ru/contest/117/enter/
Д/з 7 - Дерево Фенвика https://contest.yandex.ru/contest/119/enter/
BAPC 2012 https://contest.yandex.ru/contest/120/enter/
Northern Subregional MIPT Run https://contest.yandex.ru/contest/121/enter/
All-Siberian Olympiad 2008, Day 2 https://contest.yandex.ru/contest/122/enter/
NCPC 2012 https://contest.yandex.ru/contest/123/enter/
MIPT Training Camp Entry Contest: CTU Open 2012 https://contest.yandex.ru/contest/124/enter/
Д/з 8 - Дерево отрезков + LCA + RMQ https://contest.yandex.ru/contest/125/enter/
Rocky Mountain Regional 2012 https://contest.yandex.ru/contest/126/enter/
MIPT Training camp team blitz 1 (12.11.2012) https://contest.yandex.ru/contest/128/enter/
MIPT Training camp team PTZ Selection 1 (13.11.2012) https://contest.yandex.ru/contest/129/enter/
MIPT Training camp team short contest 1 (12.11.2012) https://contest.yandex.ru/contest/130/enter/
MIPT Training camp team blitz 2 (13.11.2012) https://contest.yandex.ru/contest/131/enter/
Д/з 9 - Декартово дерево https://contest.yandex.ru/contest/132/enter/
MIPT Training camp 3D Contest (14.11.2012) https://contest.yandex.ru/contest/133/enter/
Яндекс.Контест https://contest.yandex.ru/contest/134/enter/
MIPT Training camp personal contest https://contest.yandex.ru/contest/135/enter/
MIPT Training camp 2D contest (15.11.2012) https://contest.yandex.ru/contest/136/enter/
MIPT Training camp Graph contest (16.11.2012) https://contest.yandex.ru/contest/137/enter/
MIPT Training camp short contest 2 (17.11.2012) https://contest.yandex.ru/contest/139/enter/
MIPT Training camp Math contest (17.11.2012) https://contest.yandex.ru/contest/141/enter/
MIPT Training camp Final Contest 1 (18.11.2012) https://contest.yandex.ru/contest/143/enter/
MIPT Training camp Final contest 2 (19.11.2012) https://contest.yandex.ru/contest/144/enter/

……

下载附件

迁移

2020-10-13 19:29:37 By Qingyu

不写了

XXI Open Cup 新闻合集

2020-09-29 15:47:48 By Qingyu

本帖所有内容均来自 Open Cup News 频道(https://t.me/opencup_ru), 若信息有冲突请以频道内容为准.

本帖所提及的发帖时间均指莫斯科时间 (UTC +3)

  • 05/27/2020 18:48: The rules for the next season will be adjusted soon, so stay tuned
  • 09/24/2020 13:03: The next season starts with GP of Eurasia at the Sep 27, followed by some GP based on one of Petrozavodsk problemsets in a week and the GP of Korea in two weeks.
  • 09/25/2020 14:24: New changes in the OpenCup rules are coming. First, there will be no Div 1 Yandex Sponsor Championship for NERC ICPC teams this year. Second: the team with participant who is author or tester of the some Grand Prix, earns the team's season average score for this Grand Prix (note that this value changes through whole season and will be finalized only at the season ends). Third: there may be some changes in team formation rule, those changes are under consideration
  • 10/26/2020 14:24: GP of Siberia will be held at the Nov 1, GP of Weihai at the Nov 8. As for Nov 15, there still no decision if there will be any Grand Prix.
  • 11/26/2020 04:08: GP of NorthBeach (aka GP of Bei Sha Tan) will be held at the Nov 29.
  • 12/14/2020 11:09: GP of Xiaomi will be held at the Dec 20. For the teams participated in the MW results from MW will be integrated.. Usual time. The early participation hopefully will be opened very soon.
  • 12/24/2020 02:04: GP of Samara will be held at the Jan 3. 2021. For the teams participated in the MW results from MW will be integrated. Usual time. The early participation will be opened
  • 12/24/2020 02:11: No GP is planned for Dec 27 due to intersection with AtCoder event
  • 01/09/2021 18:24: GP of Nanjing will be held on Jan 10 (tomorrow)
  • 01/28/2021 23:48: GP of Krakow will be held on Jan 31, usual time. For the Petrozavodsk camp teams the camp participation will count
  • 01/28/2021 23:49: Feb 7 and Feb 14 here will be GP too, based on Petrozavodsk contests. Names of the GP will be announced later
  • 01/29/2021 10:30: GP of Nizhny Novgorod will be held on Feb 7, usual time. For the Petrozavodsk camp teams and ICPC/Shanghai Training camp teams the camp participation will count.
  • 02/06/2021 17:03: GP of Belarus will be held on Feb 14, usual time. For the Petrozavodsk camp teams the camp participation will count
  • 02/06/2021 17:04: GP of Suwon will be held on Feb 21, usual time. For the Petrozavodsk camp teams the camp participation will count
  • 02/25/2021 04:12: GP of Tokyo will be held on Feb 28, usual time.
  • 04/23/2021 23:18: GP of China will be held on May 2, usual time. For the MW teams the camp participation will count
  • 05/03/2021 21:43: GP of Urals will be held on May 9, usual time. Ural championship onsite teams results will be counted
  • 05/03/2021 21:44: With good chances there will be two GP at May 16 and May 23, names and other details will be told at short time
  • 05/06/2021 14:11: The GP at May 16 is cancelled. GP of Southern Europe will be held on May 23, usual time.
  • 05/16/2021 21:15: Due to SEERC is moved from Sat to Sun, the GP of Southern Europe will start at 16:00 Moscow time (5 hours later than the standard time). The ext teams link appears approximatelly at the standard time or hour later.
  • 05/16/2021 21:16: Today the final contest for the XX Open Cup was held online. The winner is USA1, the runner-up is Past Glory, third place goes to Polish Mafia. Congratultations to the winners!
  • 05/23/2021 11:06: The ext teams may start the GP of Southeastern Europe from now. The link for the GP of Southeastern Europe is http://official.contest.yandex.com/opencupXXI/contest/27619/enter
  • 06/02/2021 17:21: GP of Beijing will be held on June 6, usual time, on the CCPC Finals tasks

本帖最后更新于 06/03/2021 09:58 (UTC +3)

Easy Contest Tutorial

2020-07-10 16:04:03 By Qingyu

A

把所有形如$(a,ka)$的路径提出来,共有$O(n\log n)$条路径,后面将这种路径称为限制。

考虑答案路径如果要不合法,那么必然覆盖了至少一条完整的限制。

考虑覆盖限制$(u,v)$的路径$(a,b)$,设$dfn_x$表示$x$的$dfs$序,$end_x$表示$x$的子树中最大的$dfs$序,不妨设$dfn_u < dfn_v,dfn_a < dfn_b$。

  1. 当$u$是$v$的祖先的时候,考虑$g$是离$u$最近的路径$(u,v)$上的点,要么$dfn_a < dfn_g,dfn_v\leq dfn_b\leq end_v$,要么$dfn_v\leq dfn_a\leq end_v,dfn_b>end_g$。
  2. 当$u$不是$v$的祖先的时候,显然$dfn_u\leq dfn_a\leq end_u, dfn_v\leq dfn_b\leq end_v$。

第一种情况构成了$2$个矩形,第二种情况构成了$1$个矩形。

最终我们只要求出所有矩形的并然后取个反即可,扫描线$+$线段树,总复杂度$O(n\log^2 n)$。

B

观察一下可以发现,如果将同一行与同一列的$1$用边连起来,一种方案可以拆成很多个环,从这个方面入手。

设$f_n$表示$n\times n$矩阵的答案,我们枚举第一行所在环的大小,那么有递推式: $$f_n = \sum_{i = 2}^{n}A_i\cdot \binom{n}{i}\cdot \binom{n - 1}{i - 1}\cdot f_{n - i}$$

其中$A_i$表示$i\times i$的矩阵只有一个环的方案数,$\binom{n}{i}$表示选出$i$列,$\binom{n-1}{i-1}$表示选出除了第$1$行的剩下的$i-1$行。

先给出结论:$A_n = \frac{n!(n-1)!}{2}$,那么式子化成: $$f_n = \sum_{i = 2}^{n}\frac{i!(i-1)!}{2}\cdot \binom{n}{i}\cdot \binom{n - 1}{i - 1}\cdot f_{n - i}$$

将组合数拆开化简,得到: $$f_n = \frac{n!(n-1)!}{2}\sum_{i = 2}^{n}\frac{f_{n-i}}{((n-i)!)^2}$$

设$g_n = \frac{f_n}{(n!)^2}$,那么有: $$g_n = \frac{1}{2n}\sum_{i = 2}^{n}g_{n - i}$$

维护前缀和即可,复杂度$O(n)$。

现在考虑怎么证明$A_n = \frac{n!(n-1)!}{2}$。

先$n!$每行每列放一个$1$,设$p_i$表示第$i$行$1$的列编号。在$p_1$列放第二个$1$ 有$n-1$种方案,假设第二个$1$行号为$q_i$,那么接下来考虑$p_{q_i}$列,这列第二个$1$有$n-2$ 种放法,因为不能在此时返回第一行,再加上已有$2$个$1$的行不能再放$1$。接下来就是$n-3...$。除以二是因为这个过程的逆过程也被计算过了。

C

一眼费用流裸题,但是数据范围有点大,考虑动态维护流量。

设当前加入的点编号为$x$,因为深度是$O(\log n)$的,因此我们可以枚举$x$和$x$要到的点的LCA,对于当前LCA设为$g$,我们需要求出$g$往子树中走最小的代价使得可以流到一个还有剩余容量的点,设为$down_g$。注意子树中行走的代价可以根据每条边的流量正负来确定,因此要维护每条边的流量,其实就是手动维护网路流。我们需要求出$down_g+cost(x\rightarrow g)$中代价最小的那个,然后暴力维护每条边的流量即可。

复杂度$O(n\log n)$。

JSOI 2017 题目合集

2020-06-27 23:18:15 By Qingyu

似乎 BZOJ 挂了以后就没有地方有 JSOI 2017 的题目了,于是上传了一下。

Enjoy!

共 75 篇博客
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8