Compare commits
2 Commits
cdf8358f3c
...
c8e8f1f0cb
Author | SHA1 | Date | |
---|---|---|---|
c8e8f1f0cb | |||
eac90c8b50 |
12
.gitignore
vendored
12
.gitignore
vendored
@ -1,7 +1,7 @@
|
|||||||
.*
|
.*
|
||||||
build
|
build
|
||||||
!.gitignore
|
!.gitignore
|
||||||
*.json
|
*.json
|
||||||
/cmake-build*
|
/cmake-build*
|
||||||
/build*
|
/build*
|
||||||
/test*.txt
|
/test*.txt
|
@ -1,27 +1,27 @@
|
|||||||
cmake_minimum_required(VERSION 3.10)
|
cmake_minimum_required(VERSION 3.10)
|
||||||
|
|
||||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||||
add_compile_options(-Wall)
|
add_compile_options(-Wall)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
set(CMAKE_BUILD_TYPE Debug)
|
set(CMAKE_BUILD_TYPE Debug)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
message("Build type is [${CMAKE_BUILD_TYPE}]")
|
message("Build type is [${CMAKE_BUILD_TYPE}]")
|
||||||
|
|
||||||
|
|
||||||
project(algorithm_2024)
|
project(algorithm_2024)
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/src/include)
|
include_directories(${CMAKE_CURRENT_LIST_DIR}/src/include)
|
||||||
|
|
||||||
file(GLOB_RECURSE SRC_LIST CONFIGURE_DEPENDS ${CMAKE_CURRENT_LIST_DIR}/src/*.cpp)
|
file(GLOB_RECURSE SRC_LIST CONFIGURE_DEPENDS ${CMAKE_CURRENT_LIST_DIR}/src/*.cpp)
|
||||||
|
|
||||||
foreach(SRC IN LISTS SRC_LIST)
|
foreach(SRC IN LISTS SRC_LIST)
|
||||||
get_filename_component(SRC_NAME_WE ${SRC} NAME_WE)
|
get_filename_component(SRC_NAME_WE ${SRC} NAME_WE)
|
||||||
message("[${SRC}] will be build to [${SRC_NAME_WE}]")
|
message("[${SRC}] will be build to [${SRC_NAME_WE}]")
|
||||||
add_executable(${SRC_NAME_WE} ${SRC})
|
add_executable(${SRC_NAME_WE} ${SRC})
|
||||||
endforeach()
|
endforeach()
|
||||||
|
464
LICENSE
464
LICENSE
@ -1,232 +1,232 @@
|
|||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 3, 29 June 2007
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
Copyright © 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
|
||||||
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
Preamble
|
Preamble
|
||||||
|
|
||||||
The GNU General Public License is a free, copyleft license for software and other kinds of works.
|
The GNU General Public License is a free, copyleft license for software and other kinds of works.
|
||||||
|
|
||||||
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
|
The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too.
|
||||||
|
|
||||||
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things.
|
||||||
|
|
||||||
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
|
To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights.
|
||||||
|
|
||||||
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
|
Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
|
For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions.
|
||||||
|
|
||||||
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
|
Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
|
Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
The precise terms and conditions for copying, distribution and modification follow.
|
The precise terms and conditions for copying, distribution and modification follow.
|
||||||
|
|
||||||
TERMS AND CONDITIONS
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
0. Definitions.
|
0. Definitions.
|
||||||
|
|
||||||
“This License” refers to version 3 of the GNU General Public License.
|
“This License” refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
“Copyright” also means copyright-like laws that apply to other kinds of works, such as semiconductor masks.
|
||||||
|
|
||||||
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
|
“The Program” refers to any copyrightable work licensed under this License. Each licensee is addressed as “you”. “Licensees” and “recipients” may be individuals or organizations.
|
||||||
|
|
||||||
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
|
To “modify” a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a “modified version” of the earlier work or a work “based on” the earlier work.
|
||||||
|
|
||||||
A “covered work” means either the unmodified Program or a work based on the Program.
|
A “covered work” means either the unmodified Program or a work based on the Program.
|
||||||
|
|
||||||
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
To “propagate” a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well.
|
||||||
|
|
||||||
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
To “convey” a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
An interactive user interface displays “Appropriate Legal Notices” to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
1. Source Code.
|
1. Source Code.
|
||||||
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
|
The “source code” for a work means the preferred form of the work for making modifications to it. “Object code” means any non-source form of a work.
|
||||||
|
|
||||||
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
A “Standard Interface” means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language.
|
||||||
|
|
||||||
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
The “System Libraries” of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A “Major Component”, in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
|
The “Corresponding Source” for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work.
|
||||||
|
|
||||||
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source.
|
||||||
|
|
||||||
The Corresponding Source for a work in source code form is that same work.
|
The Corresponding Source for a work in source code form is that same work.
|
||||||
|
|
||||||
2. Basic Permissions.
|
2. Basic Permissions.
|
||||||
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary.
|
||||||
|
|
||||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures.
|
||||||
|
|
||||||
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures.
|
||||||
|
|
||||||
4. Conveying Verbatim Copies.
|
4. Conveying Verbatim Copies.
|
||||||
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
5. Conveying Modified Source Versions.
|
5. Conveying Modified Source Versions.
|
||||||
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
a) The work must carry prominent notices stating that you modified it, and giving a relevant date.
|
||||||
|
|
||||||
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
|
b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to “keep intact all notices”.
|
||||||
|
|
||||||
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so.
|
||||||
|
|
||||||
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an “aggregate” if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate.
|
||||||
|
|
||||||
6. Conveying Non-Source Forms.
|
6. Conveying Non-Source Forms.
|
||||||
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways:
|
||||||
|
|
||||||
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange.
|
||||||
|
|
||||||
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b.
|
||||||
|
|
||||||
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d.
|
||||||
|
|
||||||
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work.
|
||||||
|
|
||||||
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
A “User Product” is either (1) a “consumer product”, which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, “normally used” refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product.
|
||||||
|
|
||||||
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
“Installation Information” for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made.
|
||||||
|
|
||||||
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM).
|
||||||
|
|
||||||
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network.
|
||||||
|
|
||||||
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying.
|
||||||
|
|
||||||
7. Additional Terms.
|
7. Additional Terms.
|
||||||
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
“Additional permissions” are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions.
|
||||||
|
|
||||||
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or
|
||||||
|
|
||||||
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or
|
||||||
|
|
||||||
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
d) Limiting the use for publicity purposes of names of licensors or authors of the material; or
|
||||||
|
|
||||||
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors.
|
||||||
|
|
||||||
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
All other non-permissive additional terms are considered “further restrictions” within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying.
|
||||||
|
|
||||||
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms.
|
||||||
|
|
||||||
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way.
|
||||||
|
|
||||||
8. Termination.
|
8. Termination.
|
||||||
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11).
|
||||||
|
|
||||||
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.
|
||||||
|
|
||||||
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.
|
||||||
|
|
||||||
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10.
|
||||||
|
|
||||||
9. Acceptance Not Required for Having Copies.
|
9. Acceptance Not Required for Having Copies.
|
||||||
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
10. Automatic Licensing of Downstream Recipients.
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
An “entity transaction” is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
11. Patents.
|
11. Patents.
|
||||||
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
|
A “contributor” is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's “contributor version”.
|
||||||
|
|
||||||
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
A contributor's “essential patent claims” are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, “control” includes the right to grant patent sublicenses in a manner consistent with the requirements of this License.
|
||||||
|
|
||||||
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version.
|
||||||
|
|
||||||
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
In the following three paragraphs, a “patent license” is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To “grant” such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party.
|
||||||
|
|
||||||
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. “Knowingly relying” means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid.
|
||||||
|
|
||||||
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it.
|
||||||
|
|
||||||
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
A patent license is “discriminatory” if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
12. No Surrender of Others' Freedom.
|
12. No Surrender of Others' Freedom.
|
||||||
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
13. Use with the GNU Affero General Public License.
|
13. Use with the GNU Affero General Public License.
|
||||||
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
|
Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such.
|
||||||
|
|
||||||
14. Revised Versions of this License.
|
14. Revised Versions of this License.
|
||||||
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
|
||||||
|
|
||||||
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
|
Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation.
|
||||||
|
|
||||||
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program.
|
||||||
|
|
||||||
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version.
|
||||||
|
|
||||||
15. Disclaimer of Warranty.
|
15. Disclaimer of Warranty.
|
||||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
16. Limitation of Liability.
|
16. Limitation of Liability.
|
||||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
17. Interpretation of Sections 15 and 16.
|
17. Interpretation of Sections 15 and 16.
|
||||||
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee.
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the “copyright” line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
alogrithm_2024
|
alogrithm_2024
|
||||||
Copyright (C) 2024 Zengtudor
|
Copyright (C) 2024 Zengtudor
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
Also add information on how to contact you by electronic and paper mail.
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
alogrithm_2024 Copyright (C) 2024 Zengtudor
|
alogrithm_2024 Copyright (C) 2024 Zengtudor
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
|
The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an “about box”.
|
||||||
|
|
||||||
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <https://www.gnu.org/licenses/>.
|
You should also get your employer (if you work as a programmer) or school, if any, to sign a “copyright disclaimer” for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <https://www.gnu.org/philosophy/why-not-lgpl.html>.
|
The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <https://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||||
|
50
README.md
50
README.md
@ -1,26 +1,26 @@
|
|||||||
# algorithm_2024
|
# algorithm_2024
|
||||||
|
|
||||||
algorithm_2024
|
algorithm_2024
|
||||||
|
|
||||||
## 错题本
|
## 错题本
|
||||||
|
|
||||||
### Luogu某题
|
### Luogu某题
|
||||||
|
|
||||||
#### 数组越界导致变量异常更改
|
#### 数组越界导致变量异常更改
|
||||||
|
|
||||||
### [OJ4980:拯救行动](http://noi.openjudge.cn/ch0205/4980/)
|
### [OJ4980:拯救行动](http://noi.openjudge.cn/ch0205/4980/)
|
||||||
|
|
||||||
#### 未考虑无答案(特殊情况)时输出
|
#### 未考虑无答案(特殊情况)时输出
|
||||||
|
|
||||||
#### 优先对联是从大到小排序,重载运算符时需反向或者std::greater
|
#### 优先对联是从大到小排序,重载运算符时需反向或者std::greater
|
||||||
```cpp
|
```cpp
|
||||||
struct Status{
|
struct Status{
|
||||||
Point now;
|
Point now;
|
||||||
ll step;
|
ll step;
|
||||||
bool operator<(const Status &that)const noexcept{
|
bool operator<(const Status &that)const noexcept{
|
||||||
return this->step > that.step;
|
return this->step > that.step;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
std::priority_queue<Status> q;
|
std::priority_queue<Status> q;
|
||||||
```
|
```
|
@ -1,3 +1,3 @@
|
|||||||
1
|
1
|
||||||
0
|
0
|
||||||
2
|
2
|
@ -1,10 +1,10 @@
|
|||||||
7 3
|
7 3
|
||||||
1 2
|
1 2
|
||||||
1 3
|
1 3
|
||||||
2 4
|
2 4
|
||||||
2 5
|
2 5
|
||||||
3 6
|
3 6
|
||||||
3 7
|
3 7
|
||||||
3 2 6 7
|
3 2 6 7
|
||||||
2 3 6
|
2 3 6
|
||||||
4 4 5 6 7
|
4 4 5 6 7
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -1,32 +1,32 @@
|
|||||||
2
|
2
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
0
|
0
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
|
@ -1,332 +1,332 @@
|
|||||||
300 32
|
300 32
|
||||||
12 230
|
12 230
|
||||||
46 12
|
46 12
|
||||||
12 126
|
12 126
|
||||||
290 1
|
290 1
|
||||||
16 98
|
16 98
|
||||||
115 290
|
115 290
|
||||||
226 17
|
226 17
|
||||||
17 229
|
17 229
|
||||||
268 185
|
268 185
|
||||||
290 82
|
290 82
|
||||||
40 285
|
40 285
|
||||||
171 151
|
171 151
|
||||||
40 1
|
40 1
|
||||||
300 124
|
300 124
|
||||||
132 268
|
132 268
|
||||||
1 81
|
1 81
|
||||||
40 240
|
40 240
|
||||||
268 255
|
268 255
|
||||||
89 268
|
89 268
|
||||||
257 290
|
257 290
|
||||||
118 158
|
118 158
|
||||||
151 289
|
151 289
|
||||||
268 254
|
268 254
|
||||||
134 290
|
134 290
|
||||||
169 256
|
169 256
|
||||||
131 295
|
131 295
|
||||||
40 55
|
40 55
|
||||||
1 151
|
1 151
|
||||||
124 136
|
124 136
|
||||||
144 1
|
144 1
|
||||||
108 17
|
108 17
|
||||||
151 3
|
151 3
|
||||||
40 166
|
40 166
|
||||||
124 59
|
124 59
|
||||||
174 151
|
174 151
|
||||||
188 12
|
188 12
|
||||||
268 168
|
268 168
|
||||||
231 124
|
231 124
|
||||||
256 5
|
256 5
|
||||||
50 48
|
50 48
|
||||||
145 268
|
145 268
|
||||||
235 213
|
235 213
|
||||||
177 290
|
177 290
|
||||||
268 148
|
268 148
|
||||||
17 137
|
17 137
|
||||||
292 268
|
292 268
|
||||||
14 17
|
14 17
|
||||||
40 258
|
40 258
|
||||||
212 30
|
212 30
|
||||||
131 10
|
131 10
|
||||||
124 219
|
124 219
|
||||||
12 206
|
12 206
|
||||||
151 104
|
151 104
|
||||||
158 1
|
158 1
|
||||||
124 19
|
124 19
|
||||||
30 223
|
30 223
|
||||||
51 151
|
51 151
|
||||||
151 178
|
151 178
|
||||||
48 83
|
48 83
|
||||||
266 17
|
266 17
|
||||||
290 287
|
290 287
|
||||||
72 40
|
72 40
|
||||||
87 290
|
87 290
|
||||||
23 124
|
23 124
|
||||||
1 246
|
1 246
|
||||||
276 268
|
276 268
|
||||||
1 124
|
1 124
|
||||||
17 67
|
17 67
|
||||||
221 268
|
221 268
|
||||||
29 158
|
29 158
|
||||||
71 151
|
71 151
|
||||||
12 155
|
12 155
|
||||||
283 48
|
283 48
|
||||||
151 260
|
151 260
|
||||||
17 232
|
17 232
|
||||||
268 293
|
268 293
|
||||||
151 196
|
151 196
|
||||||
243 290
|
243 290
|
||||||
20 17
|
20 17
|
||||||
1 48
|
1 48
|
||||||
252 268
|
252 268
|
||||||
256 194
|
256 194
|
||||||
98 101
|
98 101
|
||||||
256 147
|
256 147
|
||||||
239 131
|
239 131
|
||||||
54 213
|
54 213
|
||||||
131 49
|
131 49
|
||||||
40 159
|
40 159
|
||||||
151 291
|
151 291
|
||||||
247 131
|
247 131
|
||||||
158 164
|
158 164
|
||||||
61 151
|
61 151
|
||||||
157 17
|
157 17
|
||||||
107 151
|
107 151
|
||||||
268 133
|
268 133
|
||||||
12 156
|
12 156
|
||||||
56 124
|
56 124
|
||||||
17 98
|
17 98
|
||||||
124 199
|
124 199
|
||||||
290 7
|
290 7
|
||||||
98 2
|
98 2
|
||||||
86 268
|
86 268
|
||||||
191 17
|
191 17
|
||||||
227 1
|
227 1
|
||||||
131 182
|
131 182
|
||||||
97 30
|
97 30
|
||||||
151 135
|
151 135
|
||||||
47 124
|
47 124
|
||||||
150 131
|
150 131
|
||||||
284 256
|
284 256
|
||||||
131 99
|
131 99
|
||||||
151 275
|
151 275
|
||||||
290 201
|
290 201
|
||||||
131 129
|
131 129
|
||||||
266 209
|
266 209
|
||||||
17 256
|
17 256
|
||||||
170 40
|
170 40
|
||||||
268 294
|
268 294
|
||||||
117 1
|
117 1
|
||||||
297 151
|
297 151
|
||||||
290 140
|
290 140
|
||||||
163 1
|
163 1
|
||||||
124 80
|
124 80
|
||||||
17 208
|
17 208
|
||||||
12 162
|
12 162
|
||||||
17 22
|
17 22
|
||||||
60 124
|
60 124
|
||||||
149 268
|
149 268
|
||||||
195 1
|
195 1
|
||||||
44 290
|
44 290
|
||||||
207 12
|
207 12
|
||||||
213 90
|
213 90
|
||||||
290 17
|
290 17
|
||||||
66 290
|
66 290
|
||||||
272 131
|
272 131
|
||||||
113 290
|
113 290
|
||||||
151 250
|
151 250
|
||||||
1 30
|
1 30
|
||||||
40 259
|
40 259
|
||||||
238 290
|
238 290
|
||||||
253 98
|
253 98
|
||||||
288 124
|
288 124
|
||||||
161 1
|
161 1
|
||||||
48 13
|
48 13
|
||||||
175 48
|
175 48
|
||||||
142 290
|
142 290
|
||||||
264 131
|
264 131
|
||||||
172 290
|
172 290
|
||||||
131 122
|
131 122
|
||||||
58 17
|
58 17
|
||||||
213 17
|
213 17
|
||||||
234 40
|
234 40
|
||||||
69 124
|
69 124
|
||||||
277 213
|
277 213
|
||||||
70 124
|
70 124
|
||||||
245 268
|
245 268
|
||||||
100 151
|
100 151
|
||||||
222 290
|
222 290
|
||||||
262 1
|
262 1
|
||||||
186 1
|
186 1
|
||||||
179 268
|
179 268
|
||||||
74 30
|
74 30
|
||||||
211 131
|
211 131
|
||||||
290 153
|
290 153
|
||||||
299 268
|
299 268
|
||||||
187 151
|
187 151
|
||||||
256 184
|
256 184
|
||||||
57 131
|
57 131
|
||||||
131 190
|
131 190
|
||||||
48 263
|
48 263
|
||||||
1 193
|
1 193
|
||||||
290 112
|
290 112
|
||||||
213 278
|
213 278
|
||||||
17 154
|
17 154
|
||||||
110 48
|
110 48
|
||||||
1 200
|
1 200
|
||||||
39 98
|
39 98
|
||||||
244 30
|
244 30
|
||||||
27 158
|
27 158
|
||||||
282 290
|
282 290
|
||||||
151 225
|
151 225
|
||||||
48 8
|
48 8
|
||||||
268 1
|
268 1
|
||||||
202 30
|
202 30
|
||||||
17 12
|
17 12
|
||||||
21 151
|
21 151
|
||||||
17 237
|
17 237
|
||||||
1 121
|
1 121
|
||||||
94 124
|
94 124
|
||||||
281 151
|
281 151
|
||||||
125 268
|
125 268
|
||||||
98 204
|
98 204
|
||||||
6 98
|
6 98
|
||||||
160 48
|
160 48
|
||||||
48 35
|
48 35
|
||||||
1 298
|
1 298
|
||||||
213 279
|
213 279
|
||||||
106 30
|
106 30
|
||||||
167 290
|
167 290
|
||||||
40 248
|
40 248
|
||||||
11 290
|
11 290
|
||||||
173 256
|
173 256
|
||||||
85 151
|
85 151
|
||||||
93 17
|
93 17
|
||||||
17 189
|
17 189
|
||||||
43 290
|
43 290
|
||||||
17 123
|
17 123
|
||||||
151 224
|
151 224
|
||||||
1 251
|
1 251
|
||||||
141 131
|
141 131
|
||||||
218 12
|
218 12
|
||||||
119 158
|
119 158
|
||||||
76 98
|
76 98
|
||||||
198 290
|
198 290
|
||||||
256 114
|
256 114
|
||||||
290 130
|
290 130
|
||||||
17 36
|
17 36
|
||||||
273 12
|
273 12
|
||||||
88 256
|
88 256
|
||||||
213 146
|
213 146
|
||||||
40 15
|
40 15
|
||||||
98 210
|
98 210
|
||||||
120 1
|
120 1
|
||||||
241 40
|
241 40
|
||||||
91 1
|
91 1
|
||||||
131 216
|
131 216
|
||||||
124 25
|
124 25
|
||||||
268 152
|
268 152
|
||||||
151 127
|
151 127
|
||||||
242 256
|
242 256
|
||||||
109 40
|
109 40
|
||||||
228 131
|
228 131
|
||||||
79 268
|
79 268
|
||||||
236 124
|
236 124
|
||||||
143 290
|
143 290
|
||||||
9 290
|
9 290
|
||||||
203 290
|
203 290
|
||||||
1 233
|
1 233
|
||||||
183 124
|
183 124
|
||||||
31 151
|
31 151
|
||||||
265 256
|
265 256
|
||||||
192 290
|
192 290
|
||||||
290 176
|
290 176
|
||||||
269 256
|
269 256
|
||||||
65 40
|
65 40
|
||||||
274 17
|
274 17
|
||||||
131 261
|
131 261
|
||||||
151 138
|
151 138
|
||||||
139 1
|
139 1
|
||||||
290 52
|
290 52
|
||||||
286 1
|
286 1
|
||||||
124 105
|
124 105
|
||||||
30 296
|
30 296
|
||||||
75 12
|
75 12
|
||||||
131 95
|
131 95
|
||||||
180 17
|
180 17
|
||||||
131 78
|
131 78
|
||||||
205 1
|
205 1
|
||||||
41 124
|
41 124
|
||||||
1 267
|
1 267
|
||||||
26 268
|
26 268
|
||||||
98 116
|
98 116
|
||||||
181 213
|
181 213
|
||||||
151 24
|
151 24
|
||||||
124 165
|
124 165
|
||||||
220 290
|
220 290
|
||||||
30 96
|
30 96
|
||||||
40 271
|
40 271
|
||||||
214 213
|
214 213
|
||||||
53 131
|
53 131
|
||||||
256 103
|
256 103
|
||||||
268 73
|
268 73
|
||||||
84 268
|
84 268
|
||||||
32 131
|
32 131
|
||||||
290 37
|
290 37
|
||||||
131 28
|
131 28
|
||||||
280 290
|
280 290
|
||||||
63 1
|
63 1
|
||||||
12 34
|
12 34
|
||||||
215 268
|
215 268
|
||||||
102 48
|
102 48
|
||||||
40 128
|
40 128
|
||||||
12 217
|
12 217
|
||||||
256 249
|
256 249
|
||||||
62 1
|
62 1
|
||||||
42 17
|
42 17
|
||||||
266 111
|
266 111
|
||||||
290 33
|
290 33
|
||||||
270 17
|
270 17
|
||||||
124 68
|
124 68
|
||||||
18 12
|
18 12
|
||||||
17 92
|
17 92
|
||||||
64 17
|
64 17
|
||||||
213 38
|
213 38
|
||||||
290 197
|
290 197
|
||||||
77 98
|
77 98
|
||||||
268 45
|
268 45
|
||||||
131 290
|
131 290
|
||||||
151 4
|
151 4
|
||||||
4 217 68 241 63
|
4 217 68 241 63
|
||||||
2 137 39
|
2 137 39
|
||||||
3 176 159 26
|
3 176 159 26
|
||||||
7 298 14 300 45 73 257 254
|
7 298 14 300 45 73 257 254
|
||||||
5 68 1 271 116 164
|
5 68 1 271 116 164
|
||||||
6 60 231 135 165 118 146
|
6 60 231 135 165 118 146
|
||||||
2 197 239
|
2 197 239
|
||||||
15 35 216 189 14 228 222 248 184 125 191 25 50 119 167 179
|
15 35 216 189 14 228 222 248 184 125 191 25 50 119 167 179
|
||||||
2 247 239
|
2 247 239
|
||||||
3 234 196 44
|
3 234 196 44
|
||||||
10 196 52 166 236 244 129 235 49 29 87
|
10 196 52 166 236 244 129 235 49 29 87
|
||||||
2 153 295
|
2 153 295
|
||||||
2 230 294
|
2 230 294
|
||||||
31 141 165 140 208 50 189 167 153 13 84 268 52 203 287 197 133 38 180 191 127 92 95 275 69 148 106 160 285 71 145 183
|
31 141 165 140 208 50 189 167 153 13 84 268 52 203 287 197 133 38 180 191 127 92 95 275 69 148 106 160 285 71 145 183
|
||||||
3 137 195 228
|
3 137 195 228
|
||||||
2 106 164
|
2 106 164
|
||||||
3 21 168 70
|
3 21 168 70
|
||||||
3 233 220 282
|
3 233 220 282
|
||||||
20 42 8 231 272 15 188 207 247 284 148 77 206 241 216 200 17 201 265 103 43
|
20 42 8 231 272 15 188 207 247 284 148 77 206 241 216 200 17 201 265 103 43
|
||||||
7 94 130 61 29 182 74 30
|
7 94 130 61 29 182 74 30
|
||||||
2 100 46
|
2 100 46
|
||||||
3 177 113 205
|
3 177 113 205
|
||||||
4 35 222 268 252
|
4 35 222 268 252
|
||||||
5 255 221 293 132 97
|
5 255 221 293 132 97
|
||||||
77 196 275 190 193 230 226 242 80 280 243 63 119 189 241 84 111 19 244 100 113 90 265 69 105 186 184 104 76 233 299 65 199 71 145 97 259 101 134 225 42 43 221 240 274 284 256 131 253 125 138 272 56 300 121 23 222 158 47 168 142 91 207 62 147 58 246 278 262 118 197 127 10 238 26 79 34 223
|
77 196 275 190 193 230 226 242 80 280 243 63 119 189 241 84 111 19 244 100 113 90 265 69 105 186 184 104 76 233 299 65 199 71 145 97 259 101 134 225 42 43 221 240 274 284 256 131 253 125 138 272 56 300 121 23 222 158 47 168 142 91 207 62 147 58 246 278 262 118 197 127 10 238 26 79 34 223
|
||||||
2 179 99
|
2 179 99
|
||||||
2 242 256
|
2 242 256
|
||||||
28 117 215 282 219 251 178 97 169 128 174 277 187 36 105 139 138 206 132 86 232 141 77 84 16 212 118 14 136
|
28 117 215 282 219 251 178 97 169 128 174 277 187 36 105 139 138 206 132 86 232 141 77 84 16 212 118 14 136
|
||||||
9 157 217 54 102 280 166 225 191 182
|
9 157 217 54 102 280 166 225 191 182
|
||||||
2 44 47
|
2 44 47
|
||||||
4 42 166 53 128
|
4 42 166 53 128
|
||||||
12 115 209 150 15 90 61 63 17 223 207 25 120
|
12 115 209 150 15 90 61 63 17 223 207 25 120
|
||||||
|
@ -1,158 +1,158 @@
|
|||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
1
|
1
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
1
|
1
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
1
|
1
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
1
|
1
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
1
|
1
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
1
|
1
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
2
|
2
|
||||||
3
|
3
|
||||||
3
|
3
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -1 +1 @@
|
|||||||
2 2 2
|
2 2 2
|
||||||
|
@ -1 +1 @@
|
|||||||
458446679
|
458446679
|
||||||
|
@ -1 +1 @@
|
|||||||
1 326461 939834
|
1 326461 939834
|
||||||
|
@ -1 +1 @@
|
|||||||
19
|
19
|
||||||
|
@ -1 +1 @@
|
|||||||
4 2 2
|
4 2 2
|
||||||
|
@ -1 +1 @@
|
|||||||
195308839
|
195308839
|
||||||
|
@ -1 +1 @@
|
|||||||
2 3 28658230
|
2 3 28658230
|
||||||
|
@ -1 +1 @@
|
|||||||
773413093
|
773413093
|
||||||
|
@ -1 +1 @@
|
|||||||
606437 824052 577591
|
606437 824052 577591
|
||||||
|
@ -1 +1 @@
|
|||||||
389279880
|
389279880
|
||||||
|
@ -1 +1 @@
|
|||||||
986607978 603343652 29167602
|
986607978 603343652 29167602
|
||||||
|
@ -1,90 +1,90 @@
|
|||||||
/*
|
/*
|
||||||
n行m列,Ai取第i行最小值,Bj取第j列最大值
|
n行m列,Ai取第i行最小值,Bj取第j列最大值
|
||||||
想不出来递推和数学,打暴力了。。。。
|
想不出来递推和数学,打暴力了。。。。
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using std::cin, std::cout;
|
using std::cin, std::cout;
|
||||||
using ull = unsigned long long;
|
using ull = unsigned long long;
|
||||||
using ui = unsigned int;
|
using ui = unsigned int;
|
||||||
|
|
||||||
static constexpr size_t MAX_N {(size_t)1e3+5};
|
static constexpr size_t MAX_N {(size_t)1e3+5};
|
||||||
static constexpr ull MOD {998244353};
|
static constexpr ull MOD {998244353};
|
||||||
static size_t n,m,k;
|
static size_t n,m,k;
|
||||||
ull mtx[MAX_N][MAX_N];
|
ull mtx[MAX_N][MAX_N];
|
||||||
std::set<std::pair<size_t,ull>> s;
|
std::set<std::pair<size_t,ull>> s;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
std::ostream&operator<<(std::ostream &os,const std::vector<T> &v)noexcept{
|
std::ostream&operator<<(std::ostream &os,const std::vector<T> &v)noexcept{
|
||||||
os<<"[";
|
os<<"[";
|
||||||
for(size_t i{0};i<v.size()-1;i++){
|
for(size_t i{0};i<v.size()-1;i++){
|
||||||
os<<v[i]<<" ,";
|
os<<v[i]<<" ,";
|
||||||
}
|
}
|
||||||
cout<<v[v.size()-1]<<"]";
|
cout<<v[v.size()-1]<<"]";
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
size_t hashVector1(const std::vector<T>& vec) noexcept{
|
size_t hashVector1(const std::vector<T>& vec) noexcept{
|
||||||
size_t seed = 0;
|
size_t seed = 0;
|
||||||
for (size_t i = 0; i < vec.size(); ++i) {
|
for (size_t i = 0; i < vec.size(); ++i) {
|
||||||
// 结合元素的值和其索引来生成哈希
|
// 结合元素的值和其索引来生成哈希
|
||||||
seed ^= std::hash<T>()((vec[i]+i)*(i << 2)) + 0x9e3779b9 - ((vec[i]*(i<<32))<<4) + ((vec[i]+i)<<2);
|
seed ^= std::hash<T>()((vec[i]+i)*(i << 2)) + 0x9e3779b9 - ((vec[i]*(i<<32))<<4) + ((vec[i]+i)<<2);
|
||||||
}
|
}
|
||||||
return seed;
|
return seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
size_t hashVector2(const std::vector<T>& vec) noexcept{
|
size_t hashVector2(const std::vector<T>& vec) noexcept{
|
||||||
size_t seed = 0;
|
size_t seed = 0;
|
||||||
for (size_t i = 0; i < vec.size(); ++i) {
|
for (size_t i = 0; i < vec.size(); ++i) {
|
||||||
// 结合元素的值和其索引来生成哈希
|
// 结合元素的值和其索引来生成哈希
|
||||||
seed ^= std::hash<T>()((vec[i]+i)*(i << 3)) + MOD<<(i%32) - ((vec[i]*(i<<16))<<3) + ((vec[i]+i)<<3);
|
seed ^= std::hash<T>()((vec[i]+i)*(i << 3)) + MOD<<(i%32) - ((vec[i]*(i<<16))<<3) + ((vec[i]+i)<<3);
|
||||||
}
|
}
|
||||||
return seed;
|
return seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void dfs(size_t x, size_t y){
|
void dfs(size_t x, size_t y){
|
||||||
if(x>n){
|
if(x>n){
|
||||||
// cout<<"x:"<<x<<" y:"<<y<<'\n';
|
// cout<<"x:"<<x<<" y:"<<y<<'\n';
|
||||||
std::vector<ull> v;
|
std::vector<ull> v;
|
||||||
v.reserve(n+m);
|
v.reserve(n+m);
|
||||||
for(size_t i=1;i<=n;i++){
|
for(size_t i=1;i<=n;i++){
|
||||||
ull ai {std::numeric_limits<decltype(ai)>::max()};
|
ull ai {std::numeric_limits<decltype(ai)>::max()};
|
||||||
for(size_t j=1;j<=m;j++){
|
for(size_t j=1;j<=m;j++){
|
||||||
ai = std::min(ai,mtx[i][j]);
|
ai = std::min(ai,mtx[i][j]);
|
||||||
}
|
}
|
||||||
v.push_back(ai);
|
v.push_back(ai);
|
||||||
}
|
}
|
||||||
for(size_t j {1};j<=m;j++){
|
for(size_t j {1};j<=m;j++){
|
||||||
ull bj {std::numeric_limits<decltype(bj)>::min()};
|
ull bj {std::numeric_limits<decltype(bj)>::min()};
|
||||||
for(size_t i{1};i<=n;i++){
|
for(size_t i{1};i<=n;i++){
|
||||||
bj = std::max(bj,mtx[i][j]);
|
bj = std::max(bj,mtx[i][j]);
|
||||||
}
|
}
|
||||||
v.push_back(bj);
|
v.push_back(bj);
|
||||||
}
|
}
|
||||||
// cout<<v<<"\n";
|
// cout<<v<<"\n";
|
||||||
// cout<<hashVector1(v)<<','<<hashVector2(v)<<'\n';
|
// cout<<hashVector1(v)<<','<<hashVector2(v)<<'\n';
|
||||||
s.insert({hashVector1(v),hashVector2(v)});
|
s.insert({hashVector1(v),hashVector2(v)});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(ull i{1};i<=k;i++){
|
for(ull i{1};i<=k;i++){
|
||||||
mtx[x][y]=i;
|
mtx[x][y]=i;
|
||||||
if(y+1>m){
|
if(y+1>m){
|
||||||
dfs(x+1,1);
|
dfs(x+1,1);
|
||||||
}else{
|
}else{
|
||||||
dfs(x,y+1);
|
dfs(x,y+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
cin>>n>>m>>k;
|
cin>>n>>m>>k;
|
||||||
dfs(1,1);
|
dfs(1,1);
|
||||||
cout<<s.size()%MOD<<'\n';
|
cout<<s.size()%MOD<<'\n';
|
||||||
}
|
}
|
@ -1,8 +1,8 @@
|
|||||||
YES
|
YES
|
||||||
NO
|
NO
|
||||||
YES
|
YES
|
||||||
NO
|
NO
|
||||||
NO
|
NO
|
||||||
YES
|
YES
|
||||||
NO
|
NO
|
||||||
YES
|
YES
|
@ -1,9 +1,9 @@
|
|||||||
8
|
8
|
||||||
0 0 0
|
0 0 0
|
||||||
0 1 0
|
0 1 0
|
||||||
1 0 1
|
1 0 1
|
||||||
1 1 0
|
1 1 0
|
||||||
2 0 1
|
2 0 1
|
||||||
2 1 0
|
2 1 0
|
||||||
2 1 1
|
2 1 1
|
||||||
2 0 2
|
2 0 2
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
0
|
0
|
||||||
1
|
1
|
||||||
1
|
1
|
||||||
0
|
0
|
@ -1,5 +1,5 @@
|
|||||||
0
|
0
|
||||||
3
|
3
|
||||||
0
|
0
|
||||||
4
|
4
|
||||||
1
|
1
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,179 +1,179 @@
|
|||||||
#include<bits/stdc++.h>
|
#include<bits/stdc++.h>
|
||||||
#define ll long long
|
#define ll long long
|
||||||
using namespace std;
|
using namespace std;
|
||||||
const int maxn=2e5+5;
|
const int maxn=2e5+5;
|
||||||
struct node
|
struct node
|
||||||
{
|
{
|
||||||
ll mx,sum,t,sv,add,tag,len;
|
ll mx,sum,t,sv,add,tag,len;
|
||||||
};
|
};
|
||||||
node tr[maxn<<2];
|
node tr[maxn<<2];
|
||||||
int n,q;
|
int n,q;
|
||||||
ll d[maxn<<2];
|
ll d[maxn<<2];
|
||||||
inline void mdf(int id,int k,ll w)
|
inline void mdf(int id,int k,ll w)
|
||||||
{
|
{
|
||||||
if(k==0)
|
if(k==0)
|
||||||
{
|
{
|
||||||
tr[id].mx+=w;
|
tr[id].mx+=w;
|
||||||
tr[id].t+=w*w*tr[id].len+tr[id].sv*w+tr[id].sum*w;
|
tr[id].t+=w*w*tr[id].len+tr[id].sv*w+tr[id].sum*w;
|
||||||
tr[id].sum+=w*tr[id].len;
|
tr[id].sum+=w*tr[id].len;
|
||||||
tr[id].sv+=w*tr[id].len;
|
tr[id].sv+=w*tr[id].len;
|
||||||
tr[id].add+=w;
|
tr[id].add+=w;
|
||||||
}
|
}
|
||||||
if(k==1)
|
if(k==1)
|
||||||
{
|
{
|
||||||
tr[id].mx=w,tr[id].t=w*w*tr[id].len,tr[id].sum=w*tr[id].len,tr[id].sv=w*tr[id].len;
|
tr[id].mx=w,tr[id].t=w*w*tr[id].len,tr[id].sum=w*tr[id].len,tr[id].sv=w*tr[id].len;
|
||||||
tr[id].add=0,tr[id].tag=w;
|
tr[id].add=0,tr[id].tag=w;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inline void pushdown(int id)
|
inline void pushdown(int id)
|
||||||
{
|
{
|
||||||
if(tr[id].tag)
|
if(tr[id].tag)
|
||||||
{
|
{
|
||||||
mdf(id<<1,1,tr[id].tag);
|
mdf(id<<1,1,tr[id].tag);
|
||||||
mdf(id<<1|1,1,tr[id].tag);
|
mdf(id<<1|1,1,tr[id].tag);
|
||||||
}
|
}
|
||||||
if(tr[id].add)
|
if(tr[id].add)
|
||||||
{
|
{
|
||||||
mdf(id<<1,0,tr[id].add);
|
mdf(id<<1,0,tr[id].add);
|
||||||
mdf(id<<1|1,0,tr[id].add);
|
mdf(id<<1|1,0,tr[id].add);
|
||||||
}
|
}
|
||||||
tr[id].tag=tr[id].add=0;
|
tr[id].tag=tr[id].add=0;
|
||||||
}
|
}
|
||||||
node calc(node nd,int id)
|
node calc(node nd,int id)
|
||||||
{
|
{
|
||||||
node ret=nd;
|
node ret=nd;
|
||||||
if(tr[id].len==1)
|
if(tr[id].len==1)
|
||||||
{
|
{
|
||||||
ret.mx=max(ret.mx,tr[id].mx);
|
ret.mx=max(ret.mx,tr[id].mx);
|
||||||
ret.sum+=tr[id].sum;
|
ret.sum+=tr[id].sum;
|
||||||
ret.t+=tr[id].sum*ret.mx;
|
ret.t+=tr[id].sum*ret.mx;
|
||||||
ret.sv+=ret.mx;
|
ret.sv+=ret.mx;
|
||||||
ret.len+=tr[id].len;
|
ret.len+=tr[id].len;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pushdown(id);
|
pushdown(id);
|
||||||
if(tr[id<<1].mx>=nd.mx)
|
if(tr[id<<1].mx>=nd.mx)
|
||||||
{
|
{
|
||||||
ret=calc(nd,id<<1);
|
ret=calc(nd,id<<1);
|
||||||
ret.mx=max(ret.mx,tr[id<<1|1].mx);
|
ret.mx=max(ret.mx,tr[id<<1|1].mx);
|
||||||
ret.sum+=tr[id<<1|1].sum;
|
ret.sum+=tr[id<<1|1].sum;
|
||||||
ret.t+=tr[id].t-tr[id<<1].t;
|
ret.t+=tr[id].t-tr[id<<1].t;
|
||||||
ret.sv+=tr[id].sv-tr[id<<1].sv;
|
ret.sv+=tr[id].sv-tr[id<<1].sv;
|
||||||
ret.len+=tr[id<<1|1].len;
|
ret.len+=tr[id<<1|1].len;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nd.sum+=tr[id<<1].sum;
|
nd.sum+=tr[id<<1].sum;
|
||||||
nd.t+=tr[id<<1].sum*nd.mx;
|
nd.t+=tr[id<<1].sum*nd.mx;
|
||||||
nd.sv+=tr[id<<1].len*nd.mx;
|
nd.sv+=tr[id<<1].len*nd.mx;
|
||||||
nd.len+=tr[id<<1].len;
|
nd.len+=tr[id<<1].len;
|
||||||
ret=calc(nd,id<<1|1);
|
ret=calc(nd,id<<1|1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
inline void pushup(int id)
|
inline void pushup(int id)
|
||||||
{
|
{
|
||||||
tr[id]=calc(tr[id<<1],id<<1|1);
|
tr[id]=calc(tr[id<<1],id<<1|1);
|
||||||
tr[id].tag=tr[id].add=0;
|
tr[id].tag=tr[id].add=0;
|
||||||
}
|
}
|
||||||
void build(int id,int l,int r)
|
void build(int id,int l,int r)
|
||||||
{
|
{
|
||||||
if(l==r)
|
if(l==r)
|
||||||
{
|
{
|
||||||
tr[id]=(node){d[l],d[l],d[l]*d[l],d[l],0,0,1};
|
tr[id]=(node){d[l],d[l],d[l]*d[l],d[l],0,0,1};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int mid=(l+r)>>1;
|
int mid=(l+r)>>1;
|
||||||
build(id<<1,l,mid);
|
build(id<<1,l,mid);
|
||||||
build(id<<1|1,mid+1,r);
|
build(id<<1|1,mid+1,r);
|
||||||
pushup(id);
|
pushup(id);
|
||||||
}
|
}
|
||||||
void update(int id,int l,int r,int x,int y,int k,ll w)
|
void update(int id,int l,int r,int x,int y,int k,ll w)
|
||||||
{
|
{
|
||||||
if(l>=x && r<=y)
|
if(l>=x && r<=y)
|
||||||
{
|
{
|
||||||
mdf(id,k,w);
|
mdf(id,k,w);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int mid=(l+r)>>1;
|
int mid=(l+r)>>1;
|
||||||
pushdown(id);
|
pushdown(id);
|
||||||
if(x<=mid) update(id<<1,l,mid,x,y,k,w);
|
if(x<=mid) update(id<<1,l,mid,x,y,k,w);
|
||||||
if(y>mid) update(id<<1|1,mid+1,r,x,y,k,w);
|
if(y>mid) update(id<<1|1,mid+1,r,x,y,k,w);
|
||||||
pushup(id);
|
pushup(id);
|
||||||
}
|
}
|
||||||
int num[maxn],cnt,L[maxn],R[maxn];
|
int num[maxn],cnt,L[maxn],R[maxn];
|
||||||
void get_num(int id,int l,int r,int x,int y)
|
void get_num(int id,int l,int r,int x,int y)
|
||||||
{
|
{
|
||||||
if(l>=x && r<=y)
|
if(l>=x && r<=y)
|
||||||
{
|
{
|
||||||
cnt++;
|
cnt++;
|
||||||
num[cnt]=id,L[cnt]=l,R[cnt]=r;
|
num[cnt]=id,L[cnt]=l,R[cnt]=r;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int mid=(l+r)>>1;
|
int mid=(l+r)>>1;
|
||||||
pushdown(id);
|
pushdown(id);
|
||||||
if(x<=mid) get_num(id<<1,l,mid,x,y);
|
if(x<=mid) get_num(id<<1,l,mid,x,y);
|
||||||
if(y>mid) get_num(id<<1|1,mid+1,r,x,y);
|
if(y>mid) get_num(id<<1|1,mid+1,r,x,y);
|
||||||
}
|
}
|
||||||
int get_pos(int id,int l,int r,node nd,ll t)
|
int get_pos(int id,int l,int r,node nd,ll t)
|
||||||
{
|
{
|
||||||
if(l==r) return l;
|
if(l==r) return l;
|
||||||
int mid=(l+r)>>1;
|
int mid=(l+r)>>1;
|
||||||
pushdown(id);
|
pushdown(id);
|
||||||
node dt=calc(nd,id<<1);
|
node dt=calc(nd,id<<1);
|
||||||
if(dt.t<=t) return get_pos(id<<1|1,mid+1,r,dt,t);
|
if(dt.t<=t) return get_pos(id<<1|1,mid+1,r,dt,t);
|
||||||
else return get_pos(id<<1,l,mid,nd,t);
|
else return get_pos(id<<1,l,mid,nd,t);
|
||||||
}
|
}
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
//system("fc training.out training6.ans /W");
|
//system("fc training.out training6.ans /W");
|
||||||
//return 0;
|
//return 0;
|
||||||
ios::sync_with_stdio(0);
|
ios::sync_with_stdio(0);
|
||||||
cin.tie(0);cout.tie(0);
|
cin.tie(0);cout.tie(0);
|
||||||
//freopen("training6.in","r",stdin);
|
//freopen("training6.in","r",stdin);
|
||||||
//freopen("training.out","w",stdout);
|
//freopen("training.out","w",stdout);
|
||||||
int fl;
|
int fl;
|
||||||
node nd,dt;
|
node nd,dt;
|
||||||
char opt;
|
char opt;
|
||||||
ll s,t,w;
|
ll s,t,w;
|
||||||
cin>>n>>q;
|
cin>>n>>q;
|
||||||
for(int i=0;i<n;i++) cin>>d[i];
|
for(int i=0;i<n;i++) cin>>d[i];
|
||||||
build(1,0,n-1);
|
build(1,0,n-1);
|
||||||
while(q--)
|
while(q--)
|
||||||
{
|
{
|
||||||
cin>>opt>>s>>t;
|
cin>>opt>>s>>t;
|
||||||
if(opt=='P')
|
if(opt=='P')
|
||||||
{
|
{
|
||||||
cin>>w;
|
cin>>w;
|
||||||
if(s<=t) update(1,0,n-1,s,t,0,w);
|
if(s<=t) update(1,0,n-1,s,t,0,w);
|
||||||
else update(1,0,n-1,0,t,0,w),update(1,0,n-1,s,n-1,0,w);
|
else update(1,0,n-1,0,t,0,w),update(1,0,n-1,s,n-1,0,w);
|
||||||
}
|
}
|
||||||
if(opt=='R')
|
if(opt=='R')
|
||||||
{
|
{
|
||||||
cin>>w;
|
cin>>w;
|
||||||
if(s<=t) update(1,0,n-1,s,t,1,w);
|
if(s<=t) update(1,0,n-1,s,t,1,w);
|
||||||
else update(1,0,n-1,0,t,1,w),update(1,0,n-1,s,n-1,1,w);
|
else update(1,0,n-1,0,t,1,w),update(1,0,n-1,s,n-1,1,w);
|
||||||
}
|
}
|
||||||
if(opt=='Q')
|
if(opt=='Q')
|
||||||
{
|
{
|
||||||
fl=0,cnt=0,nd=(node){0,0,0,0,0,0,0};
|
fl=0,cnt=0,nd=(node){0,0,0,0,0,0,0};
|
||||||
get_num(1,0,n-1,s,n-1);
|
get_num(1,0,n-1,s,n-1);
|
||||||
get_num(1,0,n-1,0,n-1);
|
get_num(1,0,n-1,0,n-1);
|
||||||
for(int i=1;i<=cnt;i++)
|
for(int i=1;i<=cnt;i++)
|
||||||
{
|
{
|
||||||
dt=calc(nd,num[i]);
|
dt=calc(nd,num[i]);
|
||||||
if(dt.t>t)
|
if(dt.t>t)
|
||||||
{
|
{
|
||||||
fl=1;
|
fl=1;
|
||||||
cout<<get_pos(num[i],L[i],R[i],nd,t)<<'\n';
|
cout<<get_pos(num[i],L[i],R[i],nd,t)<<'\n';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
nd=dt;
|
nd=dt;
|
||||||
}
|
}
|
||||||
if(fl==0) cout<<get_pos(1,0,n-1,nd,(t-nd.t)%(tr[1].sum*tr[1].mx)+nd.t)<<'\n';
|
if(fl==0) cout<<get_pos(1,0,n-1,nd,(t-nd.t)%(tr[1].sum*tr[1].mx)+nd.t)<<'\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,202 +1,202 @@
|
|||||||
#include<bits/stdc++.h>
|
#include<bits/stdc++.h>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
typedef long long ll;
|
typedef long long ll;
|
||||||
const int N=200001;
|
const int N=200001;
|
||||||
int n,q;
|
int n,q;
|
||||||
int a[N];
|
int a[N];
|
||||||
struct node{
|
struct node{
|
||||||
int mx;
|
int mx;
|
||||||
ll sm,smx,tt;
|
ll sm,smx,tt;
|
||||||
int tg1,tg2;
|
int tg1,tg2;
|
||||||
}t[N*4];
|
}t[N*4];
|
||||||
#define ls (p<<1)
|
#define ls (p<<1)
|
||||||
#define rs (p<<1|1)
|
#define rs (p<<1|1)
|
||||||
#define mid (l+r>>1)
|
#define mid (l+r>>1)
|
||||||
void build(int p,int l,int r){
|
void build(int p,int l,int r){
|
||||||
for(int i=l;i<=r;i++){
|
for(int i=l;i<=r;i++){
|
||||||
t[p].mx=max(t[p].mx,a[i]);
|
t[p].mx=max(t[p].mx,a[i]);
|
||||||
t[p].sm+=a[i];
|
t[p].sm+=a[i];
|
||||||
t[p].smx+=t[p].mx;
|
t[p].smx+=t[p].mx;
|
||||||
t[p].tt+=1ll*t[p].mx*a[i];
|
t[p].tt+=1ll*t[p].mx*a[i];
|
||||||
}
|
}
|
||||||
if(l==r)return;
|
if(l==r)return;
|
||||||
build(ls,l,mid);
|
build(ls,l,mid);
|
||||||
build(rs,mid+1,r);
|
build(rs,mid+1,r);
|
||||||
}
|
}
|
||||||
void pushdown(int p,int l,int r){
|
void pushdown(int p,int l,int r){
|
||||||
int tg;
|
int tg;
|
||||||
if(t[p].tg1){
|
if(t[p].tg1){
|
||||||
tg=t[p].tg1;
|
tg=t[p].tg1;
|
||||||
t[p].tg1=0;
|
t[p].tg1=0;
|
||||||
t[ls].mx=t[rs].mx=tg;
|
t[ls].mx=t[rs].mx=tg;
|
||||||
t[ls].sm=1ll*(mid-l+1)*tg,t[rs].sm=1ll*(r-mid)*tg;
|
t[ls].sm=1ll*(mid-l+1)*tg,t[rs].sm=1ll*(r-mid)*tg;
|
||||||
t[ls].smx=t[ls].sm,t[rs].smx=t[rs].sm;
|
t[ls].smx=t[ls].sm,t[rs].smx=t[rs].sm;
|
||||||
t[ls].tt=t[ls].sm*tg,t[rs].tt=t[rs].sm*tg;
|
t[ls].tt=t[ls].sm*tg,t[rs].tt=t[rs].sm*tg;
|
||||||
t[ls].tg1=t[rs].tg1=tg;
|
t[ls].tg1=t[rs].tg1=tg;
|
||||||
t[ls].tg2=t[rs].tg2=0;
|
t[ls].tg2=t[rs].tg2=0;
|
||||||
}
|
}
|
||||||
if(t[p].tg2){
|
if(t[p].tg2){
|
||||||
tg=t[p].tg2;
|
tg=t[p].tg2;
|
||||||
t[p].tg2=0;
|
t[p].tg2=0;
|
||||||
t[ls].mx+=tg,t[rs].mx+=tg;
|
t[ls].mx+=tg,t[rs].mx+=tg;
|
||||||
t[ls].tt+=tg*(1ll*tg*(mid-l+1)+t[ls].sm+t[ls].smx),t[rs].tt+=tg*(1ll*tg*(r-mid)+t[rs].sm+t[rs].smx);
|
t[ls].tt+=tg*(1ll*tg*(mid-l+1)+t[ls].sm+t[ls].smx),t[rs].tt+=tg*(1ll*tg*(r-mid)+t[rs].sm+t[rs].smx);
|
||||||
t[ls].sm+=1ll*(mid-l+1)*tg,t[rs].sm+=1ll*(r-mid)*tg;
|
t[ls].sm+=1ll*(mid-l+1)*tg,t[rs].sm+=1ll*(r-mid)*tg;
|
||||||
t[ls].smx+=1ll*(mid-l+1)*tg,t[rs].smx+=1ll*(r-mid)*tg;
|
t[ls].smx+=1ll*(mid-l+1)*tg,t[rs].smx+=1ll*(r-mid)*tg;
|
||||||
t[ls].tg2+=tg,t[rs].tg2+=tg;
|
t[ls].tg2+=tg,t[rs].tg2+=tg;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int qmx;
|
int qmx;
|
||||||
ll qsmx,qtt;
|
ll qsmx,qtt;
|
||||||
void query(int p,int l,int r){
|
void query(int p,int l,int r){
|
||||||
if(l==r){
|
if(l==r){
|
||||||
if(qmx>t[p].mx)qsmx+=qmx,qtt+=qmx*t[p].sm;
|
if(qmx>t[p].mx)qsmx+=qmx,qtt+=qmx*t[p].sm;
|
||||||
else qsmx+=t[p].mx,qtt+=t[p].tt,qmx=t[p].mx;
|
else qsmx+=t[p].mx,qtt+=t[p].tt,qmx=t[p].mx;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pushdown(p,l,r);
|
pushdown(p,l,r);
|
||||||
if(qmx>t[ls].mx){
|
if(qmx>t[ls].mx){
|
||||||
qsmx+=1ll*qmx*(mid-l+1);
|
qsmx+=1ll*qmx*(mid-l+1);
|
||||||
qtt+=qmx*t[ls].sm;
|
qtt+=qmx*t[ls].sm;
|
||||||
query(rs,mid+1,r);
|
query(rs,mid+1,r);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
qsmx+=t[p].smx-t[ls].smx;
|
qsmx+=t[p].smx-t[ls].smx;
|
||||||
qtt+=t[p].tt-t[ls].tt;
|
qtt+=t[p].tt-t[ls].tt;
|
||||||
query(ls,l,mid);
|
query(ls,l,mid);
|
||||||
qmx=t[p].mx;
|
qmx=t[p].mx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void update(int p,int l,int r){
|
void update(int p,int l,int r){
|
||||||
t[p].mx=max(t[ls].mx,t[rs].mx);
|
t[p].mx=max(t[ls].mx,t[rs].mx);
|
||||||
t[p].sm=t[ls].sm+t[rs].sm;
|
t[p].sm=t[ls].sm+t[rs].sm;
|
||||||
qmx=t[ls].mx;
|
qmx=t[ls].mx;
|
||||||
qsmx=t[ls].smx;
|
qsmx=t[ls].smx;
|
||||||
qtt=t[ls].tt;
|
qtt=t[ls].tt;
|
||||||
query(rs,mid+1,r);
|
query(rs,mid+1,r);
|
||||||
t[p].smx=qsmx;
|
t[p].smx=qsmx;
|
||||||
t[p].tt=qtt;
|
t[p].tt=qtt;
|
||||||
}
|
}
|
||||||
void modify1(int p,int l,int r,int x,int y,int d){
|
void modify1(int p,int l,int r,int x,int y,int d){
|
||||||
if(x<=l&&r<=y){
|
if(x<=l&&r<=y){
|
||||||
t[p].mx=d;
|
t[p].mx=d;
|
||||||
t[p].sm=1ll*(r-l+1)*d;
|
t[p].sm=1ll*(r-l+1)*d;
|
||||||
t[p].smx=t[p].sm;
|
t[p].smx=t[p].sm;
|
||||||
t[p].tt=t[p].sm*d;
|
t[p].tt=t[p].sm*d;
|
||||||
t[p].tg1=d;
|
t[p].tg1=d;
|
||||||
t[p].tg2=0;
|
t[p].tg2=0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pushdown(p,l,r);
|
pushdown(p,l,r);
|
||||||
if(x<=mid)modify1(ls,l,mid,x,y,d);
|
if(x<=mid)modify1(ls,l,mid,x,y,d);
|
||||||
if(mid<y)modify1(rs,mid+1,r,x,y,d);
|
if(mid<y)modify1(rs,mid+1,r,x,y,d);
|
||||||
update(p,l,r);
|
update(p,l,r);
|
||||||
}
|
}
|
||||||
void modify2(int p,int l,int r,int x,int y,int d){
|
void modify2(int p,int l,int r,int x,int y,int d){
|
||||||
if(x<=l&&r<=y){
|
if(x<=l&&r<=y){
|
||||||
t[p].mx+=d;
|
t[p].mx+=d;
|
||||||
t[p].tt+=d*(1ll*d*(r-l+1)+t[p].sm+t[p].smx);
|
t[p].tt+=d*(1ll*d*(r-l+1)+t[p].sm+t[p].smx);
|
||||||
t[p].sm+=1ll*(r-l+1)*d;
|
t[p].sm+=1ll*(r-l+1)*d;
|
||||||
t[p].smx+=1ll*(r-l+1)*d;
|
t[p].smx+=1ll*(r-l+1)*d;
|
||||||
t[p].tg2+=d;
|
t[p].tg2+=d;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pushdown(p,l,r);
|
pushdown(p,l,r);
|
||||||
if(x<=mid)modify2(ls,l,mid,x,y,d);
|
if(x<=mid)modify2(ls,l,mid,x,y,d);
|
||||||
if(mid<y)modify2(rs,mid+1,r,x,y,d);
|
if(mid<y)modify2(rs,mid+1,r,x,y,d);
|
||||||
update(p,l,r);
|
update(p,l,r);
|
||||||
}
|
}
|
||||||
struct seg{
|
struct seg{
|
||||||
int p,l,r;
|
int p,l,r;
|
||||||
}b[100];
|
}b[100];
|
||||||
int m;
|
int m;
|
||||||
void getseg(int p,int l,int r,int x,int y){
|
void getseg(int p,int l,int r,int x,int y){
|
||||||
if(x<=l&&r<=y){
|
if(x<=l&&r<=y){
|
||||||
b[++m]=(seg){p,l,r};
|
b[++m]=(seg){p,l,r};
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
pushdown(p,l,r);
|
pushdown(p,l,r);
|
||||||
if(x<=mid)getseg(ls,l,mid,x,y);
|
if(x<=mid)getseg(ls,l,mid,x,y);
|
||||||
if(mid<y)getseg(rs,mid+1,r,x,y);
|
if(mid<y)getseg(rs,mid+1,r,x,y);
|
||||||
}
|
}
|
||||||
int gettt(int p,int l,int r,ll tm){
|
int gettt(int p,int l,int r,ll tm){
|
||||||
if(l==r){
|
if(l==r){
|
||||||
query(p,l,r);
|
query(p,l,r);
|
||||||
if(qtt>tm)return l-1;
|
if(qtt>tm)return l-1;
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
pushdown(p,l,r);
|
pushdown(p,l,r);
|
||||||
int mx=qmx;
|
int mx=qmx;
|
||||||
ll tt=qtt;
|
ll tt=qtt;
|
||||||
query(ls,l,mid);
|
query(ls,l,mid);
|
||||||
if(qtt>tm){
|
if(qtt>tm){
|
||||||
qmx=mx,qtt=tt;
|
qmx=mx,qtt=tt;
|
||||||
return gettt(ls,l,mid,tm);
|
return gettt(ls,l,mid,tm);
|
||||||
}
|
}
|
||||||
return gettt(rs,mid+1,r,tm);
|
return gettt(rs,mid+1,r,tm);
|
||||||
}
|
}
|
||||||
int getsm(int p,int l,int r,ll tm){
|
int getsm(int p,int l,int r,ll tm){
|
||||||
if(l==r){
|
if(l==r){
|
||||||
if(t[p].sm>tm)return l-1;
|
if(t[p].sm>tm)return l-1;
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
pushdown(p,l,r);
|
pushdown(p,l,r);
|
||||||
if(t[ls].sm>tm)return getsm(ls,l,mid,tm);
|
if(t[ls].sm>tm)return getsm(ls,l,mid,tm);
|
||||||
return getsm(rs,mid+1,r,tm-t[ls].sm);
|
return getsm(rs,mid+1,r,tm-t[ls].sm);
|
||||||
}
|
}
|
||||||
int main(){
|
int main(){
|
||||||
ios::sync_with_stdio(0);
|
ios::sync_with_stdio(0);
|
||||||
cin.tie(0),cout.tie(0);
|
cin.tie(0),cout.tie(0);
|
||||||
cin>>n>>q;
|
cin>>n>>q;
|
||||||
for(int i=0;i<n;i++)cin>>a[i];
|
for(int i=0;i<n;i++)cin>>a[i];
|
||||||
build(1,0,n-1);
|
build(1,0,n-1);
|
||||||
while(q--){
|
while(q--){
|
||||||
char op[2];
|
char op[2];
|
||||||
cin>>op;
|
cin>>op;
|
||||||
if(op[0]=='R'){
|
if(op[0]=='R'){
|
||||||
int l,r,d;
|
int l,r,d;
|
||||||
cin>>l>>r>>d;
|
cin>>l>>r>>d;
|
||||||
if(l<=r)modify1(1,0,n-1,l,r,d);
|
if(l<=r)modify1(1,0,n-1,l,r,d);
|
||||||
else modify1(1,0,n-1,l,n-1,d),modify1(1,0,n-1,0,r,d);
|
else modify1(1,0,n-1,l,n-1,d),modify1(1,0,n-1,0,r,d);
|
||||||
}
|
}
|
||||||
if(op[0]=='P'){
|
if(op[0]=='P'){
|
||||||
int l,r,d;
|
int l,r,d;
|
||||||
cin>>l>>r>>d;
|
cin>>l>>r>>d;
|
||||||
if(l<=r)modify2(1,0,n-1,l,r,d);
|
if(l<=r)modify2(1,0,n-1,l,r,d);
|
||||||
else modify2(1,0,n-1,l,n-1,d),modify2(1,0,n-1,0,r,d);
|
else modify2(1,0,n-1,l,n-1,d),modify2(1,0,n-1,0,r,d);
|
||||||
}
|
}
|
||||||
if(op[0]=='Q'){
|
if(op[0]=='Q'){
|
||||||
int s;
|
int s;
|
||||||
ll tm;
|
ll tm;
|
||||||
cin>>s>>tm;
|
cin>>s>>tm;
|
||||||
m=0;
|
m=0;
|
||||||
getseg(1,0,n-1,s,n-1);
|
getseg(1,0,n-1,s,n-1);
|
||||||
if(s)getseg(1,0,n-1,0,s-1);
|
if(s)getseg(1,0,n-1,0,s-1);
|
||||||
bool flag=0;
|
bool flag=0;
|
||||||
int mx=0;
|
int mx=0;
|
||||||
ll tt=0;
|
ll tt=0;
|
||||||
for(int i=1;i<=m;i++){
|
for(int i=1;i<=m;i++){
|
||||||
qmx=mx,qtt=tt;
|
qmx=mx,qtt=tt;
|
||||||
query(b[i].p,b[i].l,b[i].r);
|
query(b[i].p,b[i].l,b[i].r);
|
||||||
if(qtt>tm){
|
if(qtt>tm){
|
||||||
qmx=mx,qtt=tt;
|
qmx=mx,qtt=tt;
|
||||||
cout<<(gettt(b[i].p,b[i].l,b[i].r,tm)+1)%n<<'\n';
|
cout<<(gettt(b[i].p,b[i].l,b[i].r,tm)+1)%n<<'\n';
|
||||||
flag=1;
|
flag=1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mx=qmx,tt=qtt;
|
mx=qmx,tt=qtt;
|
||||||
}
|
}
|
||||||
if(flag)continue;
|
if(flag)continue;
|
||||||
tm-=qtt;
|
tm-=qtt;
|
||||||
tm/=t[1].mx;
|
tm/=t[1].mx;
|
||||||
tm%=t[1].sm;
|
tm%=t[1].sm;
|
||||||
for(int i=1;i<=m;i++){
|
for(int i=1;i<=m;i++){
|
||||||
if(t[b[i].p].sm>tm){
|
if(t[b[i].p].sm>tm){
|
||||||
cout<<(getsm(b[i].p,b[i].l,b[i].r,tm)+1)%n<<'\n';
|
cout<<(getsm(b[i].p,b[i].l,b[i].r,tm)+1)%n<<'\n';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
tm-=t[b[i].p].sm;
|
tm-=t[b[i].p].sm;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,166 +1,166 @@
|
|||||||
#include <bits/stdc++.h>
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
#define M 200005
|
#define M 200005
|
||||||
typedef long long LL;
|
typedef long long LL;
|
||||||
int A[M],n,q;
|
int A[M],n,q;
|
||||||
struct YD{
|
struct YD{
|
||||||
struct TNode{
|
struct TNode{
|
||||||
int l,r,mark,mx,ad;
|
int l,r,mark,mx,ad;
|
||||||
LL ans,sum,mx_s;
|
LL ans,sum,mx_s;
|
||||||
int len(){
|
int len(){
|
||||||
return r-l+1;
|
return r-l+1;
|
||||||
}
|
}
|
||||||
void Reset(int ty,int v){
|
void Reset(int ty,int v){
|
||||||
if(ty==1){
|
if(ty==1){
|
||||||
if(mark!=-1)mark+=v;
|
if(mark!=-1)mark+=v;
|
||||||
else ad+=v;
|
else ad+=v;
|
||||||
mx+=v;
|
mx+=v;
|
||||||
ans+=1ll*v*v*len()+sum*v;
|
ans+=1ll*v*v*len()+sum*v;
|
||||||
ans+=mx_s*v;
|
ans+=mx_s*v;
|
||||||
sum+=1ll*len()*v;
|
sum+=1ll*len()*v;
|
||||||
mx_s+=1ll*len()*v;
|
mx_s+=1ll*len()*v;
|
||||||
}else{
|
}else{
|
||||||
ad=0;
|
ad=0;
|
||||||
mark=mx=v;
|
mark=mx=v;
|
||||||
mx_s=sum=1ll*len()*v;
|
mx_s=sum=1ll*len()*v;
|
||||||
ans=1ll*v*v*len();
|
ans=1ll*v*v*len();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}tree[M<<2];
|
}tree[M<<2];
|
||||||
#define fa tree[p]
|
#define fa tree[p]
|
||||||
#define lson tree[p<<1]
|
#define lson tree[p<<1]
|
||||||
#define rson tree[p<<1|1]
|
#define rson tree[p<<1|1]
|
||||||
void Down(int p){
|
void Down(int p){
|
||||||
if(fa.ad!=0)lson.Reset(1,fa.ad),rson.Reset(1,fa.ad),fa.ad=0;
|
if(fa.ad!=0)lson.Reset(1,fa.ad),rson.Reset(1,fa.ad),fa.ad=0;
|
||||||
if(fa.mark!=-1)lson.Reset(2,fa.mark),rson.Reset(2,fa.mark),fa.mark=-1;
|
if(fa.mark!=-1)lson.Reset(2,fa.mark),rson.Reset(2,fa.mark),fa.mark=-1;
|
||||||
}
|
}
|
||||||
LL get_mx_s(int p,int mx){
|
LL get_mx_s(int p,int mx){
|
||||||
LL ret=0;
|
LL ret=0;
|
||||||
while(fa.l^fa.r){
|
while(fa.l^fa.r){
|
||||||
Down(p);
|
Down(p);
|
||||||
if(lson.mx<=mx)ret+=1LL*mx*lson.len(),p=p<<1|1;
|
if(lson.mx<=mx)ret+=1LL*mx*lson.len(),p=p<<1|1;
|
||||||
else ret+=fa.mx_s-lson.mx_s,p<<=1;
|
else ret+=fa.mx_s-lson.mx_s,p<<=1;
|
||||||
}
|
}
|
||||||
return ret+max(mx,fa.mx);
|
return ret+max(mx,fa.mx);
|
||||||
}
|
}
|
||||||
LL get_ans(int p,int mx){
|
LL get_ans(int p,int mx){
|
||||||
LL ret=0;
|
LL ret=0;
|
||||||
while(fa.l^fa.r){
|
while(fa.l^fa.r){
|
||||||
Down(p);
|
Down(p);
|
||||||
if(lson.mx<=mx)ret+=lson.sum*mx,p=p<<1|1;
|
if(lson.mx<=mx)ret+=lson.sum*mx,p=p<<1|1;
|
||||||
else ret+=fa.ans-lson.ans,p<<=1;
|
else ret+=fa.ans-lson.ans,p<<=1;
|
||||||
}
|
}
|
||||||
return ret+1LL*fa.mx*max(fa.mx,mx);
|
return ret+1LL*fa.mx*max(fa.mx,mx);
|
||||||
}
|
}
|
||||||
void Up(int p){
|
void Up(int p){
|
||||||
fa.mx=max(lson.mx,rson.mx);
|
fa.mx=max(lson.mx,rson.mx);
|
||||||
fa.sum=lson.sum+rson.sum;
|
fa.sum=lson.sum+rson.sum;
|
||||||
fa.ans=lson.ans+get_ans(p<<1|1,lson.mx);
|
fa.ans=lson.ans+get_ans(p<<1|1,lson.mx);
|
||||||
fa.mx_s=lson.mx_s+get_mx_s(p<<1|1,lson.mx);
|
fa.mx_s=lson.mx_s+get_mx_s(p<<1|1,lson.mx);
|
||||||
}
|
}
|
||||||
int pos[M];
|
int pos[M];
|
||||||
void build(int l,int r,int p=1){
|
void build(int l,int r,int p=1){
|
||||||
fa.l=l,fa.r=r;
|
fa.l=l,fa.r=r;
|
||||||
fa.mark=-1;
|
fa.mark=-1;
|
||||||
fa.ad=0;
|
fa.ad=0;
|
||||||
if(l==r){
|
if(l==r){
|
||||||
pos[l]=p;
|
pos[l]=p;
|
||||||
fa.mx=A[l];
|
fa.mx=A[l];
|
||||||
fa.ans=1ll*A[l]*A[l];
|
fa.ans=1ll*A[l]*A[l];
|
||||||
fa.sum=A[l];
|
fa.sum=A[l];
|
||||||
fa.mx_s=A[l];
|
fa.mx_s=A[l];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int mid=l+r>>1;
|
int mid=l+r>>1;
|
||||||
build(l,mid,p<<1);
|
build(l,mid,p<<1);
|
||||||
build(mid+1,r,p<<1|1);
|
build(mid+1,r,p<<1|1);
|
||||||
Up(p);
|
Up(p);
|
||||||
}
|
}
|
||||||
void Update(int l,int r,int ty,int v,int p=1){
|
void Update(int l,int r,int ty,int v,int p=1){
|
||||||
if(l==fa.l&&r==fa.r)return void(fa.Reset(ty,v));
|
if(l==fa.l&&r==fa.r)return void(fa.Reset(ty,v));
|
||||||
Down(p);
|
Down(p);
|
||||||
int mid=fa.l+fa.r>>1;
|
int mid=fa.l+fa.r>>1;
|
||||||
if(r<=mid)Update(l,r,ty,v,p<<1);
|
if(r<=mid)Update(l,r,ty,v,p<<1);
|
||||||
else if(l>mid)Update(l,r,ty,v,p<<1|1);
|
else if(l>mid)Update(l,r,ty,v,p<<1|1);
|
||||||
else Update(l,mid,ty,v,p<<1),Update(mid+1,r,ty,v,p<<1|1);
|
else Update(l,mid,ty,v,p<<1),Update(mid+1,r,ty,v,p<<1|1);
|
||||||
Up(p);
|
Up(p);
|
||||||
}
|
}
|
||||||
int stk[M],top;
|
int stk[M],top;
|
||||||
void Pb(int x){
|
void Pb(int x){
|
||||||
for(int i=pos[x]>>1;i;i>>=1)stk[++top]=i;
|
for(int i=pos[x]>>1;i;i>>=1)stk[++top]=i;
|
||||||
while(top)Down(stk[top--]);
|
while(top)Down(stk[top--]);
|
||||||
}
|
}
|
||||||
LL sum,tmp;
|
LL sum,tmp;
|
||||||
int mx;
|
int mx;
|
||||||
int Ask_r(int x,LL t){
|
int Ask_r(int x,LL t){
|
||||||
Pb(x);
|
Pb(x);
|
||||||
int p=pos[x];
|
int p=pos[x];
|
||||||
if(1LL*fa.mx*max(mx,fa.mx)>=t)return x-1;
|
if(1LL*fa.mx*max(mx,fa.mx)>=t)return x-1;
|
||||||
int ret=x;
|
int ret=x;
|
||||||
sum=1LL*max(mx,fa.mx)*fa.mx;
|
sum=1LL*max(mx,fa.mx)*fa.mx;
|
||||||
mx=max(mx,fa.mx);
|
mx=max(mx,fa.mx);
|
||||||
while(p!=1){
|
while(p!=1){
|
||||||
if(p&1)p>>=1;
|
if(p&1)p>>=1;
|
||||||
else{
|
else{
|
||||||
p>>=1;
|
p>>=1;
|
||||||
if(sum+(tmp=get_ans(p<<1|1,mx)) < t){
|
if(sum+(tmp=get_ans(p<<1|1,mx)) < t){
|
||||||
ret=rson.r,mx=max(mx,rson.mx),sum+=tmp;
|
ret=rson.r,mx=max(mx,rson.mx),sum+=tmp;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Down(p);
|
Down(p);
|
||||||
p=p<<1|1;
|
p=p<<1|1;
|
||||||
while(fa.l^fa.r){
|
while(fa.l^fa.r){
|
||||||
Down(p);
|
Down(p);
|
||||||
if(sum+(tmp=get_ans(p<<1,mx)) < t)ret=lson.r,mx=max(mx,lson.mx),sum+=tmp,p=p<<1|1;
|
if(sum+(tmp=get_ans(p<<1,mx)) < t)ret=lson.r,mx=max(mx,lson.mx),sum+=tmp,p=p<<1|1;
|
||||||
else p<<=1;
|
else p<<=1;
|
||||||
}
|
}
|
||||||
if(sum+(tmp=1LL*fa.mx*max(fa.mx,mx)) < t)ret=fa.l,mx=max(mx,lson.mx),sum+=tmp;
|
if(sum+(tmp=1LL*fa.mx*max(fa.mx,mx)) < t)ret=fa.l,mx=max(mx,lson.mx),sum+=tmp;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
int Query(int x,LL t){
|
int Query(int x,LL t){
|
||||||
mx=sum=0;
|
mx=sum=0;
|
||||||
int r=Ask_r(x,t);
|
int r=Ask_r(x,t);
|
||||||
if(r<n-1)return r+1;
|
if(r<n-1)return r+1;
|
||||||
else{
|
else{
|
||||||
t-=sum;
|
t-=sum;
|
||||||
sum=0;
|
sum=0;
|
||||||
r = Ask_r(0,t);
|
r = Ask_r(0,t);
|
||||||
if(r<n-1)return r+1;
|
if(r<n-1)return r+1;
|
||||||
t-=sum;
|
t-=sum;
|
||||||
sum=0;
|
sum=0;
|
||||||
LL tt = tree[1].sum * mx;
|
LL tt = tree[1].sum * mx;
|
||||||
LL k = t/tt-(t%tt==0);
|
LL k = t/tt-(t%tt==0);
|
||||||
t-=tt*k;
|
t-=tt*k;
|
||||||
return Ask_r(0,t)+1;
|
return Ask_r(0,t)+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#undef fa
|
#undef fa
|
||||||
#undef lson
|
#undef lson
|
||||||
#undef rson
|
#undef rson
|
||||||
}Seg;
|
}Seg;
|
||||||
int main(){
|
int main(){
|
||||||
scanf("%d%d",&n,&q);
|
scanf("%d%d",&n,&q);
|
||||||
for(int i=0;i<n;i++)scanf("%d",&A[i]);
|
for(int i=0;i<n;i++)scanf("%d",&A[i]);
|
||||||
Seg.build(0,n-1);
|
Seg.build(0,n-1);
|
||||||
for(int i=1;i<=q;i++){
|
for(int i=1;i<=q;i++){
|
||||||
LL l,r,v;
|
LL l,r,v;
|
||||||
char op[3];
|
char op[3];
|
||||||
scanf("%s%lld%lld",op,&l,&r);
|
scanf("%s%lld%lld",op,&l,&r);
|
||||||
if(op[0]=='Q'){
|
if(op[0]=='Q'){
|
||||||
printf("%d\n",Seg.Query(l,r+1));
|
printf("%d\n",Seg.Query(l,r+1));
|
||||||
}else {
|
}else {
|
||||||
scanf("%lld",&v);
|
scanf("%lld",&v);
|
||||||
if(l<=r)Seg.Update(l,r,op[0]=='P'?1:2,v);
|
if(l<=r)Seg.Update(l,r,op[0]=='P'?1:2,v);
|
||||||
else {
|
else {
|
||||||
Seg.Update(l,n-1,op[0]=='P'?1:2,v);
|
Seg.Update(l,n-1,op[0]=='P'?1:2,v);
|
||||||
Seg.Update(0, r ,op[0]=='P'?1:2,v);
|
Seg.Update(0, r ,op[0]=='P'?1:2,v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1,36 +1,36 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
|
||||||
using std::cin,std::cout;
|
using std::cin,std::cout;
|
||||||
|
|
||||||
constexpr const auto range = std::ranges::views::iota;
|
constexpr const auto range = std::ranges::views::iota;
|
||||||
|
|
||||||
struct Point{
|
struct Point{
|
||||||
int x,y;
|
int x,y;
|
||||||
};
|
};
|
||||||
|
|
||||||
const int MAX_N = 1e4+5;
|
const int MAX_N = 1e4+5;
|
||||||
int n;
|
int n;
|
||||||
Point dir;
|
Point dir;
|
||||||
Point arr[MAX_N][2];
|
Point arr[MAX_N][2];
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
std::iostream::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
|
std::iostream::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
|
||||||
|
|
||||||
cin>>n;
|
cin>>n;
|
||||||
for(const int i:range(0,n)){
|
for(const int i:range(0,n)){
|
||||||
for(const int j:range(0,2)){
|
for(const int j:range(0,2)){
|
||||||
cin>>arr[i][j].x>>arr[i][j].y;
|
cin>>arr[i][j].x>>arr[i][j].y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cin>>dir.x>>dir.y;
|
cin>>dir.x>>dir.y;
|
||||||
|
|
||||||
for(int i=n-1;i>=0;i--){
|
for(int i=n-1;i>=0;i--){
|
||||||
if(arr[i][0].x<=dir.x && dir.x <= arr[i][0].x+arr[i][1].x
|
if(arr[i][0].x<=dir.x && dir.x <= arr[i][0].x+arr[i][1].x
|
||||||
&& arr[i][0].y<=dir.y && dir.y <= arr[i][0].y+arr[i][1].y){
|
&& arr[i][0].y<=dir.y && dir.y <= arr[i][0].y+arr[i][1].y){
|
||||||
std::cout<<i+1<<"\n";
|
std::cout<<i+1<<"\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout<<-1<<"\n";
|
std::cout<<-1<<"\n";
|
||||||
}
|
}
|
@ -1,32 +1,32 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
using std::cin, std::cout, std::iostream, std::max, std::for_each_n;
|
using std::cin, std::cout, std::iostream, std::max, std::for_each_n;
|
||||||
|
|
||||||
constexpr size_t MAX_N {(size_t)5e5+5};
|
constexpr size_t MAX_N {(size_t)5e5+5};
|
||||||
int arr[MAX_N], len[MAX_N], ans1, ans2{1}, n, last_max;
|
int arr[MAX_N], len[MAX_N], ans1, ans2{1}, n, last_max;
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
iostream::sync_with_stdio(false), cin.tie(0), cout.tie(0);
|
iostream::sync_with_stdio(false), cin.tie(0), cout.tie(0);
|
||||||
|
|
||||||
while(cin>>arr[n++]);
|
while(cin>>arr[n++]);
|
||||||
|
|
||||||
for(int i=0;i<n;i++){
|
for(int i=0;i<n;i++){
|
||||||
for(int j=i-1;j>=0;j--){ //j<i
|
for(int j=i-1;j>=0;j--){ //j<i
|
||||||
if(arr[j]>=arr[i] && len[i]<len[j]+1){
|
if(arr[j]>=arr[i] && len[i]<len[j]+1){
|
||||||
len[i] = len[j] + 1;
|
len[i] = len[j] + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for_each_n(len,n,[](decltype(*len) e){
|
for_each_n(len,n,[](decltype(*len) e){
|
||||||
ans1 = std::max(ans1,e);
|
ans1 = std::max(ans1,e);
|
||||||
});
|
});
|
||||||
for(int i=1;i<n;i++){
|
for(int i=1;i<n;i++){
|
||||||
if(arr[i]>arr[i-1]){
|
if(arr[i]>arr[i-1]){
|
||||||
ans2++;
|
ans2++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cout<<ans1<<'\n'<<ans2<<'\n';
|
cout<<ans1<<'\n'<<ans2<<'\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 40 PT
|
// 40 PT
|
@ -1,32 +1,32 @@
|
|||||||
#include <ios>
|
#include <ios>
|
||||||
#include<iostream>
|
#include<iostream>
|
||||||
|
|
||||||
int n;
|
int n;
|
||||||
int a[(int)1e4+5];
|
int a[(int)1e4+5];
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
std::ios::sync_with_stdio(false),std::cin.tie(nullptr),std::cout.tie(nullptr);
|
std::ios::sync_with_stdio(false),std::cin.tie(nullptr),std::cout.tie(nullptr);
|
||||||
|
|
||||||
std::cin>>n;
|
std::cin>>n;
|
||||||
|
|
||||||
int sum=0;
|
int sum=0;
|
||||||
for(int i=1;i<=n;i++){
|
for(int i=1;i<=n;i++){
|
||||||
std::cin>>a[i];
|
std::cin>>a[i];
|
||||||
sum+=a[i];
|
sum+=a[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
int avg = sum/n;
|
int avg = sum/n;
|
||||||
|
|
||||||
int ans = 0;
|
int ans = 0;
|
||||||
for(int i=1;i<n;i++){
|
for(int i=1;i<n;i++){
|
||||||
ans++;
|
ans++;
|
||||||
if(a[i]>avg){
|
if(a[i]>avg){
|
||||||
a[i+1]+=a[i]-avg;
|
a[i+1]+=a[i]-avg;
|
||||||
}else if(a[i]<avg){
|
}else if(a[i]<avg){
|
||||||
a[i+1]-=avg-a[i];
|
a[i+1]-=avg-a[i];
|
||||||
}else{
|
}else{
|
||||||
ans--;
|
ans--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout<<ans<<"\n";
|
std::cout<<ans<<"\n";
|
||||||
}
|
}
|
@ -1,70 +1,70 @@
|
|||||||
#include <ios>
|
#include <ios>
|
||||||
#include<iostream>
|
#include<iostream>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
const int MAX_N = (int)1e2+5;
|
const int MAX_N = (int)1e2+5;
|
||||||
int n;
|
int n;
|
||||||
int a[MAX_N];
|
int a[MAX_N];
|
||||||
int sum;
|
int sum;
|
||||||
int avg;
|
int avg;
|
||||||
int ans;
|
int ans;
|
||||||
struct Gift{
|
struct Gift{
|
||||||
int next,num;
|
int next,num;
|
||||||
};
|
};
|
||||||
std::vector<Gift> to[MAX_N];
|
std::vector<Gift> to[MAX_N];
|
||||||
int inDegree[MAX_N];
|
int inDegree[MAX_N];
|
||||||
std::queue<int> q;
|
std::queue<int> q;
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
std::ios::sync_with_stdio(false),std::cin.tie(nullptr),std::cout.tie(nullptr);
|
std::ios::sync_with_stdio(false),std::cin.tie(nullptr),std::cout.tie(nullptr);
|
||||||
|
|
||||||
std::cin>>n;
|
std::cin>>n;
|
||||||
|
|
||||||
|
|
||||||
for(int i=1;i<=n;i++){
|
for(int i=1;i<=n;i++){
|
||||||
std::cin>>a[i];
|
std::cin>>a[i];
|
||||||
sum+=a[i];
|
sum+=a[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
avg = sum/n;
|
avg = sum/n;
|
||||||
|
|
||||||
ans = 0;
|
ans = 0;
|
||||||
for(int i=1;i<n;i++){
|
for(int i=1;i<n;i++){
|
||||||
ans++;
|
ans++;
|
||||||
if(a[i]>avg){
|
if(a[i]>avg){
|
||||||
int num = a[i]-avg;
|
int num = a[i]-avg;
|
||||||
to[i].push_back({.next=i+1,.num=num});
|
to[i].push_back({.next=i+1,.num=num});
|
||||||
inDegree[i+1]++;
|
inDegree[i+1]++;
|
||||||
a[i+1]+=num;
|
a[i+1]+=num;
|
||||||
}else if(a[i]<avg){
|
}else if(a[i]<avg){
|
||||||
int num = avg-a[i];
|
int num = avg-a[i];
|
||||||
to[i+1].push_back({.next=i,.num=num});
|
to[i+1].push_back({.next=i,.num=num});
|
||||||
inDegree[i]++;
|
inDegree[i]++;
|
||||||
a[i+1]-=num;
|
a[i+1]-=num;
|
||||||
}else{
|
}else{
|
||||||
ans--;
|
ans--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i=1;i<=n;i++){
|
for(int i=1;i<=n;i++){
|
||||||
if(inDegree[i]==0){
|
if(inDegree[i]==0){
|
||||||
q.push(i);
|
q.push(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while(q.empty()==false){
|
while(q.empty()==false){
|
||||||
int top = q.front();
|
int top = q.front();
|
||||||
q.pop();
|
q.pop();
|
||||||
|
|
||||||
for(Gift i:to[top]){
|
for(Gift i:to[top]){
|
||||||
inDegree[i.next]--;
|
inDegree[i.next]--;
|
||||||
std::cout<<top<<" give "<<i.next<<" "<<i.num<<" points\n";
|
std::cout<<top<<" give "<<i.next<<" "<<i.num<<" points\n";
|
||||||
if(inDegree[i.next]==0){
|
if(inDegree[i.next]==0){
|
||||||
q.push(i.next);
|
q.push(i.next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// std::cout<<ans<<"\n";
|
// std::cout<<ans<<"\n";
|
||||||
}
|
}
|
@ -1,35 +1,35 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
using std::cin,std::cout,std::max,std::iostream;
|
using std::cin,std::cout,std::max,std::iostream;
|
||||||
|
|
||||||
constexpr size_t MAX_N {100+5};
|
constexpr size_t MAX_N {100+5};
|
||||||
int n, arr[MAX_N], go_up[MAX_N], go_down[MAX_N], ans;
|
int n, arr[MAX_N], go_up[MAX_N], go_down[MAX_N], ans;
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
iostream::sync_with_stdio(false),cin.tie(0),cout.tie(0);
|
iostream::sync_with_stdio(false),cin.tie(0),cout.tie(0);
|
||||||
|
|
||||||
cin>>n;
|
cin>>n;
|
||||||
for(int i=0;i<n;i++){
|
for(int i=0;i<n;i++){
|
||||||
cin>>arr[i];
|
cin>>arr[i];
|
||||||
go_up[i]=1,go_down[i]=1;
|
go_up[i]=1,go_down[i]=1;
|
||||||
}
|
}
|
||||||
for(int i=0;i<n;i++){//j < i
|
for(int i=0;i<n;i++){//j < i
|
||||||
for(int j=i-1;j>=0;j--){
|
for(int j=i-1;j>=0;j--){
|
||||||
if(arr[j]<arr[i] && go_up[i]<go_up[j]+1){
|
if(arr[j]<arr[i] && go_up[i]<go_up[j]+1){
|
||||||
go_up[i] = go_up[j]+1;
|
go_up[i] = go_up[j]+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int i=n-1;i>=0;i--){//i < j
|
for(int i=n-1;i>=0;i--){//i < j
|
||||||
for(int j=i+1;j<n;j++){
|
for(int j=i+1;j<n;j++){
|
||||||
if(arr[j]<arr[i] && go_down[i]<go_down[j]+1){
|
if(arr[j]<arr[i] && go_down[i]<go_down[j]+1){
|
||||||
go_down[i] = go_down[j] + 1;
|
go_down[i] = go_down[j] + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int i=0;i<n;i++){
|
for(int i=0;i<n;i++){
|
||||||
ans = max(ans,go_down[i]+go_up[i]-1);
|
ans = max(ans,go_down[i]+go_up[i]-1);
|
||||||
}
|
}
|
||||||
cout<<n-ans<<'\n';
|
cout<<n-ans<<'\n';
|
||||||
}
|
}
|
@ -1,31 +1,31 @@
|
|||||||
#include<iostream>
|
#include<iostream>
|
||||||
|
|
||||||
using std::cin,std::cout,std::iostream;
|
using std::cin,std::cout,std::iostream;
|
||||||
|
|
||||||
const int MAX_COLOR = 50+5;
|
const int MAX_COLOR = 50+5;
|
||||||
|
|
||||||
int price,color,n,k,p,last_coffee_shop,last_hotel[MAX_COLOR],left_hotel_num[MAX_COLOR],cnt_hotel_num[MAX_COLOR],ans;
|
int price,color,n,k,p,last_coffee_shop,last_hotel[MAX_COLOR],left_hotel_num[MAX_COLOR],cnt_hotel_num[MAX_COLOR],ans;
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
iostream::sync_with_stdio(false),cin.tie(0),cout.tie(0);
|
iostream::sync_with_stdio(false),cin.tie(0),cout.tie(0);
|
||||||
|
|
||||||
cin>>n>>k>>p;
|
cin>>n>>k>>p;
|
||||||
|
|
||||||
for(int i=1;i<=n;i++){
|
for(int i=1;i<=n;i++){
|
||||||
cin>>color>>price;
|
cin>>color>>price;
|
||||||
|
|
||||||
if(price<=p){
|
if(price<=p){
|
||||||
last_coffee_shop = i;
|
last_coffee_shop = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(last_hotel[color] <= last_coffee_shop){
|
if(last_hotel[color] <= last_coffee_shop){
|
||||||
left_hotel_num[color] = cnt_hotel_num[color];
|
left_hotel_num[color] = cnt_hotel_num[color];
|
||||||
}
|
}
|
||||||
|
|
||||||
last_hotel[color]=i;
|
last_hotel[color]=i;
|
||||||
ans+=left_hotel_num[color];
|
ans+=left_hotel_num[color];
|
||||||
cnt_hotel_num[color]++;
|
cnt_hotel_num[color]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
cout<<ans<<"\n";
|
cout<<ans<<"\n";
|
||||||
}
|
}
|
@ -1,65 +1,72 @@
|
|||||||
#include <iostream>
|
//#define NDEBUG
|
||||||
#include <vector>
|
#include <iostream>
|
||||||
#include <queue>
|
#include <vector>
|
||||||
#include <algorithm>
|
#include <queue>
|
||||||
|
#include <algorithm>
|
||||||
using ll = long long;
|
#define NV(v)#v<<" : "<<(v)
|
||||||
using std::endl;
|
#ifdef NDEBUG
|
||||||
static auto &is = std::cin;
|
#define DEBUG(code)
|
||||||
static auto &os = std::cout;
|
#else
|
||||||
|
#define DEBUG(code){code}
|
||||||
static const ll max_n = 1e4+5;
|
#endif
|
||||||
|
|
||||||
static ll n, m, a, b;
|
using ll = long long;
|
||||||
static std::vector<ll> next[max_n];
|
using std::endl;
|
||||||
static bool vis[max_n];
|
static auto &is = std::cin;
|
||||||
static std::queue<ll> q;
|
static auto &os = std::cout;
|
||||||
static int colors[max_n];
|
|
||||||
static ll color_sum[3];
|
static const ll max_n = 1e4+5;
|
||||||
void set_color(const ll n,const int color)noexcept{
|
|
||||||
colors[n]=color;
|
static ll n, m, a, b;
|
||||||
color_sum[color]++;
|
static std::vector<ll> next[max_n];
|
||||||
}
|
static bool vis[max_n];
|
||||||
|
static std::queue<ll> q;
|
||||||
void flush_exit()noexcept{
|
static int colors[max_n];
|
||||||
os<<endl;
|
static ll color_sum[3];
|
||||||
_Exit(0);
|
void set_color(const ll n,const int color)noexcept{
|
||||||
}
|
colors[n]=color;
|
||||||
|
color_sum[color]++;
|
||||||
void bfs(){
|
}
|
||||||
for(ll i{1};i<=n;i++){
|
|
||||||
if(vis[i])continue;
|
void flush_exit()noexcept{
|
||||||
q.push(i);
|
os<<endl;
|
||||||
set_color(i, 1);
|
_Exit(0);
|
||||||
while(!q.empty()){
|
}
|
||||||
const auto front = q.front();
|
|
||||||
q.pop();
|
void bfs(){
|
||||||
|
for(ll i{1};i<=n;i++){
|
||||||
for(const auto i:next[front]){
|
if(vis[i])continue;
|
||||||
if(vis[i]){
|
q.push(i);
|
||||||
if(colors[i]==colors[front]){
|
set_color(i, 1);
|
||||||
os<<"Impossible";
|
while(!q.empty()){
|
||||||
flush_exit();
|
const auto front = q.front();
|
||||||
}
|
q.pop();
|
||||||
continue;
|
|
||||||
}
|
for(const auto i:next[front]){
|
||||||
set_color(i,(colors[front]&1)+1);
|
if(vis[i]){
|
||||||
vis[i]=true;
|
if(colors[i]==colors[front]){
|
||||||
q.push(i);
|
os<<"Impossible";
|
||||||
}
|
flush_exit();
|
||||||
}
|
}
|
||||||
}
|
continue;
|
||||||
}
|
}
|
||||||
|
set_color(i,(colors[front]&1)+1);
|
||||||
int main(){
|
vis[i]=true;
|
||||||
is>>n>>m;
|
q.push(i);
|
||||||
for(ll i{0};i<m;i++){
|
}
|
||||||
is>>a>>b;
|
}
|
||||||
next[a].push_back(b);
|
}
|
||||||
next[b].push_back(a);
|
}
|
||||||
}
|
|
||||||
|
int main(){
|
||||||
bfs();
|
is>>n>>m;
|
||||||
os<<std::min(color_sum[1],color_sum[2]);
|
for(ll i{0};i<m;i++){
|
||||||
flush_exit();
|
is>>a>>b;
|
||||||
|
next[a].push_back(b);
|
||||||
|
next[b].push_back(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
bfs();
|
||||||
|
os<<std::min(color_sum[1],color_sum[2]);
|
||||||
|
flush_exit();
|
||||||
}
|
}
|
@ -1,103 +1,103 @@
|
|||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#define NV(v)#v<<" : "<<(v)
|
#define NV(v)#v<<" : "<<(v)
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
#define DEBUG(code)
|
#define DEBUG(code)
|
||||||
#else
|
#else
|
||||||
#define DEBUG(code){code}
|
#define DEBUG(code){code}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using ull = unsigned long long;
|
using ull = unsigned long long;
|
||||||
const size_t max_n = 150+5;
|
const size_t max_n = 150+5;
|
||||||
struct Point{
|
struct Point{
|
||||||
ull x,y;
|
ull x,y;
|
||||||
};
|
};
|
||||||
ull n;
|
ull n;
|
||||||
Point points[max_n];
|
Point points[max_n];
|
||||||
std::string s;
|
std::string s;
|
||||||
double mtx_len[max_n][max_n];
|
double mtx_len[max_n][max_n];
|
||||||
double max_len[max_n];
|
double max_len[max_n];
|
||||||
const double double_max = std::numeric_limits<double>::max(), double_min = std::numeric_limits<double>::min();
|
const double double_max = std::numeric_limits<double>::max(), double_min = std::numeric_limits<double>::min();
|
||||||
double min_ans {double_max}, default_ans{0};
|
double min_ans {double_max}, default_ans{0};
|
||||||
|
|
||||||
double len(const Point &p1, const Point &p2){
|
double len(const Point &p1, const Point &p2){
|
||||||
return std::sqrt(
|
return std::sqrt(
|
||||||
std::pow((double)p1.x-(double)p2.x, (double)2)+
|
std::pow((double)p1.x-(double)p2.x, (double)2)+
|
||||||
std::pow((double)p1.y-(double)p2.y,(double)2)
|
std::pow((double)p1.y-(double)p2.y,(double)2)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
// std::cout<<INF<<'\n';
|
// std::cout<<INF<<'\n';
|
||||||
std::cin>>n;
|
std::cin>>n;
|
||||||
|
|
||||||
for(ull i = 1;i<=n;i++){
|
for(ull i = 1;i<=n;i++){
|
||||||
std::cin>>points[i].x>>points[i].y;
|
std::cin>>points[i].x>>points[i].y;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(ull i=1;i<=n;i++){
|
for(ull i=1;i<=n;i++){
|
||||||
std::cin>>s;
|
std::cin>>s;
|
||||||
for(ull j=1;j<=n;j++){
|
for(ull j=1;j<=n;j++){
|
||||||
if(i==j){
|
if(i==j){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(s[j-1]=='1'){
|
if(s[j-1]=='1'){
|
||||||
mtx_len[i][j] = len(points[i],points[j]);
|
mtx_len[i][j] = len(points[i],points[j]);
|
||||||
}else{
|
}else{
|
||||||
mtx_len[i][j] = double_max;
|
mtx_len[i][j] = double_max;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(ull k=1;k<=n;k++){
|
for(ull k=1;k<=n;k++){
|
||||||
for(ull i=1;i<=n;i++){
|
for(ull i=1;i<=n;i++){
|
||||||
for(ull j=1;j<=n;j++){
|
for(ull j=1;j<=n;j++){
|
||||||
double new_len;
|
double new_len;
|
||||||
if(mtx_len[i][k]!=double_max && mtx_len[k][j]!=double_max){
|
if(mtx_len[i][k]!=double_max && mtx_len[k][j]!=double_max){
|
||||||
new_len = mtx_len[i][k]+mtx_len[k][j];
|
new_len = mtx_len[i][k]+mtx_len[k][j];
|
||||||
}else{
|
}else{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(new_len<mtx_len[i][j]){
|
if(new_len<mtx_len[i][j]){
|
||||||
mtx_len[i][j] = new_len;
|
mtx_len[i][j] = new_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(ull i=1;i<=n;i++){
|
for(ull i=1;i<=n;i++){
|
||||||
max_len[i]=double_max;
|
max_len[i]=double_max;
|
||||||
for(ull j=1;j<=n;j++){
|
for(ull j=1;j<=n;j++){
|
||||||
if(mtx_len[i][j]==double_max)continue;
|
if(mtx_len[i][j]==double_max)continue;
|
||||||
max_len[i] = std::max(mtx_len[i][j],(max_len[i]==double_max?double_min:max_len[i]));
|
max_len[i] = std::max(mtx_len[i][j],(max_len[i]==double_max?double_min:max_len[i]));
|
||||||
default_ans = std::max(default_ans,max_len[i]);
|
default_ans = std::max(default_ans,max_len[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DEBUG(
|
DEBUG(
|
||||||
std::cout<<NV(min_ans)<<"\n---start\n";
|
std::cout<<NV(min_ans)<<"\n---start\n";
|
||||||
)
|
)
|
||||||
for(ull i=1;i<=n;i++){
|
for(ull i=1;i<=n;i++){
|
||||||
for(ull j=i+1;j<=n;j++){
|
for(ull j=i+1;j<=n;j++){
|
||||||
if(mtx_len[i][j]==double_max){
|
if(mtx_len[i][j]==double_max){
|
||||||
DEBUG(
|
DEBUG(
|
||||||
std::cout<<NV(i)<<'\n'<<NV(j)<<'\n'<<NV(max_len[i])<<'\n'<<NV(max_len[j])<<'\n'
|
std::cout<<NV(i)<<'\n'<<NV(j)<<'\n'<<NV(max_len[i])<<'\n'<<NV(max_len[j])<<'\n'
|
||||||
<<NV(len(points[i], points[j]))<<'\n'<<NV(max_len[i]+ len(points[i], points[j]) + max_len[j])<<'\n';
|
<<NV(len(points[i], points[j]))<<'\n'<<NV(max_len[i]+ len(points[i], points[j]) + max_len[j])<<'\n';
|
||||||
)
|
)
|
||||||
min_ans = std::min(max_len[i]+ len(points[i], points[j]) +max_len[j],min_ans);
|
min_ans = std::min(max_len[i]+ len(points[i], points[j]) +max_len[j],min_ans);
|
||||||
DEBUG(
|
DEBUG(
|
||||||
std::cout<<NV(min_ans)<<'\n';
|
std::cout<<NV(min_ans)<<'\n';
|
||||||
std::cout<<"---\n";
|
std::cout<<"---\n";
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout<<std::fixed<<std::setprecision(6)<<(min_ans==double_max?default_ans:std::max(default_ans, min_ans))<<'\n';
|
std::cout<<std::fixed<<std::setprecision(6)<<(min_ans==double_max?default_ans:std::max(default_ans, min_ans))<<'\n';
|
||||||
}
|
}
|
@ -1,28 +1,28 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
#define NV(v)#v<<" : "<<(v)
|
#define NV(v)#v<<" : "<<(v)
|
||||||
using ull = unsigned long long;
|
using ull = unsigned long long;
|
||||||
|
|
||||||
static ull n, m, k, x;
|
static ull n, m, k, x;
|
||||||
static auto &is = std::cin;
|
static auto &is = std::cin;
|
||||||
static auto &os = std::cout;
|
static auto &os = std::cout;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
T fast_pow(T b,T e, const T &k){
|
T fast_pow(T b,T e, const T &k){
|
||||||
T ret{1};
|
T ret{1};
|
||||||
b%=k;
|
b%=k;
|
||||||
while(e>0){
|
while(e>0){
|
||||||
if(e&1){
|
if(e&1){
|
||||||
ret = (ret * b)%k;
|
ret = (ret * b)%k;
|
||||||
}
|
}
|
||||||
e>>=1;
|
e>>=1;
|
||||||
b = (b*b) %k;
|
b = (b*b) %k;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
// os<<NV(fast_pow(3,3, 1000))<<'\n';
|
// os<<NV(fast_pow(3,3, 1000))<<'\n';
|
||||||
is>>n>>m>>k>>x;
|
is>>n>>m>>k>>x;
|
||||||
os<<((x+m*((ull)(fast_pow(10ull,k,n))%n))%n)<<'\n';
|
os<<((x+m*((ull)(fast_pow(10ull,k,n))%n))%n)<<'\n';
|
||||||
}
|
}
|
@ -1,44 +1,44 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
using ull = unsigned long long;
|
using ull = unsigned long long;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class ReadNumber{
|
class ReadNumber{
|
||||||
char c;
|
char c;
|
||||||
T w,n;
|
T w,n;
|
||||||
public:
|
public:
|
||||||
ReadNumber& operator>>(T &t){
|
ReadNumber& operator>>(T &t){
|
||||||
c=(char)0,w=1,n=0;
|
c=(char)0,w=1,n=0;
|
||||||
while(!isdigit(c)){
|
while(!isdigit(c)){
|
||||||
if constexpr (std::is_signed_v<T>){
|
if constexpr (std::is_signed_v<T>){
|
||||||
if(c=='-')w=-1;
|
if(c=='-')w=-1;
|
||||||
}
|
}
|
||||||
c=getchar();
|
c=getchar();
|
||||||
}
|
}
|
||||||
while(isdigit(c)){
|
while(isdigit(c)){
|
||||||
n=n*10+(c-'0');
|
n=n*10+(c-'0');
|
||||||
c=getchar();
|
c=getchar();
|
||||||
}
|
}
|
||||||
t = n*w;
|
t = n*w;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
static ReadNumber<ull> readull;
|
static ReadNumber<ull> readull;
|
||||||
// static auto &is = std::cin;
|
// static auto &is = std::cin;
|
||||||
static auto &is = readull;
|
static auto &is = readull;
|
||||||
static auto &os = std::cout;
|
static auto &os = std::cout;
|
||||||
|
|
||||||
static ull a, b, ans, n;
|
static ull a, b, ans, n;
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
is>>n;
|
is>>n;
|
||||||
for(size_t i{0};i<n;i++){
|
for(size_t i{0};i<n;i++){
|
||||||
is>>b;
|
is>>b;
|
||||||
if(a<b){
|
if(a<b){
|
||||||
ans+=b-a;
|
ans+=b-a;
|
||||||
}
|
}
|
||||||
a=b;
|
a=b;
|
||||||
}
|
}
|
||||||
os<<ans<<'\n';
|
os<<ans<<'\n';
|
||||||
}
|
}
|
@ -1,51 +1,51 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
|
||||||
using std::cin,std::cout;
|
using std::cin,std::cout;
|
||||||
static constexpr const auto range = std::ranges::views::iota;
|
static constexpr const auto range = std::ranges::views::iota;
|
||||||
|
|
||||||
const int MAX_N = 39+5;
|
const int MAX_N = 39+5;
|
||||||
int n;
|
int n;
|
||||||
int map[MAX_N][MAX_N];
|
int map[MAX_N][MAX_N];
|
||||||
int x,y,now{1};
|
int x,y,now{1};
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
std::iostream::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
|
std::iostream::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
|
||||||
|
|
||||||
std::cin>>n;
|
std::cin>>n;
|
||||||
x=1,y=n/2+1;
|
x=1,y=n/2+1;
|
||||||
|
|
||||||
map[x][y]=now++;
|
map[x][y]=now++;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
1. 若 $(K-1)$ 在第一行但不在最后一列,则将 $K$ 填在最后一行, $(K-1)$ 所在列的右一列;
|
1. 若 $(K-1)$ 在第一行但不在最后一列,则将 $K$ 填在最后一行, $(K-1)$ 所在列的右一列;
|
||||||
2. 若 $(K-1)$ 在最后一列但不在第一行,则将 $K$ 填在第一列, $(K-1)$ 所在行的上一行;
|
2. 若 $(K-1)$ 在最后一列但不在第一行,则将 $K$ 填在第一列, $(K-1)$ 所在行的上一行;
|
||||||
3. 若 $(K-1)$ 在第一行最后一列,则将 $K$ 填在 $(K-1)$ 的正下方;
|
3. 若 $(K-1)$ 在第一行最后一列,则将 $K$ 填在 $(K-1)$ 的正下方;
|
||||||
4. 若 $(K-1)$ 既不在第一行,也不在最后一列,如果 $(K-1)$ 的右上方还未填数,则将 $K$ 填在 $(K-1)$ 的右上方,否则将 $K$ 填在 $(K-1)$ 的正下方。
|
4. 若 $(K-1)$ 既不在第一行,也不在最后一列,如果 $(K-1)$ 的右上方还未填数,则将 $K$ 填在 $(K-1)$ 的右上方,否则将 $K$ 填在 $(K-1)$ 的正下方。
|
||||||
*/
|
*/
|
||||||
while(now<=n*n){
|
while(now<=n*n){
|
||||||
if(x==1 && y!=n){
|
if(x==1 && y!=n){
|
||||||
x=n,y++;
|
x=n,y++;
|
||||||
}else if(y==n && x!=1){
|
}else if(y==n && x!=1){
|
||||||
y=1,x--;
|
y=1,x--;
|
||||||
}else if(x==1 && y==n){
|
}else if(x==1 && y==n){
|
||||||
x++;
|
x++;
|
||||||
}else if(x!=1 && y!=n){
|
}else if(x!=1 && y!=n){
|
||||||
if(map[x-1][y+1]==0){
|
if(map[x-1][y+1]==0){
|
||||||
x--;
|
x--;
|
||||||
y++;
|
y++;
|
||||||
}else{
|
}else{
|
||||||
x++;
|
x++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
map[x][y]=now++;
|
map[x][y]=now++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i:range(1,n+1)){
|
for(int i:range(1,n+1)){
|
||||||
for(int j:range(1,n+1)){
|
for(int j:range(1,n+1)){
|
||||||
std::cout<<map[i][j]<<" ";
|
std::cout<<map[i][j]<<" ";
|
||||||
}
|
}
|
||||||
std::cout<<"\n";
|
std::cout<<"\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,54 +1,54 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
using std::cin,std::cout;
|
using std::cin,std::cout;
|
||||||
|
|
||||||
const int MAX_N {(int)2e5+5};
|
const int MAX_N {(int)2e5+5};
|
||||||
int n;
|
int n;
|
||||||
int next[MAX_N];
|
int next[MAX_N];
|
||||||
int in_degree[MAX_N];
|
int in_degree[MAX_N];
|
||||||
bool vis[MAX_N];
|
bool vis[MAX_N];
|
||||||
std::queue<int> q;
|
std::queue<int> q;
|
||||||
int ans {std::numeric_limits<int>::max()};
|
int ans {std::numeric_limits<int>::max()};
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
std::iostream::sync_with_stdio(false),cin.tie(0),cout.tie(0);
|
std::iostream::sync_with_stdio(false),cin.tie(0),cout.tie(0);
|
||||||
|
|
||||||
std::cin>>n;
|
std::cin>>n;
|
||||||
for(int i=1;i<=n;i++){
|
for(int i=1;i<=n;i++){
|
||||||
cin>>next[i];
|
cin>>next[i];
|
||||||
in_degree[next[i]]++;
|
in_degree[next[i]]++;
|
||||||
}
|
}
|
||||||
const auto push_vis = [](int n){
|
const auto push_vis = [](int n){
|
||||||
q.push(n);
|
q.push(n);
|
||||||
vis[n]=true;
|
vis[n]=true;
|
||||||
};
|
};
|
||||||
for(int i=1;i<=n;i++){
|
for(int i=1;i<=n;i++){
|
||||||
if(in_degree[i]<=0){
|
if(in_degree[i]<=0){
|
||||||
push_vis(i);
|
push_vis(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while(q.empty()==false){
|
while(q.empty()==false){
|
||||||
int front = q.front();
|
int front = q.front();
|
||||||
q.pop();
|
q.pop();
|
||||||
if(--in_degree[next[front]]<=0){
|
if(--in_degree[next[front]]<=0){
|
||||||
push_vis(next[front]);
|
push_vis(next[front]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int i=1;i<=n;i++){
|
for(int i=1;i<=n;i++){
|
||||||
if(vis[i])continue;
|
if(vis[i])continue;
|
||||||
int loop_size {0};
|
int loop_size {0};
|
||||||
int start {i};
|
int start {i};
|
||||||
int now {start};
|
int now {start};
|
||||||
do{
|
do{
|
||||||
vis[now]=true;
|
vis[now]=true;
|
||||||
now=next[now];
|
now=next[now];
|
||||||
loop_size++;
|
loop_size++;
|
||||||
}while(now!=start);
|
}while(now!=start);
|
||||||
ans=std::min(ans,loop_size);
|
ans=std::min(ans,loop_size);
|
||||||
}
|
}
|
||||||
std::cout<<ans<<"\n";
|
std::cout<<ans<<"\n";
|
||||||
}
|
}
|
@ -1,61 +1,61 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
using std::cin,std::cout;
|
using std::cin,std::cout;
|
||||||
constexpr const auto range = std::ranges::views::iota;
|
constexpr const auto range = std::ranges::views::iota;
|
||||||
|
|
||||||
const int MAX_N = 2e5+5;
|
const int MAX_N = 2e5+5;
|
||||||
int n;
|
int n;
|
||||||
int next[MAX_N];
|
int next[MAX_N];
|
||||||
int in_degree[MAX_N];
|
int in_degree[MAX_N];
|
||||||
std::queue<int> q;
|
std::queue<int> q;
|
||||||
bool vis[MAX_N];
|
bool vis[MAX_N];
|
||||||
int ans {std::numeric_limits<int>::max()};
|
int ans {std::numeric_limits<int>::max()};
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
std::iostream::sync_with_stdio(false),cin.tie(nullptr),cout.tie(0);
|
std::iostream::sync_with_stdio(false),cin.tie(nullptr),cout.tie(0);
|
||||||
|
|
||||||
cin>>n;
|
cin>>n;
|
||||||
for(const int i:range(1,n+1)){
|
for(const int i:range(1,n+1)){
|
||||||
cin>>next[i];
|
cin>>next[i];
|
||||||
in_degree[next[i]]++;
|
in_degree[next[i]]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto push_vis = [](const int n){
|
const auto push_vis = [](const int n){
|
||||||
q.push(n);
|
q.push(n);
|
||||||
vis[n]=true;
|
vis[n]=true;
|
||||||
};
|
};
|
||||||
for(const int i:range(1,n+1)){
|
for(const int i:range(1,n+1)){
|
||||||
if(in_degree[i]==0){
|
if(in_degree[i]==0){
|
||||||
push_vis(i);
|
push_vis(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while(q.empty()==false){
|
while(q.empty()==false){
|
||||||
int front = q.front();
|
int front = q.front();
|
||||||
q.pop();
|
q.pop();
|
||||||
in_degree[next[front]]--;
|
in_degree[next[front]]--;
|
||||||
if(in_degree[next[front]]==0){
|
if(in_degree[next[front]]==0){
|
||||||
push_vis(next[front]);
|
push_vis(next[front]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i:range(1,n+1)){
|
for(int i:range(1,n+1)){
|
||||||
if(vis[i])continue;
|
if(vis[i])continue;
|
||||||
const int start {i};
|
const int start {i};
|
||||||
int now {start};
|
int now {start};
|
||||||
int ring_size {0};
|
int ring_size {0};
|
||||||
do{
|
do{
|
||||||
vis[now]=true;
|
vis[now]=true;
|
||||||
ring_size++;
|
ring_size++;
|
||||||
now = next[now];
|
now = next[now];
|
||||||
}while(now!=start);
|
}while(now!=start);
|
||||||
ans = std::min(ans,ring_size);
|
ans = std::min(ans,ring_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
cout<<ans<<"\n";
|
cout<<ans<<"\n";
|
||||||
}
|
}
|
@ -1,59 +1,59 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
using std::cin,std::cout,std::sort,std::max;
|
using std::cin,std::cout,std::sort,std::max;
|
||||||
|
|
||||||
constexpr int MAX_N {(int)2e5+5};
|
constexpr int MAX_N {(int)2e5+5};
|
||||||
struct City{
|
struct City{
|
||||||
int a,b;
|
int a,b;
|
||||||
bool operator<(const City &that)const noexcept{
|
bool operator<(const City &that)const noexcept{
|
||||||
return this->a<that.a;
|
return this->a<that.a;
|
||||||
}
|
}
|
||||||
} city[MAX_N];
|
} city[MAX_N];
|
||||||
int n, len[MAX_N],ans;
|
int n, len[MAX_N],ans;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class ReadNumber{
|
class ReadNumber{
|
||||||
char c;
|
char c;
|
||||||
T w,n;
|
T w,n;
|
||||||
public:
|
public:
|
||||||
ReadNumber& operator>>(T &num)noexcept{
|
ReadNumber& operator>>(T &num)noexcept{
|
||||||
c=(char)0,w=1,n=0;
|
c=(char)0,w=1,n=0;
|
||||||
while(!isdigit(c)){
|
while(!isdigit(c)){
|
||||||
// if constexpr(!std::is_same_v<ull, T>){
|
// if constexpr(!std::is_same_v<ull, T>){
|
||||||
// if(c=='-')w=-1;
|
// if(c=='-')w=-1;
|
||||||
// }
|
// }
|
||||||
c = getchar();
|
c = getchar();
|
||||||
}
|
}
|
||||||
while(isdigit(c)){
|
while(isdigit(c)){
|
||||||
n = n*10 + (c-'0');
|
n = n*10 + (c-'0');
|
||||||
c = getchar();
|
c = getchar();
|
||||||
}
|
}
|
||||||
num = w*n;
|
num = w*n;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ReadNumber<int> readint;
|
ReadNumber<int> readint;
|
||||||
#define cin readint
|
#define cin readint
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
cin>>n;
|
cin>>n;
|
||||||
for(int i=0;i<n;i++){
|
for(int i=0;i<n;i++){
|
||||||
cin>>city[i].a>>city[i].b;
|
cin>>city[i].a>>city[i].b;
|
||||||
len[i]=1;
|
len[i]=1;
|
||||||
}
|
}
|
||||||
sort(city,city+n);
|
sort(city,city+n);
|
||||||
for(int i=0;i<n;i++){
|
for(int i=0;i<n;i++){
|
||||||
for(int j=i-1;j>=0;j--){
|
for(int j=i-1;j>=0;j--){
|
||||||
if(city[j].b<city[i].b && len[i]<len[j]+1){
|
if(city[j].b<city[i].b && len[i]<len[j]+1){
|
||||||
len[i]=len[j]+1;
|
len[i]=len[j]+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(int i=0;i<n;i++){
|
for(int i=0;i<n;i++){
|
||||||
// cout<<"i:"<<i<<" "<<"len:"<<len[i]<<'\n';
|
// cout<<"i:"<<i<<" "<<"len:"<<len[i]<<'\n';
|
||||||
ans = max(ans,len[i]);
|
ans = max(ans,len[i]);
|
||||||
}
|
}
|
||||||
cout<<ans<<'\n';
|
cout<<ans<<'\n';
|
||||||
}
|
}
|
@ -1,47 +1,47 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
using ull = unsigned long long;
|
using ull = unsigned long long;
|
||||||
#define NV(v)#v<<" : "<<(v)
|
#define NV(v)#v<<" : "<<(v)
|
||||||
|
|
||||||
static ull t, k, n, m, ans;
|
static ull t, k, n, m, ans;
|
||||||
static std::map<ull,ull> fact_map;
|
static std::map<ull,ull> fact_map;
|
||||||
static std::map<std::pair<ull,ull>,ull> C_map;
|
static std::map<std::pair<ull,ull>,ull> C_map;
|
||||||
|
|
||||||
static ull fact(const ull n)noexcept{
|
static ull fact(const ull n)noexcept{
|
||||||
if(n==0)return 1;
|
if(n==0)return 1;
|
||||||
const auto it = fact_map.find(n);
|
const auto it = fact_map.find(n);
|
||||||
if(it != fact_map.end())return (*it).second;
|
if(it != fact_map.end())return (*it).second;
|
||||||
ull ret {1};
|
ull ret {1};
|
||||||
for(ull i{2};i<=n;i++){
|
for(ull i{2};i<=n;i++){
|
||||||
ret*=i;
|
ret*=i;
|
||||||
}
|
}
|
||||||
fact_map.insert({n,ret});
|
fact_map.insert({n,ret});
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static ull C(const ull n, const ull m)noexcept{
|
static ull C(const ull n, const ull m)noexcept{
|
||||||
const auto it = C_map.find({n,m});
|
const auto it = C_map.find({n,m});
|
||||||
if(it!=C_map.end())return (*it).second;
|
if(it!=C_map.end())return (*it).second;
|
||||||
const ull ret = (fact(n))/(fact(m)*fact(n-m));
|
const ull ret = (fact(n))/(fact(m)*fact(n-m));
|
||||||
C_map.insert({{n,m},ret});
|
C_map.insert({{n,m},ret});
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
// std::cout<<NV(fact(0))<<'\n'<<NV(fact(3))<<'\n';
|
// std::cout<<NV(fact(0))<<'\n'<<NV(fact(3))<<'\n';
|
||||||
std::iostream::sync_with_stdio(false), std::cin.tie(nullptr), std::cout.tie(nullptr);
|
std::iostream::sync_with_stdio(false), std::cin.tie(nullptr), std::cout.tie(nullptr);
|
||||||
std::cin>>t>>k;
|
std::cin>>t>>k;
|
||||||
|
|
||||||
for(ull i {0};i<t;i++){
|
for(ull i {0};i<t;i++){
|
||||||
std::cin>>n>>m;
|
std::cin>>n>>m;
|
||||||
ans = 0;
|
ans = 0;
|
||||||
for(ull i {0};i<=n;i++){
|
for(ull i {0};i<=n;i++){
|
||||||
for(ull j{0};j<=std::min(i,m);j++){
|
for(ull j{0};j<=std::min(i,m);j++){
|
||||||
if(C(i,j)%k==0)ans++;
|
if(C(i,j)%k==0)ans++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout<<ans<<'\n';
|
std::cout<<ans<<'\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,136 +1,136 @@
|
|||||||
// #define NDEBUG //切换release和debug版本
|
// #define NDEBUG //切换release和debug版本
|
||||||
|
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
using ull = unsigned long long;
|
using ull = unsigned long long;
|
||||||
|
|
||||||
template<class T,size_t size>
|
template<class T,size_t size>
|
||||||
struct Array{
|
struct Array{
|
||||||
constexpr Array(){};
|
constexpr Array(){};
|
||||||
constexpr Array(const std::initializer_list<T> list){
|
constexpr Array(const std::initializer_list<T> list){
|
||||||
std::copy(list.begin(),list.end(),arr);
|
std::copy(list.begin(),list.end(),arr);
|
||||||
}
|
}
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
#define NDB_NOEXCEPT noexcept
|
#define NDB_NOEXCEPT noexcept
|
||||||
#define NDB_CONSTEXPR constexpr
|
#define NDB_CONSTEXPR constexpr
|
||||||
#else
|
#else
|
||||||
#define NDB_NOEXCEPT
|
#define NDB_NOEXCEPT
|
||||||
#define NDB_CONSTEXPR
|
#define NDB_CONSTEXPR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NDB_CONSTEXPR T& operator[](const size_t n)NDB_NOEXCEPT{
|
NDB_CONSTEXPR T& operator[](const size_t n)NDB_NOEXCEPT{
|
||||||
// static_assert(noexcept(Array::operator[](0)), "isn't noexcept");
|
// static_assert(noexcept(Array::operator[](0)), "isn't noexcept");
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if(n>=size){
|
if(n>=size){
|
||||||
std::ostringstream err_oss;
|
std::ostringstream err_oss;
|
||||||
err_oss<<"\n[array_size]: "<<size<<"\n[Your index]: "<<n<<'\n';
|
err_oss<<"\n[array_size]: "<<size<<"\n[Your index]: "<<n<<'\n';
|
||||||
throw std::runtime_error(err_oss.str());
|
throw std::runtime_error(err_oss.str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return arr[n];
|
return arr[n];
|
||||||
}
|
}
|
||||||
struct Iterator{
|
struct Iterator{
|
||||||
constexpr Iterator(const size_t n,T *const p)noexcept:now{n},p{p}{}
|
constexpr Iterator(const size_t n,T *const p)noexcept:now{n},p{p}{}
|
||||||
bool operator!=(const Iterator &that)const noexcept{
|
bool operator!=(const Iterator &that)const noexcept{
|
||||||
return this->now!=that.now;
|
return this->now!=that.now;
|
||||||
}
|
}
|
||||||
NDB_CONSTEXPR T& operator*()const NDB_NOEXCEPT{
|
NDB_CONSTEXPR T& operator*()const NDB_NOEXCEPT{
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if(now>=size){
|
if(now>=size){
|
||||||
std::ostringstream err_oss;
|
std::ostringstream err_oss;
|
||||||
err_oss<<"[array_size]: "<<size<<" [Your index]: "<<now<<'\n';
|
err_oss<<"[array_size]: "<<size<<" [Your index]: "<<now<<'\n';
|
||||||
throw std::runtime_error(err_oss.str());
|
throw std::runtime_error(err_oss.str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return p[now];
|
return p[now];
|
||||||
}
|
}
|
||||||
constexpr Iterator& operator++()noexcept{
|
constexpr Iterator& operator++()noexcept{
|
||||||
now++;
|
now++;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
constexpr Iterator& operator--()noexcept{
|
constexpr Iterator& operator--()noexcept{
|
||||||
now--;
|
now--;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
constexpr Iterator operator--(int)noexcept{
|
constexpr Iterator operator--(int)noexcept{
|
||||||
auto old = *this;
|
auto old = *this;
|
||||||
now--;
|
now--;
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
size_t now;
|
size_t now;
|
||||||
T *const p;
|
T *const p;
|
||||||
};
|
};
|
||||||
constexpr Iterator begin()noexcept{
|
constexpr Iterator begin()noexcept{
|
||||||
return Iterator(0,arr);
|
return Iterator(0,arr);
|
||||||
}
|
}
|
||||||
constexpr Iterator end()noexcept{
|
constexpr Iterator end()noexcept{
|
||||||
return Iterator(size,arr);
|
return Iterator(size,arr);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
T arr[size];
|
T arr[size];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static const size_t max_n {(size_t)2e3+5};
|
static const size_t max_n {(size_t)2e3+5};
|
||||||
ull k, t, n, m;
|
ull k, t, n, m;
|
||||||
Array<Array<ull,max_n>,max_n> c,prefix;
|
Array<Array<ull,max_n>,max_n> c,prefix;
|
||||||
|
|
||||||
static void init(){
|
static void init(){
|
||||||
c[0][0] = c[1][0] = c[1][1] = 1;
|
c[0][0] = c[1][0] = c[1][1] = 1;
|
||||||
for(ull i {2};i<max_n;i++){
|
for(ull i {2};i<max_n;i++){
|
||||||
c[i][0]=1;
|
c[i][0]=1;
|
||||||
for(ull j{1};j<=i;j++){
|
for(ull j{1};j<=i;j++){
|
||||||
c[i][j] = (c[i-1][j-1] + c[i-1][j])%k;
|
c[i][j] = (c[i-1][j-1] + c[i-1][j])%k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(ull i = 2;i<max_n;i++){ //注意这里越界了,这是个bug示例
|
for(ull i = 2;i<max_n;i++){ //注意这里越界了,这是个bug示例
|
||||||
for(ull j{1};j<=i;j++){
|
for(ull j{1};j<=i;j++){
|
||||||
prefix[i][j] = prefix[i-1][j]+prefix[i][j-1]-prefix[i-1][j-1] + (c[i][j]==0?1:0);
|
prefix[i][j] = prefix[i-1][j]+prefix[i][j-1]-prefix[i-1][j-1] + (c[i][j]==0?1:0);
|
||||||
}
|
}
|
||||||
prefix[i][i+1] = prefix[i][i];
|
prefix[i][i+1] = prefix[i][i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NV(v)#v<<" : "<<(v)
|
#define NV(v)#v<<" : "<<(v)
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
struct ReadNumber{
|
struct ReadNumber{
|
||||||
ReadNumber& operator>>(T &num){
|
ReadNumber& operator>>(T &num){
|
||||||
c=0,w=1,n=0;
|
c=0,w=1,n=0;
|
||||||
while(!isdigit(c)){
|
while(!isdigit(c)){
|
||||||
if constexpr (!std::is_unsigned_v<T>){
|
if constexpr (!std::is_unsigned_v<T>){
|
||||||
if(c=='-')w=-1;
|
if(c=='-')w=-1;
|
||||||
}
|
}
|
||||||
c=getchar();
|
c=getchar();
|
||||||
}
|
}
|
||||||
while(isdigit(c)){
|
while(isdigit(c)){
|
||||||
n=n*10+(c-'0');
|
n=n*10+(c-'0');
|
||||||
c=getchar();
|
c=getchar();
|
||||||
}
|
}
|
||||||
num = w*n;
|
num = w*n;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
char c;
|
char c;
|
||||||
T w,n;
|
T w,n;
|
||||||
};
|
};
|
||||||
|
|
||||||
ReadNumber<ull> readull;
|
ReadNumber<ull> readull;
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
readull>>t>>k;
|
readull>>t>>k;
|
||||||
// std::cout<<NV(t)<<'\n'<<NV(k)<<'\n';
|
// std::cout<<NV(t)<<'\n'<<NV(k)<<'\n';
|
||||||
init();
|
init();
|
||||||
for(ull i {0};i<t;i++){
|
for(ull i {0};i<t;i++){
|
||||||
// std::cout<<NV(t)<<'\n'<<NV(k)<<'\n';
|
// std::cout<<NV(t)<<'\n'<<NV(k)<<'\n';
|
||||||
readull>>n>>m;
|
readull>>n>>m;
|
||||||
// std::cout<<"test\n";
|
// std::cout<<"test\n";
|
||||||
m = std::min(m,n);
|
m = std::min(m,n);
|
||||||
std::cout<<(prefix[n][m])<<'\n';
|
std::cout<<(prefix[n][m])<<'\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,88 +1,88 @@
|
|||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
#define NV(v)#v<<" : "<<(v)
|
#define NV(v)#v<<" : "<<(v)
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
#define DEBUG(code)
|
#define DEBUG(code)
|
||||||
#else
|
#else
|
||||||
#define DEBUG(code){code}
|
#define DEBUG(code){code}
|
||||||
#endif
|
#endif
|
||||||
using ull = unsigned long long;
|
using ull = unsigned long long;
|
||||||
|
|
||||||
static const size_t max_n {(size_t)2e3+5};
|
static const size_t max_n {(size_t)2e3+5};
|
||||||
// static const size_t max_n {(size_t)10};
|
// static const size_t max_n {(size_t)10};
|
||||||
static ull k, c[max_n][max_n], prefix[max_n][max_n], t, n, m;
|
static ull k, c[max_n][max_n], prefix[max_n][max_n], t, n, m;
|
||||||
|
|
||||||
static void init(){
|
static void init(){
|
||||||
c[0][0] = c[1][0] = c[1][1] = 1;
|
c[0][0] = c[1][0] = c[1][1] = 1;
|
||||||
for(ull i {2};i<max_n;i++){
|
for(ull i {2};i<max_n;i++){
|
||||||
c[i][0]=1;
|
c[i][0]=1;
|
||||||
for(ull j{1};j<=i;j++){
|
for(ull j{1};j<=i;j++){
|
||||||
c[i][j] = (c[i-1][j-1] + c[i-1][j])%k;
|
c[i][j] = (c[i-1][j-1] + c[i-1][j])%k;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DEBUG(
|
DEBUG(
|
||||||
for(ull i{0};i<max_n;i++){
|
for(ull i{0};i<max_n;i++){
|
||||||
for(ull j{0};j<=i;j++){
|
for(ull j{0};j<=i;j++){
|
||||||
std::cout<<c[i][j]<<' ';
|
std::cout<<c[i][j]<<' ';
|
||||||
}
|
}
|
||||||
std::cout<<'\n';
|
std::cout<<'\n';
|
||||||
}
|
}
|
||||||
std::cout<<"===========\n";
|
std::cout<<"===========\n";
|
||||||
)
|
)
|
||||||
|
|
||||||
for(ull i = 2;i<max_n-1;i++){ //注意这里是max_n-1
|
for(ull i = 2;i<max_n-1;i++){ //注意这里是max_n-1
|
||||||
for(ull j{1};j<=i;j++){
|
for(ull j{1};j<=i;j++){
|
||||||
prefix[i][j] = prefix[i-1][j]+prefix[i][j-1]-prefix[i-1][j-1] + (c[i][j]==0?1:0);
|
prefix[i][j] = prefix[i-1][j]+prefix[i][j-1]-prefix[i-1][j-1] + (c[i][j]==0?1:0);
|
||||||
}
|
}
|
||||||
prefix[i][i+1] = prefix[i][i];
|
prefix[i][i+1] = prefix[i][i];
|
||||||
}
|
}
|
||||||
DEBUG(
|
DEBUG(
|
||||||
for(ull i{0};i<max_n;i++){
|
for(ull i{0};i<max_n;i++){
|
||||||
for(ull j{0};j<=i;j++){
|
for(ull j{0};j<=i;j++){
|
||||||
std::cout<<prefix[i][j]<<' ';
|
std::cout<<prefix[i][j]<<' ';
|
||||||
}
|
}
|
||||||
std::cout<<'\n';
|
std::cout<<'\n';
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
struct ReadNumber{
|
struct ReadNumber{
|
||||||
ReadNumber& operator>>(T &num){
|
ReadNumber& operator>>(T &num){
|
||||||
c=0,w=1,n=0;
|
c=0,w=1,n=0;
|
||||||
while(!isdigit(c)){
|
while(!isdigit(c)){
|
||||||
if constexpr (!std::is_unsigned_v<T>){
|
if constexpr (!std::is_unsigned_v<T>){
|
||||||
if(c=='-')w=-1;
|
if(c=='-')w=-1;
|
||||||
}
|
}
|
||||||
c=getchar();
|
c=getchar();
|
||||||
}
|
}
|
||||||
while(isdigit(c)){
|
while(isdigit(c)){
|
||||||
n=n*10+(c-'0');
|
n=n*10+(c-'0');
|
||||||
c=getchar();
|
c=getchar();
|
||||||
}
|
}
|
||||||
num = w*n;
|
num = w*n;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
char c;
|
char c;
|
||||||
T w,n;
|
T w,n;
|
||||||
};
|
};
|
||||||
|
|
||||||
ReadNumber<ull> readull;
|
ReadNumber<ull> readull;
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
readull>>t>>k;
|
readull>>t>>k;
|
||||||
// std::cout<<NV(t)<<'\n'<<NV(k)<<'\n';
|
// std::cout<<NV(t)<<'\n'<<NV(k)<<'\n';
|
||||||
init();
|
init();
|
||||||
for(ull i {0};i<t;i++){
|
for(ull i {0};i<t;i++){
|
||||||
// std::cout<<NV(t)<<'\n'<<NV(k)<<'\n';
|
// std::cout<<NV(t)<<'\n'<<NV(k)<<'\n';
|
||||||
readull>>n>>m;
|
readull>>n>>m;
|
||||||
// std::cout<<"test\n";
|
// std::cout<<"test\n";
|
||||||
m = std::min(m,n);
|
m = std::min(m,n);
|
||||||
std::cout<<(prefix[n][m])<<'\n';
|
std::cout<<(prefix[n][m])<<'\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,71 +1,71 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
using std::cout,std::iostream;
|
using std::cout,std::iostream;
|
||||||
static const constexpr auto range {std::ranges::views::iota};
|
static const constexpr auto range {std::ranges::views::iota};
|
||||||
|
|
||||||
static const constexpr int MOD {80112002}, MAX_TYPES {(int)5e3+5} /*, MAX_REL_SHIPS {(int)5e5+5}*/;
|
static const constexpr int MOD {80112002}, MAX_TYPES {(int)5e3+5} /*, MAX_REL_SHIPS {(int)5e5+5}*/;
|
||||||
static int types, rel_ships, a, b, in_degree[MAX_TYPES], out_degree[MAX_TYPES], link_nums[MAX_TYPES], ans;
|
static int types, rel_ships, a, b, in_degree[MAX_TYPES], out_degree[MAX_TYPES], link_nums[MAX_TYPES], ans;
|
||||||
static std::queue<int> q;
|
static std::queue<int> q;
|
||||||
static std::vector<int> next[MAX_TYPES];
|
static std::vector<int> next[MAX_TYPES];
|
||||||
|
|
||||||
class ReadInt{
|
class ReadInt{
|
||||||
char c;
|
char c;
|
||||||
int w,n;
|
int w,n;
|
||||||
public:
|
public:
|
||||||
ReadInt &operator>>(int &num){
|
ReadInt &operator>>(int &num){
|
||||||
c=0,w=1,n=0;
|
c=0,w=1,n=0;
|
||||||
while(!isdigit(c)){
|
while(!isdigit(c)){
|
||||||
if(c=='-')w=-1;
|
if(c=='-')w=-1;
|
||||||
c = (char)getchar();
|
c = (char)getchar();
|
||||||
}
|
}
|
||||||
while(isdigit(c)){
|
while(isdigit(c)){
|
||||||
n=n*10+(c-'0');
|
n=n*10+(c-'0');
|
||||||
c = (char)getchar();
|
c = (char)getchar();
|
||||||
}
|
}
|
||||||
num = n*w;
|
num = n*w;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static ReadInt readint;
|
static ReadInt readint;
|
||||||
|
|
||||||
#define cin readint
|
#define cin readint
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
cin>>types>>rel_ships;
|
cin>>types>>rel_ships;
|
||||||
for([[maybe_unused]] const int _:range(1,rel_ships+1)){
|
for([[maybe_unused]] const int _:range(1,rel_ships+1)){
|
||||||
cin>>a>>b;
|
cin>>a>>b;
|
||||||
next[a].push_back(b);
|
next[a].push_back(b);
|
||||||
in_degree[b]++;
|
in_degree[b]++;
|
||||||
out_degree[a]++;
|
out_degree[a]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(const int i:range(1, types+1)){
|
for(const int i:range(1, types+1)){
|
||||||
if(in_degree[i]==0){
|
if(in_degree[i]==0){
|
||||||
q.push(i);
|
q.push(i);
|
||||||
link_nums[i] = 1;
|
link_nums[i] = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while(!q.empty()){
|
while(!q.empty()){
|
||||||
auto front {q.front()};
|
auto front {q.front()};
|
||||||
q.pop();
|
q.pop();
|
||||||
for(auto i:next[front]){
|
for(auto i:next[front]){
|
||||||
link_nums[i] = (link_nums[i] + link_nums[front])%MOD;
|
link_nums[i] = (link_nums[i] + link_nums[front])%MOD;
|
||||||
if(--in_degree[i]==0){
|
if(--in_degree[i]==0){
|
||||||
q.push(i);
|
q.push(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(auto i:range(1,types+1)){
|
for(auto i:range(1,types+1)){
|
||||||
if(out_degree[i]==0){
|
if(out_degree[i]==0){
|
||||||
ans = (ans + link_nums[i]) % MOD;
|
ans = (ans + link_nums[i]) % MOD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cout<<ans<<"\n";
|
cout<<ans<<"\n";
|
||||||
}
|
}
|
@ -1,5 +1,5 @@
|
|||||||
#include<iostream>
|
#include<iostream>
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
|
|
||||||
}
|
}
|
@ -1,65 +1,65 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
using ull = unsigned long long;
|
using ull = unsigned long long;
|
||||||
using std::cout,std::iostream,std::bitset;
|
using std::cout,std::iostream,std::bitset;
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
class ReadNumber{
|
class ReadNumber{
|
||||||
char c;
|
char c;
|
||||||
T w,n;
|
T w,n;
|
||||||
public:
|
public:
|
||||||
ReadNumber& operator>>(T &num)noexcept{
|
ReadNumber& operator>>(T &num)noexcept{
|
||||||
c=(char)0,w=1,n=0;
|
c=(char)0,w=1,n=0;
|
||||||
while(!isdigit(c)){
|
while(!isdigit(c)){
|
||||||
if constexpr(!std::is_same_v<ull, T>){
|
if constexpr(!std::is_same_v<ull, T>){
|
||||||
if(c=='-')w=-1;
|
if(c=='-')w=-1;
|
||||||
}
|
}
|
||||||
c = getchar();
|
c = getchar();
|
||||||
}
|
}
|
||||||
while(isdigit(c)){
|
while(isdigit(c)){
|
||||||
n = n*10 + (c-'0');
|
n = n*10 + (c-'0');
|
||||||
c = getchar();
|
c = getchar();
|
||||||
}
|
}
|
||||||
num = w*n;
|
num = w*n;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ull n, m, c, k, num, input, p, ans {1}, _;
|
ull n, m, c, k, num, input, p, ans {1}, _;
|
||||||
bitset<64+5> bt;
|
bitset<64+5> bt;
|
||||||
|
|
||||||
ReadNumber<ull> readull;
|
ReadNumber<ull> readull;
|
||||||
#define cin readull
|
#define cin readull
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
constexpr T safe_left_shift(const T t,const size_t n)noexcept{
|
constexpr T safe_left_shift(const T t,const size_t n)noexcept{
|
||||||
constexpr auto sizeof_t = sizeof(t)*8;
|
constexpr auto sizeof_t = sizeof(t)*8;
|
||||||
return (n>=sizeof_t?0:t<<n);
|
return (n>=sizeof_t?0:t<<n);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
cin>>n>>m>>c>>k;
|
cin>>n>>m>>c>>k;
|
||||||
|
|
||||||
if(n==0 && m==0 && k==64){ //特判
|
if(n==0 && m==0 && k==64){ //特判
|
||||||
cout<<"18446744073709551616\n";
|
cout<<"18446744073709551616\n";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(ull i=0;i<n;i++){
|
for(ull i=0;i<n;i++){
|
||||||
cin>>input;
|
cin>>input;
|
||||||
num |= input; //所有编号占用的'1'的位置,把他并在一起
|
num |= input; //所有编号占用的'1'的位置,把他并在一起
|
||||||
}
|
}
|
||||||
for(ull i=0;i<m;i++){
|
for(ull i=0;i<m;i++){
|
||||||
cin>>p>>_;
|
cin>>p>>_;
|
||||||
if(!((num>>p)&1) && !bt[p]){ //已有的n个编号里面没有出现过的规则,并且还未标记,bt用来去重
|
if(!((num>>p)&1) && !bt[p]){ //已有的n个编号里面没有出现过的规则,并且还未标记,bt用来去重
|
||||||
k--;
|
k--;
|
||||||
bt[p]=true;
|
bt[p]=true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for(int i=0;i<k;i++)ans*=2; //此时ans=所有(未排除n个已用规则),可以用的二进制位的组合
|
// for(int i=0;i<k;i++)ans*=2; //此时ans=所有(未排除n个已用规则),可以用的二进制位的组合
|
||||||
ans = safe_left_shift(1ull, k); // 避开未定义行为
|
ans = safe_left_shift(1ull, k); // 避开未定义行为
|
||||||
cout<<ans-n<<'\n';//注意这里要去重,基本排列组合原理
|
cout<<ans-n<<'\n';//注意这里要去重,基本排列组合原理
|
||||||
}
|
}
|
@ -1,44 +1,44 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
using ull = unsigned long long;
|
using ull = unsigned long long;
|
||||||
|
|
||||||
auto &is = std::cin;
|
auto &is = std::cin;
|
||||||
auto &os = std::cout;
|
auto &os = std::cout;
|
||||||
|
|
||||||
ull n, a, b, depth;
|
ull n, a, b, depth;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
cal(a,b)
|
cal(a,b)
|
||||||
1)a==b return 0;
|
1)a==b return 0;
|
||||||
2)a>b && a is odd return cal(a+1,b)+1;
|
2)a>b && a is odd return cal(a+1,b)+1;
|
||||||
3)a>b && a is even return cal(a/2,b)+1;
|
3)a>b && a is even return cal(a/2,b)+1;
|
||||||
4)a>b/2 && a<b return b-a;
|
4)a>b/2 && a<b return b-a;
|
||||||
5)a<b/2 && b is odd return cal(a,b/2)+1;
|
5)a<b/2 && b is odd return cal(a,b/2)+1;
|
||||||
6)a<b/2 && b is even return cal(a,b-1)+1;
|
6)a<b/2 && b is even return cal(a,b-1)+1;
|
||||||
*/
|
*/
|
||||||
ull cal(const ull a,const ull b)noexcept{
|
ull cal(const ull a,const ull b)noexcept{
|
||||||
if(a==b){
|
if(a==b){
|
||||||
return 0;
|
return 0;
|
||||||
}else if(a>b){
|
}else if(a>b){
|
||||||
if(a&1)return cal(a+1,b)+1;
|
if(a&1)return cal(a+1,b)+1;
|
||||||
else return cal(a/2,b)+1;
|
else return cal(a/2,b)+1;
|
||||||
}else if(a>b/2){
|
}else if(a>b/2){
|
||||||
const auto ans = b-a;
|
const auto ans = b-a;
|
||||||
if(b&1)return std::min(ans,cal(a,b-1)+1);
|
if(b&1)return std::min(ans,cal(a,b-1)+1);
|
||||||
else return std::min(ans,cal(a,b/2)+1);
|
else return std::min(ans,cal(a,b/2)+1);
|
||||||
}else if(a<=b/2){
|
}else if(a<=b/2){
|
||||||
if(b&1)return cal(a,b-1)+1;
|
if(b&1)return cal(a,b-1)+1;
|
||||||
else return cal(a,b/2)+1;
|
else return cal(a,b/2)+1;
|
||||||
}
|
}
|
||||||
throw std::runtime_error("cannot calculate");
|
throw std::runtime_error("cannot calculate");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
is>>n;
|
is>>n;
|
||||||
for(ull i {0};i<n;i++){
|
for(ull i {0};i<n;i++){
|
||||||
is>>a>>b;
|
is>>a>>b;
|
||||||
os<<cal(a,b)<<'\n';
|
os<<cal(a,b)<<'\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,25 +1,25 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
|
||||||
using std::cin, std::cout, std::string;
|
using std::cin, std::cout, std::string;
|
||||||
using ull = unsigned long long;
|
using ull = unsigned long long;
|
||||||
constexpr auto range = std::ranges::views::iota;
|
constexpr auto range = std::ranges::views::iota;
|
||||||
|
|
||||||
constexpr size_t MAX_N{(size_t)3e5 + 5}, MOD{998244353};
|
constexpr size_t MAX_N{(size_t)3e5 + 5}, MOD{998244353};
|
||||||
string s;
|
string s;
|
||||||
ull stk[MAX_N], left_num[MAX_N], dp[MAX_N], ans;
|
ull stk[MAX_N], left_num[MAX_N], dp[MAX_N], ans;
|
||||||
size_t stk_size;
|
size_t stk_size;
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
cin >> s;
|
cin >> s;
|
||||||
for (const size_t i : range((size_t)0, s.size())) {
|
for (const size_t i : range((size_t)0, s.size())) {
|
||||||
if (s[i] == '(') {
|
if (s[i] == '(') {
|
||||||
stk[stk_size++] = i + 1;
|
stk[stk_size++] = i + 1;
|
||||||
} else if (stk_size > 0) {
|
} else if (stk_size > 0) {
|
||||||
left_num[i] = stk[--stk_size];
|
left_num[i] = stk[--stk_size];
|
||||||
dp[i] = (dp[left_num[i] - 2] + left_num[i]) % MOD;
|
dp[i] = (dp[left_num[i] - 2] + left_num[i]) % MOD;
|
||||||
ans = (ans + dp[i] * (s.size() - i)) % MOD;
|
ans = (ans + dp[i] * (s.size() - i)) % MOD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cout << ans << '\n';
|
cout << ans << '\n';
|
||||||
}
|
}
|
@ -1,77 +1,77 @@
|
|||||||
# 括号序列问题1
|
# 括号序列问题1
|
||||||
|
|
||||||
## 题目描述
|
## 题目描述
|
||||||
|
|
||||||
给一个长度为 $n$ 的括号串 $s$,其中连续的一段 $s[l...r]$ 称为 $s$ 的子串。
|
给一个长度为 $n$ 的括号串 $s$,其中连续的一段 $s[l...r]$ 称为 $s$ 的子串。
|
||||||
|
|
||||||
合法串的定义如下:
|
合法串的定义如下:
|
||||||
|
|
||||||
1. `()` 是合法括号串。
|
1. `()` 是合法括号串。
|
||||||
2. 如果 `A` 是合法括号串,则 `(A)` 是合法括号串。
|
2. 如果 `A` 是合法括号串,则 `(A)` 是合法括号串。
|
||||||
3. 如果 `A`,`B` 是合法括号串,则 `AB` 是合法括号串。
|
3. 如果 `A`,`B` 是合法括号串,则 `AB` 是合法括号串。
|
||||||
|
|
||||||
对于串 $t$,其所有子串中合法串的数量记为 $f(t)$
|
对于串 $t$,其所有子串中合法串的数量记为 $f(t)$
|
||||||
|
|
||||||
求 $s$ 串所有子串的 $f$ 值之和,即 $\sum_{l\le r}f(s[l...r])$,模 998244353。
|
求 $s$ 串所有子串的 $f$ 值之和,即 $\sum_{l\le r}f(s[l...r])$,模 998244353。
|
||||||
|
|
||||||
## 输入格式
|
## 输入格式
|
||||||
|
|
||||||
一个字符串 $s$
|
一个字符串 $s$
|
||||||
|
|
||||||
## 输出格式
|
## 输出格式
|
||||||
|
|
||||||
输出一个整数代表答案
|
输出一个整数代表答案
|
||||||
|
|
||||||
## 样例 #1
|
## 样例 #1
|
||||||
|
|
||||||
### 样例输入 #1
|
### 样例输入 #1
|
||||||
|
|
||||||
```
|
```
|
||||||
())
|
())
|
||||||
```
|
```
|
||||||
|
|
||||||
### 样例输出 #1
|
### 样例输出 #1
|
||||||
|
|
||||||
```
|
```
|
||||||
2
|
2
|
||||||
```
|
```
|
||||||
|
|
||||||
## 样例 #2
|
## 样例 #2
|
||||||
|
|
||||||
### 样例输入 #2
|
### 样例输入 #2
|
||||||
|
|
||||||
```
|
```
|
||||||
(()()
|
(()()
|
||||||
```
|
```
|
||||||
|
|
||||||
### 样例输出 #2
|
### 样例输出 #2
|
||||||
|
|
||||||
```
|
```
|
||||||
12
|
12
|
||||||
```
|
```
|
||||||
|
|
||||||
## 样例 #3
|
## 样例 #3
|
||||||
|
|
||||||
### 样例输入 #3
|
### 样例输入 #3
|
||||||
|
|
||||||
```
|
```
|
||||||
)(()())()
|
)(()())()
|
||||||
```
|
```
|
||||||
|
|
||||||
### 样例输出 #3
|
### 样例输出 #3
|
||||||
|
|
||||||
```
|
```
|
||||||
66
|
66
|
||||||
```
|
```
|
||||||
|
|
||||||
## 提示
|
## 提示
|
||||||
|
|
||||||
设 $n$ 为输入串长度:
|
设 $n$ 为输入串长度:
|
||||||
|
|
||||||
子任务1(20分):$1\le n\le 100$
|
子任务1(20分):$1\le n\le 100$
|
||||||
|
|
||||||
子任务2(20分):$1\le n\le 700$
|
子任务2(20分):$1\le n\le 700$
|
||||||
|
|
||||||
子任务3(20分):$1\le n\le 5000$
|
子任务3(20分):$1\le n\le 5000$
|
||||||
|
|
||||||
子任务4(40分):$1\le n\le 300000$
|
子任务4(40分):$1\le n\le 300000$
|
@ -1,45 +1,45 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
using std::cin, std::cout, std::string, std::stack, std::array;
|
using std::cin, std::cout, std::string, std::stack, std::array;
|
||||||
|
|
||||||
constexpr size_t MOD {998244353}, MAX_N {(size_t)3e5+5};
|
constexpr size_t MOD {998244353}, MAX_N {(size_t)3e5+5};
|
||||||
string s;
|
string s;
|
||||||
stack<size_t> st;
|
stack<size_t> st;
|
||||||
unsigned int prefix[MAX_N], ans, sum, left_num;
|
unsigned int prefix[MAX_N], ans, sum, left_num;
|
||||||
constexpr size_t char_size {1<<(sizeof(char)*8)};
|
constexpr size_t char_size {1<<(sizeof(char)*8)};
|
||||||
constexpr array<int,char_size> install_array(){
|
constexpr array<int,char_size> install_array(){
|
||||||
array<int,char_size> ret{};
|
array<int,char_size> ret{};
|
||||||
ret[40]=1;
|
ret[40]=1;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
constexpr array<int,char_size> map = install_array();
|
constexpr array<int,char_size> map = install_array();
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
cin>>s;
|
cin>>s;
|
||||||
for(size_t i {0};i<s.size();i++){
|
for(size_t i {0};i<s.size();i++){
|
||||||
for(size_t j {i+1};j<=s.size();j++){
|
for(size_t j {i+1};j<=s.size();j++){
|
||||||
for(size_t k{i};k<j;k++){
|
for(size_t k{i};k<j;k++){
|
||||||
for(size_t l{k+1};l<=j;l++){
|
for(size_t l{k+1};l<=j;l++){
|
||||||
left_num = 0;
|
left_num = 0;
|
||||||
for(size_t m{k};m<l;m++){
|
for(size_t m{k};m<l;m++){
|
||||||
left_num+=map[s[m]];
|
left_num+=map[s[m]];
|
||||||
if(s[m]==')'){
|
if(s[m]==')'){
|
||||||
if(left_num<=0){
|
if(left_num<=0){
|
||||||
goto failed;
|
goto failed;
|
||||||
}
|
}
|
||||||
left_num--;
|
left_num--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(left_num==0){
|
if(left_num==0){
|
||||||
ans=(ans+1)%MOD;
|
ans=(ans+1)%MOD;
|
||||||
}
|
}
|
||||||
failed:;
|
failed:;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cout<<ans<<'\n';
|
cout<<ans<<'\n';
|
||||||
}
|
}
|
@ -1,104 +1,104 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
using std::cin, std::cout, std::string;
|
using std::cin, std::cout, std::string;
|
||||||
typedef unsigned long long ull;
|
typedef unsigned long long ull;
|
||||||
|
|
||||||
template<class T,size_t size>
|
template<class T,size_t size>
|
||||||
struct Array{
|
struct Array{
|
||||||
constexpr Array(){};
|
constexpr Array(){};
|
||||||
constexpr Array(const std::initializer_list<T> list){
|
constexpr Array(const std::initializer_list<T> list){
|
||||||
std::copy(list.begin(),list.end(),arr);
|
std::copy(list.begin(),list.end(),arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
#define NDB_NOEXCEPT noexcept
|
#define NDB_NOEXCEPT noexcept
|
||||||
#define NDB_CONSTEXPR constexpr
|
#define NDB_CONSTEXPR constexpr
|
||||||
#else
|
#else
|
||||||
#define NDB_NOEXCEPT
|
#define NDB_NOEXCEPT
|
||||||
#define NDB_CONSTEXPR
|
#define NDB_CONSTEXPR
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
NDB_CONSTEXPR T& operator[](const size_t n)NDB_NOEXCEPT{
|
NDB_CONSTEXPR T& operator[](const size_t n)NDB_NOEXCEPT{
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if(n>=size){
|
if(n>=size){
|
||||||
std::ostringstream err_oss;
|
std::ostringstream err_oss;
|
||||||
err_oss<<"\n[array_size]: "<<size<<"\n[Your index]: "<<n<<'\n';
|
err_oss<<"\n[array_size]: "<<size<<"\n[Your index]: "<<n<<'\n';
|
||||||
throw std::runtime_error(err_oss.str());
|
throw std::runtime_error(err_oss.str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return arr[n];
|
return arr[n];
|
||||||
}
|
}
|
||||||
struct Iterator{
|
struct Iterator{
|
||||||
constexpr Iterator(const size_t n,T *const p)noexcept:now{n},p{p}{}
|
constexpr Iterator(const size_t n,T *const p)noexcept:now{n},p{p}{}
|
||||||
bool operator!=(const Iterator &that)const noexcept{
|
bool operator!=(const Iterator &that)const noexcept{
|
||||||
return this->now!=that.now;
|
return this->now!=that.now;
|
||||||
}
|
}
|
||||||
NDB_CONSTEXPR T& operator*()const NDB_NOEXCEPT{
|
NDB_CONSTEXPR T& operator*()const NDB_NOEXCEPT{
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if(now>=size){
|
if(now>=size){
|
||||||
std::ostringstream err_oss;
|
std::ostringstream err_oss;
|
||||||
err_oss<<"[array_size]: "<<size<<" [Your index]: "<<now<<'\n';
|
err_oss<<"[array_size]: "<<size<<" [Your index]: "<<now<<'\n';
|
||||||
throw std::runtime_error(err_oss.str());
|
throw std::runtime_error(err_oss.str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return p[now];
|
return p[now];
|
||||||
}
|
}
|
||||||
constexpr Iterator& operator++()noexcept{
|
constexpr Iterator& operator++()noexcept{
|
||||||
now++;
|
now++;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
constexpr Iterator& operator--()noexcept{
|
constexpr Iterator& operator--()noexcept{
|
||||||
now--;
|
now--;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
constexpr Iterator operator--(int)noexcept{
|
constexpr Iterator operator--(int)noexcept{
|
||||||
auto old = *this;
|
auto old = *this;
|
||||||
now--;
|
now--;
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
size_t now;
|
size_t now;
|
||||||
T *const p;
|
T *const p;
|
||||||
};
|
};
|
||||||
constexpr Iterator begin()noexcept{
|
constexpr Iterator begin()noexcept{
|
||||||
return Iterator(0,arr);
|
return Iterator(0,arr);
|
||||||
}
|
}
|
||||||
constexpr Iterator end()noexcept{
|
constexpr Iterator end()noexcept{
|
||||||
return Iterator(size,arr);
|
return Iterator(size,arr);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
T arr[size];
|
T arr[size];
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class T,class ...Args>
|
template<class T,class ...Args>
|
||||||
constexpr static Array<T,sizeof...(Args)> make_array(Args&&...args){
|
constexpr static Array<T,sizeof...(Args)> make_array(Args&&...args){
|
||||||
Array<T,sizeof...(Args)> arr;
|
Array<T,sizeof...(Args)> arr;
|
||||||
size_t index {0};
|
size_t index {0};
|
||||||
((arr[index++]=args),...);
|
((arr[index++]=args),...);
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const size_t MOD {998244353}, MAX_N {300000+5};
|
static const size_t MOD {998244353}, MAX_N {300000+5};
|
||||||
static string s;
|
static string s;
|
||||||
static size_t unused_left_num, ans;
|
static size_t unused_left_num, ans;
|
||||||
static Array<size_t,MAX_N> left_dp, last_left;
|
static Array<size_t,MAX_N> left_dp, last_left;
|
||||||
static Array<ull,MAX_N> stk;
|
static Array<ull,MAX_N> stk;
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
cin>>s;
|
cin>>s;
|
||||||
for(size_t i {1};i<=s.size();i++){
|
for(size_t i {1};i<=s.size();i++){
|
||||||
if(s[i-1]=='('){
|
if(s[i-1]=='('){
|
||||||
stk[unused_left_num++]=i;
|
stk[unused_left_num++]=i;
|
||||||
}else if(unused_left_num>0){
|
}else if(unused_left_num>0){
|
||||||
last_left[i] = stk[--unused_left_num];
|
last_left[i] = stk[--unused_left_num];
|
||||||
left_dp[i] = (left_dp[last_left[i]-1] + last_left[i]) % MOD;
|
left_dp[i] = (left_dp[last_left[i]-1] + last_left[i]) % MOD;
|
||||||
ans = (ans + left_dp[i] * (s.size() - i+1)) % MOD ;
|
ans = (ans + left_dp[i] * (s.size() - i+1)) % MOD ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cout<<ans<<'\n';
|
cout<<ans<<'\n';
|
||||||
}
|
}
|
@ -1,24 +1,24 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
using std::cin, std::cout, std::string;
|
using std::cin, std::cout, std::string;
|
||||||
using ull = unsigned long long;
|
using ull = unsigned long long;
|
||||||
|
|
||||||
constexpr size_t MAX_N {(size_t)3e5+5}, MOD {998244353};
|
constexpr size_t MAX_N {(size_t)3e5+5}, MOD {998244353};
|
||||||
string s;
|
string s;
|
||||||
ull left_ok[MAX_N], stk[MAX_N], stk_size, left_index[MAX_N], ans;
|
ull left_ok[MAX_N], stk[MAX_N], stk_size, left_index[MAX_N], ans;
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
cin>>s;
|
cin>>s;
|
||||||
|
|
||||||
for(size_t i {1};i<=s.size();i++){
|
for(size_t i {1};i<=s.size();i++){
|
||||||
if(s[i-1]=='('){
|
if(s[i-1]=='('){
|
||||||
stk[stk_size++] = i;
|
stk[stk_size++] = i;
|
||||||
}else if(stk_size>0){
|
}else if(stk_size>0){
|
||||||
left_index[i] = stk[--stk_size];
|
left_index[i] = stk[--stk_size];
|
||||||
left_ok[i] = (left_ok[left_index[i]-1] + left_index[i]) % MOD;
|
left_ok[i] = (left_ok[left_index[i]-1] + left_index[i]) % MOD;
|
||||||
ans = ( ans + left_ok[i] * (s.size() - i + 1)) % MOD;
|
ans = ( ans + left_ok[i] * (s.size() - i + 1)) % MOD;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cout<<ans<<'\n';
|
cout<<ans<<'\n';
|
||||||
}
|
}
|
@ -1,59 +1,59 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
using std::cin, std::cout, std::string, std::vector, std::iostream;
|
using std::cin, std::cout, std::string, std::vector, std::iostream;
|
||||||
constexpr auto range = std::ranges::views::iota;
|
constexpr auto range = std::ranges::views::iota;
|
||||||
|
|
||||||
size_t n;
|
size_t n;
|
||||||
string s;
|
string s;
|
||||||
int a_num, b_num;
|
int a_num, b_num;
|
||||||
char max_char, min_char;
|
char max_char, min_char;
|
||||||
|
|
||||||
struct Ope{
|
struct Ope{
|
||||||
const size_t start,end;
|
const size_t start,end;
|
||||||
const char c;
|
const char c;
|
||||||
};
|
};
|
||||||
vector<Ope> v;
|
vector<Ope> v;
|
||||||
|
|
||||||
void print()noexcept{
|
void print()noexcept{
|
||||||
cout<<v.size()<<'\n';
|
cout<<v.size()<<'\n';
|
||||||
for(auto &i:v){
|
for(auto &i:v){
|
||||||
cout<<i.start+1<<' '<<i.end+1<<' '<<i.c<<'\n';
|
cout<<i.start+1<<' '<<i.end+1<<' '<<i.c<<'\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
iostream::sync_with_stdio(false), cin.tie(0), cout.tie(0);
|
iostream::sync_with_stdio(false), cin.tie(0), cout.tie(0);
|
||||||
cin>>n;
|
cin>>n;
|
||||||
cin>>s;
|
cin>>s;
|
||||||
for(const int i:range((size_t)0,n)){
|
for(const int i:range((size_t)0,n)){
|
||||||
if(s[i]=='A') {
|
if(s[i]=='A') {
|
||||||
a_num++;
|
a_num++;
|
||||||
}else if(s[i]=='B'){
|
}else if(s[i]=='B'){
|
||||||
b_num++;
|
b_num++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(a_num>=b_num){
|
if(a_num>=b_num){
|
||||||
max_char = 'A';
|
max_char = 'A';
|
||||||
min_char = 'B';
|
min_char = 'B';
|
||||||
}else{
|
}else{
|
||||||
max_char = 'B';
|
max_char = 'B';
|
||||||
min_char = 'A';
|
min_char = 'A';
|
||||||
}
|
}
|
||||||
v.push_back({0,(size_t)n-1,max_char});
|
v.push_back({0,(size_t)n-1,max_char});
|
||||||
for(size_t i=0;i<n;i++){
|
for(size_t i=0;i<n;i++){
|
||||||
if(s[i]==min_char){
|
if(s[i]==min_char){
|
||||||
size_t end {i};
|
size_t end {i};
|
||||||
for(size_t j=i+1;j<n;j++){
|
for(size_t j=i+1;j<n;j++){
|
||||||
if(s[j]!=min_char)break;
|
if(s[j]!=min_char)break;
|
||||||
end=j;
|
end=j;
|
||||||
}
|
}
|
||||||
v.push_back({i,end,min_char});
|
v.push_back({i,end,min_char});
|
||||||
i=end+1;
|
i=end+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print();
|
print();
|
||||||
}
|
}
|
@ -1,2 +1,2 @@
|
|||||||
1
|
1
|
||||||
1 4 A
|
1 4 A
|
@ -1,2 +1,2 @@
|
|||||||
4
|
4
|
||||||
AAAA
|
AAAA
|
@ -1,5 +1,5 @@
|
|||||||
4
|
4
|
||||||
1 6 B
|
1 6 B
|
||||||
3 5 C
|
3 5 C
|
||||||
4 4 A
|
4 4 A
|
||||||
1 1 A
|
1 1 A
|
@ -1,2 +1,2 @@
|
|||||||
6
|
6
|
||||||
ABCACB
|
ABCACB
|
@ -1,27 +1,27 @@
|
|||||||
26
|
26
|
||||||
1 50 B
|
1 50 B
|
||||||
49 49 A
|
49 49 A
|
||||||
47 47 A
|
47 47 A
|
||||||
45 45 A
|
45 45 A
|
||||||
43 43 A
|
43 43 A
|
||||||
41 41 A
|
41 41 A
|
||||||
39 39 A
|
39 39 A
|
||||||
37 37 A
|
37 37 A
|
||||||
35 35 A
|
35 35 A
|
||||||
33 33 A
|
33 33 A
|
||||||
31 31 A
|
31 31 A
|
||||||
29 29 A
|
29 29 A
|
||||||
27 27 A
|
27 27 A
|
||||||
25 25 A
|
25 25 A
|
||||||
23 23 A
|
23 23 A
|
||||||
21 21 A
|
21 21 A
|
||||||
19 19 A
|
19 19 A
|
||||||
17 17 A
|
17 17 A
|
||||||
15 15 A
|
15 15 A
|
||||||
13 13 A
|
13 13 A
|
||||||
11 11 A
|
11 11 A
|
||||||
9 9 A
|
9 9 A
|
||||||
7 7 A
|
7 7 A
|
||||||
5 5 A
|
5 5 A
|
||||||
3 3 A
|
3 3 A
|
||||||
1 1 A
|
1 1 A
|
@ -1,2 +1,2 @@
|
|||||||
50
|
50
|
||||||
ABABABABABABABABABABABABABABABABABABABABABABABABAB
|
ABABABABABABABABABABABABABABABABABABABABABABABABAB
|
@ -1,356 +1,356 @@
|
|||||||
355
|
355
|
||||||
1 692 B
|
1 692 B
|
||||||
691 691 E
|
691 691 E
|
||||||
14 689 D
|
14 689 D
|
||||||
688 688 G
|
688 688 G
|
||||||
686 687 F
|
686 687 F
|
||||||
685 685 A
|
685 685 A
|
||||||
399 682 G
|
399 682 G
|
||||||
400 681 A
|
400 681 A
|
||||||
404 680 C
|
404 680 C
|
||||||
679 679 D
|
679 679 D
|
||||||
405 678 F
|
405 678 F
|
||||||
677 677 G
|
677 677 G
|
||||||
406 676 B
|
406 676 B
|
||||||
675 675 C
|
675 675 C
|
||||||
672 672 C
|
672 672 C
|
||||||
407 671 E
|
407 671 E
|
||||||
670 670 D
|
670 670 D
|
||||||
668 668 F
|
668 668 F
|
||||||
415 666 D
|
415 666 D
|
||||||
416 665 G
|
416 665 G
|
||||||
418 664 B
|
418 664 B
|
||||||
420 663 A
|
420 663 A
|
||||||
423 661 D
|
423 661 D
|
||||||
660 660 C
|
660 660 C
|
||||||
424 659 E
|
424 659 E
|
||||||
425 658 F
|
425 658 F
|
||||||
657 657 G
|
657 657 G
|
||||||
446 654 A
|
446 654 A
|
||||||
447 653 C
|
447 653 C
|
||||||
464 652 E
|
464 652 E
|
||||||
651 651 F
|
651 651 F
|
||||||
528 648 D
|
528 648 D
|
||||||
619 647 F
|
619 647 F
|
||||||
635 646 A
|
635 646 A
|
||||||
637 645 D
|
637 645 D
|
||||||
638 644 C
|
638 644 C
|
||||||
639 643 A
|
639 643 A
|
||||||
640 642 F
|
640 642 F
|
||||||
641 641 D
|
641 641 D
|
||||||
636 636 E
|
636 636 E
|
||||||
625 634 B
|
625 634 B
|
||||||
633 633 D
|
633 633 D
|
||||||
627 632 G
|
627 632 G
|
||||||
629 631 A
|
629 631 A
|
||||||
623 623 B
|
623 623 B
|
||||||
620 620 E
|
620 620 E
|
||||||
577 617 C
|
577 617 C
|
||||||
581 616 F
|
581 616 F
|
||||||
582 615 G
|
582 615 G
|
||||||
585 614 B
|
585 614 B
|
||||||
592 613 D
|
592 613 D
|
||||||
612 612 A
|
612 612 A
|
||||||
596 611 C
|
596 611 C
|
||||||
597 610 E
|
597 610 E
|
||||||
598 609 D
|
598 609 D
|
||||||
600 608 A
|
600 608 A
|
||||||
605 607 G
|
605 607 G
|
||||||
606 606 E
|
606 606 E
|
||||||
604 604 B
|
604 604 B
|
||||||
603 603 C
|
603 603 C
|
||||||
602 602 F
|
602 602 F
|
||||||
594 594 E
|
594 594 E
|
||||||
593 593 C
|
593 593 C
|
||||||
591 591 A
|
591 591 A
|
||||||
587 590 E
|
587 590 E
|
||||||
589 589 G
|
589 589 G
|
||||||
584 584 A
|
584 584 A
|
||||||
578 579 A
|
578 579 A
|
||||||
575 575 A
|
575 575 A
|
||||||
531 573 G
|
531 573 G
|
||||||
535 571 E
|
535 571 E
|
||||||
570 570 D
|
570 570 D
|
||||||
537 568 B
|
537 568 B
|
||||||
563 567 C
|
563 567 C
|
||||||
564 566 A
|
564 566 A
|
||||||
547 560 G
|
547 560 G
|
||||||
550 559 C
|
550 559 C
|
||||||
558 558 D
|
558 558 D
|
||||||
556 557 A
|
556 557 A
|
||||||
554 554 E
|
554 554 E
|
||||||
551 553 D
|
551 553 D
|
||||||
552 552 B
|
552 552 B
|
||||||
549 549 E
|
549 549 E
|
||||||
545 545 F
|
545 545 F
|
||||||
543 543 G
|
543 543 G
|
||||||
539 542 A
|
539 542 A
|
||||||
541 541 F
|
541 541 F
|
||||||
540 540 C
|
540 540 C
|
||||||
536 536 F
|
536 536 F
|
||||||
529 529 F
|
529 529 F
|
||||||
526 526 B
|
526 526 B
|
||||||
466 524 A
|
466 524 A
|
||||||
494 522 G
|
494 522 G
|
||||||
495 521 E
|
495 521 E
|
||||||
520 520 B
|
520 520 B
|
||||||
498 518 B
|
498 518 B
|
||||||
512 517 D
|
512 517 D
|
||||||
516 516 F
|
516 516 F
|
||||||
515 515 E
|
515 515 E
|
||||||
513 513 C
|
513 513 C
|
||||||
511 511 G
|
511 511 G
|
||||||
509 509 F
|
509 509 F
|
||||||
499 507 F
|
499 507 F
|
||||||
503 506 D
|
503 506 D
|
||||||
505 505 C
|
505 505 C
|
||||||
504 504 B
|
504 504 B
|
||||||
502 502 G
|
502 502 G
|
||||||
497 497 C
|
497 497 C
|
||||||
468 491 B
|
468 491 B
|
||||||
472 490 F
|
472 490 F
|
||||||
488 488 A
|
488 488 A
|
||||||
479 487 D
|
479 487 D
|
||||||
480 486 G
|
480 486 G
|
||||||
482 485 B
|
482 485 B
|
||||||
483 483 C
|
483 483 C
|
||||||
481 481 E
|
481 481 E
|
||||||
474 477 C
|
474 477 C
|
||||||
476 476 G
|
476 476 G
|
||||||
473 473 G
|
473 473 G
|
||||||
471 471 C
|
471 471 C
|
||||||
469 470 G
|
469 470 G
|
||||||
467 467 D
|
467 467 D
|
||||||
465 465 F
|
465 465 F
|
||||||
462 462 B
|
462 462 B
|
||||||
450 460 B
|
450 460 B
|
||||||
458 458 D
|
458 458 D
|
||||||
452 456 G
|
452 456 G
|
||||||
454 454 F
|
454 454 F
|
||||||
453 453 C
|
453 453 C
|
||||||
448 448 G
|
448 448 G
|
||||||
426 444 C
|
426 444 C
|
||||||
439 441 D
|
439 441 D
|
||||||
434 437 G
|
434 437 G
|
||||||
436 436 A
|
436 436 A
|
||||||
435 435 F
|
435 435 F
|
||||||
427 432 A
|
427 432 A
|
||||||
431 431 E
|
431 431 E
|
||||||
428 430 B
|
428 430 B
|
||||||
429 429 C
|
429 429 C
|
||||||
421 421 F
|
421 421 F
|
||||||
419 419 E
|
419 419 E
|
||||||
414 414 A
|
414 414 A
|
||||||
409 412 F
|
409 412 F
|
||||||
411 411 C
|
411 411 C
|
||||||
410 410 A
|
410 410 A
|
||||||
403 403 E
|
403 403 E
|
||||||
401 401 C
|
401 401 C
|
||||||
398 398 F
|
398 398 F
|
||||||
18 396 C
|
18 396 C
|
||||||
26 394 E
|
26 394 E
|
||||||
27 393 G
|
27 393 G
|
||||||
371 392 B
|
371 392 B
|
||||||
391 391 C
|
391 391 C
|
||||||
389 389 D
|
389 389 D
|
||||||
388 388 A
|
388 388 A
|
||||||
386 386 F
|
386 386 F
|
||||||
383 385 E
|
383 385 E
|
||||||
384 384 A
|
384 384 A
|
||||||
381 381 F
|
381 381 F
|
||||||
372 379 F
|
372 379 F
|
||||||
378 378 D
|
378 378 D
|
||||||
377 377 A
|
377 377 A
|
||||||
375 375 G
|
375 375 G
|
||||||
374 374 A
|
374 374 A
|
||||||
49 370 C
|
49 370 C
|
||||||
59 369 D
|
59 369 D
|
||||||
60 367 B
|
60 367 B
|
||||||
65 365 C
|
65 365 C
|
||||||
67 364 A
|
67 364 A
|
||||||
363 363 B
|
363 363 B
|
||||||
361 361 G
|
361 361 G
|
||||||
72 360 B
|
72 360 B
|
||||||
82 359 E
|
82 359 E
|
||||||
96 358 A
|
96 358 A
|
||||||
97 356 D
|
97 356 D
|
||||||
355 355 F
|
355 355 F
|
||||||
350 354 G
|
350 354 G
|
||||||
353 353 E
|
353 353 E
|
||||||
351 352 C
|
351 352 C
|
||||||
342 347 C
|
342 347 C
|
||||||
344 346 F
|
344 346 F
|
||||||
343 343 E
|
343 343 E
|
||||||
101 341 F
|
101 341 F
|
||||||
340 340 A
|
340 340 A
|
||||||
338 338 A
|
338 338 A
|
||||||
325 336 E
|
325 336 E
|
||||||
335 335 C
|
335 335 C
|
||||||
334 334 A
|
334 334 A
|
||||||
331 331 G
|
331 331 G
|
||||||
330 330 B
|
330 330 B
|
||||||
326 329 C
|
326 329 C
|
||||||
103 322 A
|
103 322 A
|
||||||
104 321 C
|
104 321 C
|
||||||
318 320 G
|
318 320 G
|
||||||
319 319 D
|
319 319 D
|
||||||
105 317 D
|
105 317 D
|
||||||
316 316 A
|
316 316 A
|
||||||
106 313 E
|
106 313 E
|
||||||
107 312 G
|
107 312 G
|
||||||
311 311 D
|
311 311 D
|
||||||
310 310 B
|
310 310 B
|
||||||
111 308 F
|
111 308 F
|
||||||
302 307 D
|
302 307 D
|
||||||
303 306 E
|
303 306 E
|
||||||
305 305 A
|
305 305 A
|
||||||
304 304 B
|
304 304 B
|
||||||
112 301 B
|
112 301 B
|
||||||
113 299 E
|
113 299 E
|
||||||
295 298 C
|
295 298 C
|
||||||
297 297 A
|
297 297 A
|
||||||
296 296 B
|
296 296 B
|
||||||
293 293 D
|
293 293 D
|
||||||
289 291 C
|
289 291 C
|
||||||
290 290 G
|
290 290 G
|
||||||
114 287 A
|
114 287 A
|
||||||
264 286 D
|
264 286 D
|
||||||
266 285 G
|
266 285 G
|
||||||
268 284 E
|
268 284 E
|
||||||
280 283 D
|
280 283 D
|
||||||
282 282 B
|
282 282 B
|
||||||
281 281 F
|
281 281 F
|
||||||
270 278 C
|
270 278 C
|
||||||
271 277 A
|
271 277 A
|
||||||
276 276 G
|
276 276 G
|
||||||
275 275 B
|
275 275 B
|
||||||
272 274 F
|
272 274 F
|
||||||
273 273 D
|
273 273 D
|
||||||
265 265 C
|
265 265 C
|
||||||
115 262 B
|
115 262 B
|
||||||
116 261 E
|
116 261 E
|
||||||
260 260 C
|
260 260 C
|
||||||
122 258 A
|
122 258 A
|
||||||
256 256 G
|
256 256 G
|
||||||
127 254 G
|
127 254 G
|
||||||
253 253 C
|
253 253 C
|
||||||
252 252 D
|
252 252 D
|
||||||
132 250 B
|
132 250 B
|
||||||
133 249 C
|
133 249 C
|
||||||
248 248 D
|
248 248 D
|
||||||
245 247 A
|
245 247 A
|
||||||
246 246 E
|
246 246 E
|
||||||
134 243 D
|
134 243 D
|
||||||
145 241 B
|
145 241 B
|
||||||
160 240 E
|
160 240 E
|
||||||
208 239 F
|
208 239 F
|
||||||
236 238 A
|
236 238 A
|
||||||
237 237 B
|
237 237 B
|
||||||
233 235 C
|
233 235 C
|
||||||
234 234 E
|
234 234 E
|
||||||
223 231 A
|
223 231 A
|
||||||
229 229 B
|
229 229 B
|
||||||
226 228 E
|
226 228 E
|
||||||
227 227 G
|
227 227 G
|
||||||
224 224 B
|
224 224 B
|
||||||
210 220 A
|
210 220 A
|
||||||
219 219 E
|
219 219 E
|
||||||
212 218 G
|
212 218 G
|
||||||
217 217 B
|
217 217 B
|
||||||
213 216 C
|
213 216 C
|
||||||
215 215 F
|
215 215 F
|
||||||
211 211 D
|
211 211 D
|
||||||
163 206 F
|
163 206 F
|
||||||
164 205 D
|
164 205 D
|
||||||
203 204 E
|
203 204 E
|
||||||
189 201 E
|
189 201 E
|
||||||
198 200 B
|
198 200 B
|
||||||
199 199 D
|
199 199 D
|
||||||
190 196 A
|
190 196 A
|
||||||
195 195 G
|
195 195 G
|
||||||
191 194 B
|
191 194 B
|
||||||
193 193 C
|
193 193 C
|
||||||
192 192 E
|
192 192 E
|
||||||
185 187 B
|
185 187 B
|
||||||
186 186 F
|
186 186 F
|
||||||
170 183 E
|
170 183 E
|
||||||
171 182 A
|
171 182 A
|
||||||
179 181 F
|
179 181 F
|
||||||
180 180 B
|
180 180 B
|
||||||
173 177 G
|
173 177 G
|
||||||
175 176 F
|
175 176 F
|
||||||
174 174 E
|
174 174 E
|
||||||
172 172 C
|
172 172 C
|
||||||
168 169 C
|
168 169 C
|
||||||
165 167 B
|
165 167 B
|
||||||
161 161 D
|
161 161 D
|
||||||
158 158 A
|
158 158 A
|
||||||
146 157 C
|
146 157 C
|
||||||
150 156 D
|
150 156 D
|
||||||
151 155 A
|
151 155 A
|
||||||
154 154 F
|
154 154 F
|
||||||
152 152 G
|
152 152 G
|
||||||
148 148 E
|
148 148 E
|
||||||
147 147 G
|
147 147 G
|
||||||
143 143 A
|
143 143 A
|
||||||
142 142 E
|
142 142 E
|
||||||
135 140 F
|
135 140 F
|
||||||
139 139 C
|
139 139 C
|
||||||
137 137 A
|
137 137 A
|
||||||
136 136 B
|
136 136 B
|
||||||
128 131 F
|
128 131 F
|
||||||
130 130 E
|
130 130 E
|
||||||
129 129 A
|
129 129 A
|
||||||
125 125 C
|
125 125 C
|
||||||
120 120 C
|
120 120 C
|
||||||
119 119 D
|
119 119 D
|
||||||
118 118 F
|
118 118 F
|
||||||
117 117 A
|
117 117 A
|
||||||
108 110 D
|
108 110 D
|
||||||
102 102 B
|
102 102 B
|
||||||
98 98 E
|
98 98 E
|
||||||
85 95 G
|
85 95 G
|
||||||
86 94 B
|
86 94 B
|
||||||
93 93 C
|
93 93 C
|
||||||
88 91 E
|
88 91 E
|
||||||
90 90 A
|
90 90 A
|
||||||
89 89 C
|
89 89 C
|
||||||
87 87 F
|
87 87 F
|
||||||
83 83 G
|
83 83 G
|
||||||
77 79 F
|
77 79 F
|
||||||
78 78 A
|
78 78 A
|
||||||
74 76 C
|
74 76 C
|
||||||
68 70 D
|
68 70 D
|
||||||
69 69 F
|
69 69 F
|
||||||
63 63 G
|
63 63 G
|
||||||
61 61 F
|
61 61 F
|
||||||
50 58 E
|
50 58 E
|
||||||
51 57 G
|
51 57 G
|
||||||
55 56 F
|
55 56 F
|
||||||
52 54 C
|
52 54 C
|
||||||
53 53 B
|
53 53 B
|
||||||
33 47 F
|
33 47 F
|
||||||
37 46 B
|
37 46 B
|
||||||
45 45 C
|
45 45 C
|
||||||
43 43 G
|
43 43 G
|
||||||
41 41 E
|
41 41 E
|
||||||
38 40 A
|
38 40 A
|
||||||
39 39 C
|
39 39 C
|
||||||
36 36 D
|
36 36 D
|
||||||
34 34 B
|
34 34 B
|
||||||
28 31 D
|
28 31 D
|
||||||
29 29 E
|
29 29 E
|
||||||
24 24 F
|
24 24 F
|
||||||
19 22 B
|
19 22 B
|
||||||
21 21 F
|
21 21 F
|
||||||
20 20 A
|
20 20 A
|
||||||
15 15 A
|
15 15 A
|
||||||
12 12 F
|
12 12 F
|
||||||
11 11 E
|
11 11 E
|
||||||
9 9 G
|
9 9 G
|
||||||
6 8 C
|
6 8 C
|
||||||
7 7 E
|
7 7 E
|
||||||
5 5 F
|
5 5 F
|
||||||
4 4 A
|
4 4 A
|
||||||
2 2 D
|
2 2 D
|
||||||
1 1 A
|
1 1 A
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
692
|
692
|
||||||
ADBAFCECGBEFBDADDCBAFBCFCEGDEDDGFBFDBACAEBGBCBFGCEGCBCFFGEDBFBGBCCADFDABBCCCFAFBBEGEGBFECAEBCBGADEDDFBACDEGDDDFBEABEAFDCEAAACAGFAEFBCDFBAFCFDEADBCGECDAGAFADCABEDEFDBBBCCEACGEFFGAFBFAEDBFBDEABECBGAEBDBEDEEDFEFFADGCCFCBGEAFFABAEGEBAAFCECABAFEBDDCAEADCBGDCGAGAAECEBADCGGEECAFDFBGACEDFBDEGDAECGCEDECBACEBBDEBAEDFGBDGEDDADGDGCAFFECCCCBGEEACEFAFAFCEFFFCDDGCCEGFDAAEBGABACBBDDCBFFAGFADFBFBEAEFBADBCBGECCDFGACAECFBEEFACFEADGGBEAFADEFCABCBEACGFAGCDDDCCCFACGCBBGCFGGBDBBCBCEFADBGGCFGCCGCFDGEBCBBGDAFFBAAGEECBFFFGDBCDFBFBGDCDEFDBEBEGAAEBEDFDGGGGEFBBACFAGBFBGGECDBDECAADCGBBCAAACBEDEGGDADCAACFGGABBEEGEADCEDCEDDAAFCBGEGADECADBGFCDFEFFBFBBGGAAAGDBAEDCAFDFACDAFDEEFECAFFGFECDAABGDEFEDECBBCBGFDCAGDDAFFGDBEB
|
ADBAFCECGBEFBDADDCBAFBCFCEGDEDDGFBFDBACAEBGBCBFGCEGCBCFFGEDBFBGBCCADFDABBCCCFAFBBEGEGBFECAEBCBGADEDDFBACDEGDDDFBEABEAFDCEAAACAGFAEFBCDFBAFCFDEADBCGECDAGAFADCABEDEFDBBBCCEACGEFFGAFBFAEDBFBDEABECBGAEBDBEDEEDFEFFADGCCFCBGEAFFABAEGEBAAFCECABAFEBDDCAEADCBGDCGAGAAECEBADCGGEECAFDFBGACEDFBDEGDAECGCEDECBACEBBDEBAEDFGBDGEDDADGDGCAFFECCCCBGEEACEFAFAFCEFFFCDDGCCEGFDAAEBGABACBBDDCBFFAGFADFBFBEAEFBADBCBGECCDFGACAECFBEEFACFEADGGBEAFADEFCABCBEACGFAGCDDDCCCFACGCBBGCFGGBDBBCBCEFADBGGCFGCCGCFDGEBCBBGDAFFBAAGEECBFFFGDBCDFBFBGDCDEFDBEBEGAAEBEDFDGGGGEFBBACFAGBFBGGECDBDECAADCGBBCAAACBEDEGGDADCAACFGGABBEEGEADCEDCEDDAAFCBGEGADECADBGFCDFEFFBFBBGGAAAGDBAEDCAFDFACDAFDEEFECAFFGFECDAABGDEFEDECBBCBGFDCAGDDAFFGDBEB
|
@ -1,117 +1,117 @@
|
|||||||
// C++ includes used for precompiling -*- C++ -*-
|
// C++ includes used for precompiling -*- C++ -*-
|
||||||
|
|
||||||
// Copyright (C) 2003-2014 Free Software Foundation, Inc.
|
// Copyright (C) 2003-2014 Free Software Foundation, Inc.
|
||||||
//
|
//
|
||||||
// This file is part of the GNU ISO C++ Library. This library is free
|
// This file is part of the GNU ISO C++ Library. This library is free
|
||||||
// software; you can redistribute it and/or modify it under the
|
// software; you can redistribute it and/or modify it under the
|
||||||
// terms of the GNU General Public License as published by the
|
// terms of the GNU General Public License as published by the
|
||||||
// Free Software Foundation; either version 3, or (at your option)
|
// Free Software Foundation; either version 3, or (at your option)
|
||||||
// any later version.
|
// any later version.
|
||||||
|
|
||||||
// This library is distributed in the hope that it will be useful,
|
// This library is distributed in the hope that it will be useful,
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// GNU General Public License for more details.
|
// GNU General Public License for more details.
|
||||||
|
|
||||||
// Under Section 7 of GPL version 3, you are granted additional
|
// Under Section 7 of GPL version 3, you are granted additional
|
||||||
// permissions described in the GCC Runtime Library Exception, version
|
// permissions described in the GCC Runtime Library Exception, version
|
||||||
// 3.1, as published by the Free Software Foundation.
|
// 3.1, as published by the Free Software Foundation.
|
||||||
|
|
||||||
// You should have received a copy of the GNU General Public License and
|
// You should have received a copy of the GNU General Public License and
|
||||||
// a copy of the GCC Runtime Library Exception along with this program;
|
// a copy of the GCC Runtime Library Exception along with this program;
|
||||||
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
||||||
// <http://www.gnu.org/licenses/>.
|
// <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
/** @file stdc++.h
|
/** @file stdc++.h
|
||||||
* This is an implementation file for a precompiled header.
|
* This is an implementation file for a precompiled header.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// 17.4.1.2 Headers
|
// 17.4.1.2 Headers
|
||||||
|
|
||||||
// C
|
// C
|
||||||
#ifndef _GLIBCXX_NO_ASSERT
|
#ifndef _GLIBCXX_NO_ASSERT
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#endif
|
#endif
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cerrno>
|
#include <cerrno>
|
||||||
#include <cfloat>
|
#include <cfloat>
|
||||||
#include <ciso646>
|
#include <ciso646>
|
||||||
#include <climits>
|
#include <climits>
|
||||||
#include <clocale>
|
#include <clocale>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <csetjmp>
|
#include <csetjmp>
|
||||||
#include <csignal>
|
#include <csignal>
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
#include <ccomplex>
|
#include <ccomplex>
|
||||||
#include <cfenv>
|
#include <cfenv>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
// #include <cstdalign>
|
// #include <cstdalign>
|
||||||
#include <cstdbool>
|
#include <cstdbool>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <ctgmath>
|
#include <ctgmath>
|
||||||
#include <cwchar>
|
#include <cwchar>
|
||||||
#include <cwctype>
|
#include <cwctype>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// C++
|
// C++
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <complex>
|
#include <complex>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <ios>
|
#include <ios>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <new>
|
#include <new>
|
||||||
#include <numeric>
|
#include <numeric>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <streambuf>
|
#include <streambuf>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <valarray>
|
#include <valarray>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
#if __cplusplus >= 201103L
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <forward_list>
|
#include <forward_list>
|
||||||
#include <future>
|
#include <future>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <random>
|
#include <random>
|
||||||
#include <ratio>
|
#include <ratio>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <scoped_allocator>
|
#include <scoped_allocator>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <typeindex>
|
#include <typeindex>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,83 +1,83 @@
|
|||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
|
|
||||||
using ll = long long;
|
using ll = long long;
|
||||||
auto &is = std::cin;
|
auto &is = std::cin;
|
||||||
auto &os = std::cout;
|
auto &os = std::cout;
|
||||||
|
|
||||||
struct Point{
|
struct Point{
|
||||||
ll x,y;
|
ll x,y;
|
||||||
};
|
};
|
||||||
struct Status{
|
struct Status{
|
||||||
Point now;
|
Point now;
|
||||||
ll step;
|
ll step;
|
||||||
bool operator<(const Status &that)const noexcept{
|
bool operator<(const Status &that)const noexcept{
|
||||||
return this->step > that.step;
|
return this->step > that.step;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const ll max_nm {200+5};
|
const ll max_nm {200+5};
|
||||||
const ll ll_max {std::numeric_limits<decltype(ll_max)>::max()};
|
const ll ll_max {std::numeric_limits<decltype(ll_max)>::max()};
|
||||||
ll n, h, w, ans{ll_max};
|
ll n, h, w, ans{ll_max};
|
||||||
char map[max_nm][max_nm];
|
char map[max_nm][max_nm];
|
||||||
Point me;
|
Point me;
|
||||||
|
|
||||||
const int to_next[4][2] {
|
const int to_next[4][2] {
|
||||||
{1,0},
|
{1,0},
|
||||||
{0,1},
|
{0,1},
|
||||||
{-1,0},
|
{-1,0},
|
||||||
{0,-1},
|
{0,-1},
|
||||||
};
|
};
|
||||||
|
|
||||||
void bfs(const Point start)noexcept{
|
void bfs(const Point start)noexcept{
|
||||||
std::bitset<max_nm> vis[max_nm];
|
std::bitset<max_nm> vis[max_nm];
|
||||||
|
|
||||||
std::priority_queue<Status> q;
|
std::priority_queue<Status> q;
|
||||||
ans = ll_max;
|
ans = ll_max;
|
||||||
vis[start.x][start.y] = true;
|
vis[start.x][start.y] = true;
|
||||||
|
|
||||||
q.push({start,0});
|
q.push({start,0});
|
||||||
while(q.empty()==false){
|
while(q.empty()==false){
|
||||||
const auto status = q.top();
|
const auto status = q.top();
|
||||||
const auto nowchar = [&status]()->char{return map[status.now.x][status.now.y];};
|
const auto nowchar = [&status]()->char{return map[status.now.x][status.now.y];};
|
||||||
q.pop();
|
q.pop();
|
||||||
|
|
||||||
if(nowchar()=='a'){
|
if(nowchar()=='a'){
|
||||||
ans = std::min(ans,status.step);
|
ans = std::min(ans,status.step);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for(ll i{0};i<4;i++){
|
for(ll i{0};i<4;i++){
|
||||||
const Point next {status.now.x+to_next[i][0],status.now.y+to_next[i][1]};
|
const Point next {status.now.x+to_next[i][0],status.now.y+to_next[i][1]};
|
||||||
if(vis[next.x][next.y])continue;
|
if(vis[next.x][next.y])continue;
|
||||||
const auto nextchar = [&next]()->char{return map[next.x][next.y];};
|
const auto nextchar = [&next]()->char{return map[next.x][next.y];};
|
||||||
ll cost {1};
|
ll cost {1};
|
||||||
if(next.x>h || next.x<=0 || next.y > w || next.y<=0
|
if(next.x>h || next.x<=0 || next.y > w || next.y<=0
|
||||||
|| nextchar()=='#')continue;
|
|| nextchar()=='#')continue;
|
||||||
if(nextchar()=='x')cost++;
|
if(nextchar()=='x')cost++;
|
||||||
const Status next_status {next,status.step+cost};
|
const Status next_status {next,status.step+cost};
|
||||||
vis[next_status.now.x][next_status.now.y] = true;
|
vis[next_status.now.x][next_status.now.y] = true;
|
||||||
q.push(next_status);
|
q.push(next_status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
is>>n;
|
is>>n;
|
||||||
for(ll _{0};_<n;_++){
|
for(ll _{0};_<n;_++){
|
||||||
is>>h>>w;
|
is>>h>>w;
|
||||||
for(ll i{1};i<=h;i++){
|
for(ll i{1};i<=h;i++){
|
||||||
for(ll j{1};j<=w;j++){
|
for(ll j{1};j<=w;j++){
|
||||||
is>>map[i][j];
|
is>>map[i][j];
|
||||||
if(map[i][j]=='r')me.x=i,me.y=j;
|
if(map[i][j]=='r')me.x=i,me.y=j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bfs(me);
|
bfs(me);
|
||||||
if(ans==ll_max)os<<"Impossible\n";
|
if(ans==ll_max)os<<"Impossible\n";
|
||||||
else os<<ans<<'\n';
|
else os<<ans<<'\n';
|
||||||
}
|
}
|
||||||
}
|
}
|
150
src/test.cpp
150
src/test.cpp
@ -1,76 +1,76 @@
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NV(v)#v<<" : "<<(v)
|
#define NV(v)#v<<" : "<<(v)
|
||||||
using ull = unsigned long long;
|
using ull = unsigned long long;
|
||||||
|
|
||||||
#ifdef NDEBUG
|
#ifdef NDEBUG
|
||||||
#define ARR_NDB_NOEXCEPT noexcept
|
#define ARR_NDB_NOEXCEPT noexcept
|
||||||
#define ARR_NDB_CONSTEXPR constexpr
|
#define ARR_NDB_CONSTEXPR constexpr
|
||||||
#else
|
#else
|
||||||
#define ARR_NDB_CONSTEXPR
|
#define ARR_NDB_CONSTEXPR
|
||||||
#define ARR_NDB_NOEXCEPT
|
#define ARR_NDB_NOEXCEPT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<size_t a,size_t b>
|
template<size_t a,size_t b>
|
||||||
constexpr bool test(){
|
constexpr bool test(){
|
||||||
return a>=b;
|
return a>=b;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T, size_t size>
|
template<class T, size_t size>
|
||||||
class Array{
|
class Array{
|
||||||
public:
|
public:
|
||||||
private:
|
private:
|
||||||
T arr[size];
|
T arr[size];
|
||||||
public:
|
public:
|
||||||
ARR_NDB_CONSTEXPR T& operator[](const size_t n)ARR_NDB_NOEXCEPT{
|
ARR_NDB_CONSTEXPR T& operator[](const size_t n)ARR_NDB_NOEXCEPT{
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if(n>=size){
|
if(n>=size){
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss<<"\nYour [array size] is: "<<size<<"\nBut your [index] is :"<<n<<'\n';
|
ss<<"\nYour [array size] is: "<<size<<"\nBut your [index] is :"<<n<<'\n';
|
||||||
throw std::range_error(ss.str());
|
throw std::range_error(ss.str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return arr[n];
|
return arr[n];
|
||||||
}
|
}
|
||||||
ARR_NDB_CONSTEXPR const T& operator[](const size_t n)const ARR_NDB_NOEXCEPT{
|
ARR_NDB_CONSTEXPR const T& operator[](const size_t n)const ARR_NDB_NOEXCEPT{
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
if(n>=size){
|
if(n>=size){
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss<<"\nYour [array size] is: "<<size<<"\nBut your [index] is :"<<n<<'\n';
|
ss<<"\nYour [array size] is: "<<size<<"\nBut your [index] is :"<<n<<'\n';
|
||||||
throw std::range_error(ss.str());
|
throw std::range_error(ss.str());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return arr[n];
|
return arr[n];
|
||||||
}
|
}
|
||||||
ARR_NDB_CONSTEXPR operator const T*()const ARR_NDB_NOEXCEPT{
|
ARR_NDB_CONSTEXPR operator const T*()const ARR_NDB_NOEXCEPT{
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
constexpr bool is_const()const{
|
constexpr bool is_const()const{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
constexpr bool is_const(){
|
constexpr bool is_const(){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr size_t size {10};
|
constexpr size_t size {10};
|
||||||
constexpr Array<ull,size> arr{};
|
constexpr Array<ull,size> arr{};
|
||||||
ull a;
|
ull a;
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
std::cout<<NV(arr)<<'\n';
|
std::cout<<NV(arr)<<'\n';
|
||||||
// std::cout<<NV(&arr[size-1])<<'\n'<<NV(&a)<<'\n';
|
// std::cout<<NV(&arr[size-1])<<'\n'<<NV(&a)<<'\n';
|
||||||
// std::cout<<NV(a)<<'\n';
|
// std::cout<<NV(a)<<'\n';
|
||||||
// std::cout<<NV(++arr[size])<<'\n';
|
// std::cout<<NV(++arr[size])<<'\n';
|
||||||
// std::cout<<NV(a)<<'\n';
|
// std::cout<<NV(a)<<'\n';
|
||||||
constexpr ull a {arr[size-1]};
|
constexpr ull a {arr[size-1]};
|
||||||
const constexpr ull *p {arr};
|
const constexpr ull *p {arr};
|
||||||
std::cout<<NV(a)<<'\n'<<NV(p)<<'\n';
|
std::cout<<NV(a)<<'\n'<<NV(p)<<'\n';
|
||||||
}
|
}
|
@ -1,37 +1,37 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
#include <ranges>
|
#include <ranges>
|
||||||
|
|
||||||
static const size_t MAX_LEN {(size_t)2e3+5};
|
static const size_t MAX_LEN {(size_t)2e3+5};
|
||||||
static std::string s,p;
|
static std::string s,p;
|
||||||
static constexpr auto range {std::ranges::views::iota};
|
static constexpr auto range {std::ranges::views::iota};
|
||||||
|
|
||||||
static std::bitset<MAX_LEN> dp[MAX_LEN];
|
static std::bitset<MAX_LEN> dp[MAX_LEN];
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
const auto get_p = [](const size_t n)noexcept->const char&{return p[n-1];};
|
const auto get_p = [](const size_t n)noexcept->const char&{return p[n-1];};
|
||||||
const auto get_s = [](const size_t n)noexcept->const char&{return s[n-1];};
|
const auto get_s = [](const size_t n)noexcept->const char&{return s[n-1];};
|
||||||
|
|
||||||
std::cin>>s>>p;
|
std::cin>>s>>p;
|
||||||
|
|
||||||
dp[0][0] = true;
|
dp[0][0] = true;
|
||||||
|
|
||||||
for(const size_t j:range((size_t)1,p.size()+1)){
|
for(const size_t j:range((size_t)1,p.size()+1)){
|
||||||
if(get_p(j)!='*'){
|
if(get_p(j)!='*'){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
dp[0][j]=true;
|
dp[0][j]=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(const size_t i:range((size_t)1,s.size()+1)){
|
for(const size_t i:range((size_t)1,s.size()+1)){
|
||||||
for(const size_t j:range((size_t)1,p.size()+1)){
|
for(const size_t j:range((size_t)1,p.size()+1)){
|
||||||
if(get_s(i) == get_p(j) || get_p(j)=='?'){
|
if(get_s(i) == get_p(j) || get_p(j)=='?'){
|
||||||
dp[i][j] = dp[i-1][j-1];
|
dp[i][j] = dp[i-1][j-1];
|
||||||
}else if(get_p(j)=='*'){
|
}else if(get_p(j)=='*'){
|
||||||
dp[i][j] = dp[i-1][j] || dp[i][j-1]; //01背包,查看是否使用这个字符
|
dp[i][j] = dp[i-1][j] || dp[i][j-1]; //01背包,查看是否使用这个字符
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
std::cout<<(dp[s.size()][p.size()]==true?"yes":"no")<<'\n';
|
std::cout<<(dp[s.size()][p.size()]==true?"yes":"no")<<'\n';
|
||||||
}
|
}
|
@ -1,60 +1,60 @@
|
|||||||
# Wildcard Match
|
# Wildcard Match
|
||||||
># wildcard_match
|
># wildcard_match
|
||||||
题目描述:
|
题目描述:
|
||||||
|
|
||||||
给定一个字符串 `s` 和一个模式 `p`,实现通配符模式匹配,支持 '?' 和 '*',其中:
|
给定一个字符串 `s` 和一个模式 `p`,实现通配符模式匹配,支持 '?' 和 '*',其中:
|
||||||
- '?' 匹配任意单个字符。
|
- '?' 匹配任意单个字符。
|
||||||
- '*' 匹配任意长度的字符序列(包括空序列)。
|
- '*' 匹配任意长度的字符序列(包括空序列)。
|
||||||
|
|
||||||
匹配应覆盖整个输入字符串(不允许部分匹配)。
|
匹配应覆盖整个输入字符串(不允许部分匹配)。
|
||||||
|
|
||||||
输入:
|
输入:
|
||||||
- 第一行是字符串 `s`。
|
- 第一行是字符串 `s`。
|
||||||
- 第二行是字符串 `p`。
|
- 第二行是字符串 `p`。
|
||||||
|
|
||||||
约束:
|
约束:
|
||||||
- 0 < s.length, p.length < 2000。
|
- 0 < s.length, p.length < 2000。
|
||||||
- `s` 仅包含小写英文字母。
|
- `s` 仅包含小写英文字母。
|
||||||
- `p` 仅包含小写英文字母、'?' 或 '*'。
|
- `p` 仅包含小写英文字母、'?' 或 '*'。
|
||||||
|
|
||||||
输出:
|
输出:
|
||||||
- 输出 "yes" 或 "no"。
|
- 输出 "yes" 或 "no"。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
示例 1:
|
示例 1:
|
||||||
输入:
|
输入:
|
||||||
```
|
```
|
||||||
app
|
app
|
||||||
ap
|
ap
|
||||||
```
|
```
|
||||||
输出:
|
输出:
|
||||||
```
|
```
|
||||||
no
|
no
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
示例 2:
|
示例 2:
|
||||||
输入:
|
输入:
|
||||||
```
|
```
|
||||||
app
|
app
|
||||||
a?p
|
a?p
|
||||||
```
|
```
|
||||||
输出:
|
输出:
|
||||||
```
|
```
|
||||||
yes
|
yes
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
示例 3:
|
示例 3:
|
||||||
输入:
|
输入:
|
||||||
```
|
```
|
||||||
abc
|
abc
|
||||||
a*
|
a*
|
||||||
```
|
```
|
||||||
输出:
|
输出:
|
||||||
```
|
```
|
||||||
yes
|
yes
|
||||||
```
|
```
|
Loading…
Reference in New Issue
Block a user