mirror of
https://gitlab.com/mfocko/Codeforces.git
synced 2024-11-09 21:59:06 +01:00
1321 lines
86 KiB
HTML
1321 lines
86 KiB
HTML
|
|
|||
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
|||
|
<html lang="en">
|
|||
|
<head>
|
|||
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|||
|
<meta name="X-Csrf-Token" content="ae751edca974d9cd4dd707531deeb4c1"/>
|
|||
|
<meta id="viewport" name="viewport" content="width=device-width, initial-scale=0.01"/>
|
|||
|
|
|||
|
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/0/js/jquery-1.8.3.js"></script>
|
|||
|
<script type="application/javascript">
|
|||
|
window.locale = "en";
|
|||
|
window.standaloneContest = false;
|
|||
|
function adjustViewport() {
|
|||
|
var screenWidthPx = Math.min($(window).width(), window.screen.width);
|
|||
|
var siteWidthPx = 1100; // min width of site
|
|||
|
var ratio = Math.min(screenWidthPx / siteWidthPx, 1.0);
|
|||
|
var viewport = "width=device-width, initial-scale=" + ratio;
|
|||
|
$('#viewport').attr('content', viewport);
|
|||
|
var style = $('<style>html * { max-height: 1000000px; }</style>');
|
|||
|
$('html > head').append(style);
|
|||
|
}
|
|||
|
|
|||
|
if ( /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent) ) {
|
|||
|
adjustViewport();
|
|||
|
}
|
|||
|
|
|||
|
/* Protection against trailing dot in domain. */
|
|||
|
let hostLength = window.location.host.length;
|
|||
|
if (hostLength > 1 && window.location.host[hostLength - 1] === '.') {
|
|||
|
window.location = window.location.protocol + "//" + window.location.host.substring(0, hostLength - 1);
|
|||
|
}
|
|||
|
</script>
|
|||
|
<meta http-equiv="pragma" content="no-cache">
|
|||
|
<meta http-equiv="expires" content="-1">
|
|||
|
<meta http-equiv="profileName" content="f1">
|
|||
|
<meta name="google-site-verification" content="OTd2dN5x4nS4OPknPI9JFg36fKxjqY0i1PSfFPv_J90"/>
|
|||
|
<meta property="fb:admins" content="100001352546622" />
|
|||
|
<meta property="og:image" content="//codeforces.org/s/0/images/codeforces-sponsored-by-ton.png" />
|
|||
|
<link rel="image_src" href="//codeforces.org/s/0/images/codeforces-sponsored-by-ton.png" />
|
|||
|
<meta property="og:title" content="Problems - Codeforces"/>
|
|||
|
<meta property="og:description" content=""/>
|
|||
|
|
|||
|
<meta property="og:site_name" content="Codeforces"/>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<meta name="utc_offset" content="+03:00"/>
|
|||
|
<meta name="verify-reformal" content="f56f99fd7e087fb6ccb48ef2" />
|
|||
|
<title>Problems - Codeforces</title>
|
|||
|
<meta name="description" content="Codeforces. Programming competitions and contests, programming community" />
|
|||
|
<meta name="keywords" content="programming algorithm contest competition informatics olympiads c++ java graphs vkcup" />
|
|||
|
<meta name="robots" content="index, follow" />
|
|||
|
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/font-awesome.min.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/line-awesome.min.css" type="text/css" charset="utf-8" />
|
|||
|
|
|||
|
<link href='//fonts.googleapis.com/css?family=PT+Sans+Narrow:400,700&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
|
|||
|
<link href='//fonts.googleapis.com/css?family=Cuprum&subset=latin,cyrillic' rel='stylesheet' type='text/css'>
|
|||
|
|
|||
|
|
|||
|
<link rel="apple-touch-icon" sizes="57x57" href="//codeforces.org/s/0/apple-icon-57x57.png">
|
|||
|
<link rel="apple-touch-icon" sizes="60x60" href="//codeforces.org/s/0/apple-icon-60x60.png">
|
|||
|
<link rel="apple-touch-icon" sizes="72x72" href="//codeforces.org/s/0/apple-icon-72x72.png">
|
|||
|
<link rel="apple-touch-icon" sizes="76x76" href="//codeforces.org/s/0/apple-icon-76x76.png">
|
|||
|
<link rel="apple-touch-icon" sizes="114x114" href="//codeforces.org/s/0/apple-icon-114x114.png">
|
|||
|
<link rel="apple-touch-icon" sizes="120x120" href="//codeforces.org/s/0/apple-icon-120x120.png">
|
|||
|
<link rel="apple-touch-icon" sizes="144x144" href="//codeforces.org/s/0/apple-icon-144x144.png">
|
|||
|
<link rel="apple-touch-icon" sizes="152x152" href="//codeforces.org/s/0/apple-icon-152x152.png">
|
|||
|
<link rel="apple-touch-icon" sizes="180x180" href="//codeforces.org/s/0/apple-icon-180x180.png">
|
|||
|
<link rel="icon" type="image/png" sizes="192x192" href="//codeforces.org/s/0/android-icon-192x192.png">
|
|||
|
<link rel="icon" type="image/png" sizes="32x32" href="//codeforces.org/s/0/favicon-32x32.png">
|
|||
|
<link rel="icon" type="image/png" sizes="96x96" href="//codeforces.org/s/0/favicon-96x96.png">
|
|||
|
<link rel="icon" type="image/png" sizes="16x16" href="//codeforces.org/s/0/favicon-16x16.png">
|
|||
|
<link rel="manifest" href="/manifest.json">
|
|||
|
<meta name="msapplication-TileColor" content="#ffffff">
|
|||
|
<meta name="msapplication-TileImage" content="//codeforces.org/s/0/ms-icon-144x144.png">
|
|||
|
<meta name="theme-color" content="#ffffff">
|
|||
|
|
|||
|
<!--CombineResourcesFilter-->
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/prettify.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/clear.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/style.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/ttypography.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/problem-statement.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/second-level-menu.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/roundbox.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/datatable.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/table-form.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/topic.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/jquery.jgrowl.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/facebox.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/jquery.wysiwyg.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/jquery.autocomplete.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/codeforces.datepick.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/colorbox.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/jquery.drafts.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/community.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/css/sidebar-menu.css" type="text/css" charset="utf-8" />
|
|||
|
|
|||
|
<!-- MathJax -->
|
|||
|
<script type="text/x-mathjax-config">
|
|||
|
MathJax.Hub.Config({
|
|||
|
tex2jax: {inlineMath: [['$$$','$$$']], displayMath: [['$$$$$$','$$$$$$']]}
|
|||
|
});
|
|||
|
MathJax.Hub.Register.StartupHook("End", function () {
|
|||
|
Codeforces.runMathJaxListeners();
|
|||
|
});
|
|||
|
</script>
|
|||
|
<script type="text/javascript" async
|
|||
|
src="https://cdn-mathjax.codeforces.com/MathJax.js?config=TeX-AMS_HTML-full"
|
|||
|
>
|
|||
|
</script>
|
|||
|
<!-- /MathJax -->
|
|||
|
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/prettify/prettify.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/moment-with-locales.min.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/pushstream.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/jquery.easing.min.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/jquery.lavalamp.min.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/jquery.jgrowl.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/jquery.swipe.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/jquery.hotkeys.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/facebox.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/jquery.wysiwyg.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/controls/wysiwyg.colorpicker.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/controls/wysiwyg.table.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/controls/wysiwyg.image.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/controls/wysiwyg.link.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/jquery.autocomplete.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/jquery.datepick.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/jquery.ie6blocker.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/jquery.colorbox-min.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/jquery.ba-bbq.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/jquery.drafts.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/clipboard.min.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/autosize.min.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/sjcl.js"></script>
|
|||
|
<script type="text/javascript" src="/scripts/658bcc8e4b3c6baeb1034414d85702f6/en/codeforces-options.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/codeforces.js?v=20160131"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/EventCatcher.js?v=20160131"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/preparedVerdictFormats-en.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/js/confetti.min.js"></script>
|
|||
|
<!--/CombineResourcesFilter-->
|
|||
|
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/markitup/skins/markitup/style.css" type="text/css" charset="utf-8" />
|
|||
|
<link rel="stylesheet" href="//codeforces.org/s/42835/markitup/sets/markdown/style.css" type="text/css" charset="utf-8" />
|
|||
|
|
|||
|
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/markitup/jquery.markitup.js"></script>
|
|||
|
<script type="text/javascript" src="//codeforces.org/s/42835/markitup/sets/markdown/set.js"></script>
|
|||
|
|
|||
|
<!--[if IE]>
|
|||
|
<style>
|
|||
|
#sidebar {
|
|||
|
padding-left: 1em;
|
|||
|
margin: 1em 1em 1em 0;
|
|||
|
}
|
|||
|
</style>
|
|||
|
<![endif]-->
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
</head>
|
|||
|
<body class=" "><span style='display:none;' class='csrf-token' data-csrf='ae751edca974d9cd4dd707531deeb4c1'> </span>
|
|||
|
|
|||
|
<!-- .notificationTextCleaner used in Codeforces.showAnnouncements() -->
|
|||
|
<div class="notificationTextCleaner" style="font-size: 0"></div>
|
|||
|
<div class="button-up" style="display: none; opacity: 0.7; width: 50px; height:100%; position: fixed; left: 0; top: 0; cursor: pointer; text-align: center; line-height: 35px; color: #d3dbe4; font-weight: bold; font-size: 3.0rem;"><i class="icon-circle-arrow-up"></i></div>
|
|||
|
<div class="verdictPrototypeDiv" style="display: none;"></div>
|
|||
|
|
|||
|
<!-- Codeforces JavaScripts. -->
|
|||
|
<script type="text/javascript">
|
|||
|
String.prototype.hashCode = function() {
|
|||
|
var hash = 0, i, chr;
|
|||
|
if (this.length === 0) return hash;
|
|||
|
for (i = 0; i < this.length; i++) {
|
|||
|
chr = this.charCodeAt(i);
|
|||
|
hash = ((hash << 5) - hash) + chr;
|
|||
|
hash |= 0; // Convert to 32bit integer
|
|||
|
}
|
|||
|
return hash;
|
|||
|
};
|
|||
|
|
|||
|
var queryMobile = Codeforces.queryString.mobile;
|
|||
|
if (queryMobile === "true" || queryMobile === "false") {
|
|||
|
Codeforces.putToStorage("useMobile", queryMobile === "true");
|
|||
|
} else {
|
|||
|
var useMobile = Codeforces.getFromStorage("useMobile");
|
|||
|
if (useMobile === true || useMobile === false) {
|
|||
|
if (useMobile != false) {
|
|||
|
Codeforces.redirect(Codeforces.updateUrlParameter(document.location.href, "mobile", useMobile));
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
</script>
|
|||
|
|
|||
|
<script type="text/javascript">
|
|||
|
if (window.parent.frames.length > 0) {
|
|||
|
window.stop();
|
|||
|
}
|
|||
|
</script>
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
<script type="text/javascript">
|
|||
|
$(document).ready(function () {
|
|||
|
(function () {
|
|||
|
jQuery.expr[':'].containsCI = function(elem, index, match) {
|
|||
|
return !match || !match.length || match.length < 4 || !match[3] || (
|
|||
|
elem.textContent || elem.innerText || jQuery(elem).text() || ''
|
|||
|
).toLowerCase().indexOf(match[3].toLowerCase()) >= 0;
|
|||
|
}
|
|||
|
}(jQuery));
|
|||
|
|
|||
|
$.ajaxPrefilter(function(options, originalOptions, xhr) {
|
|||
|
var csrf = Codeforces.getCsrfToken();
|
|||
|
|
|||
|
if (csrf) {
|
|||
|
var data = originalOptions.data;
|
|||
|
if (originalOptions.data !== undefined) {
|
|||
|
if (Object.prototype.toString.call(originalOptions.data) === '[object String]') {
|
|||
|
data = $.deparam(originalOptions.data);
|
|||
|
}
|
|||
|
} else {
|
|||
|
data = {};
|
|||
|
}
|
|||
|
options.data = $.param($.extend(data, { csrf_token: csrf }));
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
window.getCodeforcesServerTime = function(callback) {
|
|||
|
$.post("/data/time", {}, callback, "json");
|
|||
|
}
|
|||
|
|
|||
|
window.updateTypography = function () {
|
|||
|
$("div.ttypography code").addClass("tt");
|
|||
|
$("div.ttypography pre>code").addClass("prettyprint").removeClass("tt");
|
|||
|
$("div.ttypography table").addClass("bordertable");
|
|||
|
prettyPrint();
|
|||
|
}
|
|||
|
|
|||
|
$.ajaxSetup({ scriptCharset: "utf-8" ,contentType: "application/x-www-form-urlencoded; charset=UTF-8", headers: {
|
|||
|
'X-Csrf-Token': Codeforces.getCsrfToken()
|
|||
|
}});
|
|||
|
|
|||
|
window.updateTypography();
|
|||
|
|
|||
|
Codeforces.signForms();
|
|||
|
|
|||
|
setTimeout(function() {
|
|||
|
$(".second-level-menu-list").lavaLamp({
|
|||
|
fx: "backout",
|
|||
|
speed: 700
|
|||
|
});
|
|||
|
}, 100);
|
|||
|
|
|||
|
|
|||
|
Codeforces.countdown();
|
|||
|
$("a[rel='photobox']").colorbox();
|
|||
|
|
|||
|
|
|||
|
function showAnnouncements(json) {
|
|||
|
//info("j=" + JSON.stringify(json));
|
|||
|
|
|||
|
if (json.t != "a") {
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
setTimeout(function() {
|
|||
|
Codeforces.showAnnouncements(json.d, "en");
|
|||
|
}, Math.random() * 500);
|
|||
|
}
|
|||
|
|
|||
|
function showEventCatcherUserMessage(json) {
|
|||
|
if (json.t == "s") {
|
|||
|
var points = json.d[5];
|
|||
|
var passedTestCount = json.d[7];
|
|||
|
var judgedTestCount = json.d[8];
|
|||
|
var verdict = preparedVerdictFormats[json.d[12]];
|
|||
|
var verdictPrototypeDiv = $(".verdictPrototypeDiv");
|
|||
|
verdictPrototypeDiv.html(verdict);
|
|||
|
if (judgedTestCount != null && judgedTestCount != undefined) {
|
|||
|
verdictPrototypeDiv.find(".verdict-format-judged").text(judgedTestCount);
|
|||
|
}
|
|||
|
if (passedTestCount != null && passedTestCount != undefined) {
|
|||
|
verdictPrototypeDiv.find(".verdict-format-passed").text(passedTestCount);
|
|||
|
}
|
|||
|
if (points != null && points != undefined) {
|
|||
|
verdictPrototypeDiv.find(".verdict-format-points").text(points);
|
|||
|
}
|
|||
|
Codeforces.showMessage(verdictPrototypeDiv.text());
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
$(".clickable-title").each(function() {
|
|||
|
var title = $(this).attr("data-title");
|
|||
|
if (title) {
|
|||
|
var tmp = document.createElement("DIV");
|
|||
|
tmp.innerHTML = title;
|
|||
|
$(this).attr("title", tmp.textContent || tmp.innerText || "");
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
$(".clickable-title").click(function() {
|
|||
|
var title = $(this).attr("data-title");
|
|||
|
if (title) {
|
|||
|
Codeforces.alert(title);
|
|||
|
} else {
|
|||
|
Codeforces.alert($(this).attr("title"));
|
|||
|
}
|
|||
|
}).css("position", "relative").css("bottom", "3px");
|
|||
|
|
|||
|
Codeforces.showDelayedMessage();
|
|||
|
|
|||
|
Codeforces.reformatTimes();
|
|||
|
|
|||
|
//Codeforces.initializePubSub();
|
|||
|
if (window.codeforcesOptions.subscribeServerUrl) {
|
|||
|
window.eventCatcher = new EventCatcher(
|
|||
|
window.codeforcesOptions.subscribeServerUrl,
|
|||
|
[
|
|||
|
Codeforces.getGlobalChannel(),
|
|||
|
Codeforces.getUserChannel(),
|
|||
|
Codeforces.getUserShowMessageChannel(),
|
|||
|
Codeforces.getContestChannel(),
|
|||
|
Codeforces.getParticipantChannel(),
|
|||
|
Codeforces.getTalkChannel()
|
|||
|
]
|
|||
|
);
|
|||
|
|
|||
|
if (Codeforces.getParticipantChannel()) {
|
|||
|
window.eventCatcher.subscribe(Codeforces.getParticipantChannel(), function(json) {
|
|||
|
showAnnouncements(json);
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (Codeforces.getContestChannel()) {
|
|||
|
window.eventCatcher.subscribe(Codeforces.getContestChannel(), function(json) {
|
|||
|
showAnnouncements(json);
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (Codeforces.getGlobalChannel()) {
|
|||
|
window.eventCatcher.subscribe(Codeforces.getGlobalChannel(), function(json) {
|
|||
|
showAnnouncements(json);
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (Codeforces.getUserChannel()) {
|
|||
|
window.eventCatcher.subscribe(Codeforces.getUserChannel(), function(json) {
|
|||
|
showAnnouncements(json);
|
|||
|
});
|
|||
|
}
|
|||
|
|
|||
|
if (Codeforces.getUserShowMessageChannel()) {
|
|||
|
window.eventCatcher.subscribe(Codeforces.getUserShowMessageChannel(), function(json) {
|
|||
|
showEventCatcherUserMessage(json);
|
|||
|
});
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
Codeforces.setupContestTimes("/data/contests");
|
|||
|
Codeforces.setupSpoilers();
|
|||
|
Codeforces.setupTutorials("/data/problemTutorial");
|
|||
|
});
|
|||
|
</script>
|
|||
|
|
|||
|
<script type="text/javascript">
|
|||
|
var _gaq = _gaq || [];
|
|||
|
_gaq.push(['_setAccount', 'UA-743380-5']);
|
|||
|
_gaq.push(['_trackPageview']);
|
|||
|
|
|||
|
(function () {
|
|||
|
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
|||
|
ga.src = (document.location.protocol == 'https:' ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
|||
|
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
|||
|
})();
|
|||
|
</script>
|
|||
|
|
|||
|
|
|||
|
<div id="body">
|
|||
|
<div style="width: 950px; margin: 0 auto;" class="compact-problemset">
|
|||
|
<div id="header" style="position: relative; margin: 0;">
|
|||
|
<div style="float:left;">
|
|||
|
<a href="/"><img height="65" style="height: 65px;" src="//codeforces.org/s/98536/images/codeforces-sponsored-by-ton.png" alt="Codeforces"/></a>
|
|||
|
</div>
|
|||
|
<div class="lang">
|
|||
|
<div style="text-align: right;">
|
|||
|
<a href="?locale=en"><img src="//codeforces.org/s/98536/images/flags/24/gb.png" title="In English" alt="In English"/></a>
|
|||
|
<a href="?locale=ru"><img src="//codeforces.org/s/98536/images/flags/24/ru.png" title="По-русски" alt="По-русски"/></a>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<br style="clear: both;"/>
|
|||
|
</div>
|
|||
|
|
|||
|
<br style="clear: both;"/>
|
|||
|
|
|||
|
<div style="text-align: center; font-size: 1.8rem; margin-bottom: 0.5em;"
|
|||
|
class="caption">Codeforces Round 871 (Div. 4)</div>
|
|||
|
<div style="border-top: 1px solid #ccc; height: 1em;"></div>
|
|||
|
|
|||
|
<div class="problem-frames">
|
|||
|
<div
|
|||
|
style="margin-bottom: 2em;"
|
|||
|
>
|
|||
|
|
|||
|
<style>
|
|||
|
#facebox .content:has(.diff-popup) {
|
|||
|
width: 90vw;
|
|||
|
max-width: 120rem !important;
|
|||
|
}
|
|||
|
|
|||
|
.testCaseMarker {
|
|||
|
position: absolute;
|
|||
|
font-weight: bold;
|
|||
|
font-size: 1rem;
|
|||
|
}
|
|||
|
|
|||
|
.diff-popup {
|
|||
|
width: 90vw;
|
|||
|
max-width: 120rem !important;
|
|||
|
display: none;
|
|||
|
overflow: auto;
|
|||
|
}
|
|||
|
|
|||
|
.input-output-copier {
|
|||
|
font-size: 1.2rem;
|
|||
|
float: right;
|
|||
|
color: #888 !important;
|
|||
|
cursor: pointer;
|
|||
|
border: 1px solid rgb(185, 185, 185);
|
|||
|
padding: 3px;
|
|||
|
margin: 1px;
|
|||
|
line-height: 1.1rem;
|
|||
|
text-transform: none;
|
|||
|
}
|
|||
|
|
|||
|
.input-output-copier:hover {
|
|||
|
background-color: #def;
|
|||
|
}
|
|||
|
|
|||
|
.test-explanation textarea {
|
|||
|
width: 100%;
|
|||
|
height: 1.5em;
|
|||
|
}
|
|||
|
|
|||
|
.pending-submission-message {
|
|||
|
color: darkorange !important;
|
|||
|
}
|
|||
|
</style>
|
|||
|
<script>
|
|||
|
const OPENING_SPACE = String.fromCharCode(1001);
|
|||
|
const CLOSING_SPACE = String.fromCharCode(1002);
|
|||
|
|
|||
|
const nodeToText = function (node, pre) {
|
|||
|
let result = [];
|
|||
|
|
|||
|
if (node.tagName === "SCRIPT" || node.tagName === "math"
|
|||
|
|| (node.classList && node.classList.contains("input-output-copier")))
|
|||
|
return [];
|
|||
|
|
|||
|
if (node.tagName === "NOBR") {
|
|||
|
result.push(OPENING_SPACE);
|
|||
|
}
|
|||
|
|
|||
|
if (node.nodeType === Node.TEXT_NODE) {
|
|||
|
let s = node.textContent;
|
|||
|
if (!pre) {
|
|||
|
s = s.replace(/\s+/g, " ");
|
|||
|
}
|
|||
|
if (s.length > 0) {
|
|||
|
result.push(s);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (pre && node.tagName === "BR") {
|
|||
|
result.push("\n");
|
|||
|
}
|
|||
|
|
|||
|
node.childNodes.forEach(function (child) {
|
|||
|
result.push(nodeToText(child, node.tagName === "PRE").join(""));
|
|||
|
});
|
|||
|
|
|||
|
if (node.tagName === "DIV"
|
|||
|
|| node.tagName === "P"
|
|||
|
|| node.tagName === "PRE"
|
|||
|
|| node.tagName === "UL"
|
|||
|
|| node.tagName === "LI"
|
|||
|
) {
|
|||
|
result.push("\n");
|
|||
|
}
|
|||
|
|
|||
|
if (node.tagName === "NOBR") {
|
|||
|
result.push(CLOSING_SPACE);
|
|||
|
}
|
|||
|
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
const isSpecial = function (c) {
|
|||
|
return c === ',' || c === '.' || c === ';' || c === ')' || c === ' ';
|
|||
|
}
|
|||
|
|
|||
|
const convertStatementToText = function(statmentNode) {
|
|||
|
const text = nodeToText(statmentNode, false).join("").replace(/ +/g, " ").replace(/\n\n+/g, "\n\n");
|
|||
|
let result = [];
|
|||
|
for (let i = 0; i < text.length; i++) {
|
|||
|
const c = text.charAt(i);
|
|||
|
if (c === OPENING_SPACE) {
|
|||
|
if (!((i > 0 && text.charAt(i - 1) === '(') || (result.length > 0 && result[result.length - 1] === ' '))) {
|
|||
|
result.push('+');
|
|||
|
}
|
|||
|
} else if (c === CLOSING_SPACE) {
|
|||
|
if (!(i + 1 < text.length && isSpecial(text.charAt(i + 1)))) {
|
|||
|
result.push('-');
|
|||
|
}
|
|||
|
} else {
|
|||
|
result.push(c);
|
|||
|
}
|
|||
|
}
|
|||
|
return result.join("").split("\n").map(value => value.trim()).join("\n");
|
|||
|
};
|
|||
|
</script>
|
|||
|
<div class="diff-popup">
|
|||
|
</div>
|
|||
|
|
|||
|
<div class="problemindexholder" problemindex="A" data-uuid="ps_a01dc42c239b7c3fb8d49626ef753bca0c573680">
|
|||
|
<div style="display: none; margin:1em 0;text-align: center; position: relative;" class="alert alert-info diff-notifier">
|
|||
|
<div>The problem statement has recently been changed. <a class="view-changes" href="#">View the changes.</a></div>
|
|||
|
<span class="diff-notifier-close" style="position: absolute; top: 0.2em; right: 0.3em; cursor: pointer; font-size: 1.4em;">×</span>
|
|||
|
</div>
|
|||
|
<div class="ttypography"><div class="problem-statement"><div class="header"><div class="title">A. Love Story</div><div class="time-limit"><div class="property-title">time limit per test</div>1 second</div><div class="memory-limit"><div class="property-title">memory limit per test</div>256 megabytes</div><div class="input-file"><div class="property-title">input</div>standard input</div><div class="output-file"><div class="property-title">output</div>standard output</div></div><div><p>Timur loves codeforces. That's why he has a string $$$s$$$ having length $$$10$$$ made containing only lowercase Latin letters. Timur wants to know how many indices string $$$s$$$ <span class="tex-font-style-bf">differs</span> from the string "<span class="tex-font-style-tt">codeforces</span>".</p><p>For example string $$$s =$$$ "<span class="tex-font-style-tt">co<span class="tex-font-style-bf">ol</span>for<span class="tex-font-style-bf">s</span>e<span class="tex-font-style-bf">z</span></span>" differs from "<span class="tex-font-style-tt">codeforces</span>" in $$$4$$$ indices, shown in bold.</p><p>Help Timur by finding the number of indices where string $$$s$$$ differs from "<span class="tex-font-style-tt">codeforces</span>".</p><p>Note that you can't reorder the characters in the string $$$s$$$.</p></div><div class="input-specification"><div class="section-title">Input</div><p>The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases.</p><p>Each test case is one line and contains the string $$$s$$$, consisting of exactly $$$10$$$ lowercase Latin characters.</p></div><div class="output-specification"><div class="section-title">Output</div><p>For each test case, output a single integer — the number of indices where string $$$s$$$ differs.</p></div><div class="sample-tests"><div class="section-title">Example</div><div class="sample-test"><div class="input"><div class="title">Input</div><pre><div class="test-example-line test-example-line-even test-example-line-0">5</div><div class="test-example-line test-example-line-odd test-example-line-1">coolforsez</div><div class="test-example-line test-example-line-even test-example-line-2">cadafurcie</div><div class="test-example-line test-example-line-odd test-example-line-3">codeforces</div><div class="test-example-line test-example-line-even test-example-line-4">paiuforces</div><div class="test-example-line test-example-line-odd test-example-line-5">forcescode</div></pre></div><div class="output"><div class="title">Output</div><pre>4
|
|||
|
5
|
|||
|
0
|
|||
|
4
|
|||
|
9
|
|||
|
</pre></div></div></div></div><p> </p></div>
|
|||
|
</div>
|
|||
|
|
|||
|
<script>
|
|||
|
$(function () {
|
|||
|
Codeforces.addMathJaxListener(function () {
|
|||
|
let $problem = $("div[problemindex=A]");
|
|||
|
let uuid = $problem.attr("data-uuid");
|
|||
|
let statementText = convertStatementToText($problem.find(".ttypography").get(0));
|
|||
|
|
|||
|
let previousStatementText = Codeforces.getFromStorage(uuid);
|
|||
|
if (previousStatementText) {
|
|||
|
if (previousStatementText !== statementText) {
|
|||
|
$problem.find(".diff-notifier").show();
|
|||
|
|
|||
|
$problem.find(".diff-notifier-close").click(function() {
|
|||
|
Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
|
|||
|
$problem.find(".diff-notifier").hide();
|
|||
|
});
|
|||
|
|
|||
|
$problem.find("a.view-changes").click(function() {
|
|||
|
$.post("/data/diff", {action: "getDiff", a: previousStatementText, b: statementText}, function (result) {
|
|||
|
if (result["success"] === "true") {
|
|||
|
Codeforces.facebox(".diff-popup", "//codeforces.org/s/98536");
|
|||
|
$("#facebox .diff-popup").html(result["diff"]);
|
|||
|
}
|
|||
|
}, "json");
|
|||
|
});
|
|||
|
}
|
|||
|
} else {
|
|||
|
Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
</script>
|
|||
|
|
|||
|
|
|||
|
<script type="text/javascript">
|
|||
|
$(document).ready(function () {
|
|||
|
window.changedTests = new Set();
|
|||
|
|
|||
|
function endsWith(string, suffix) {
|
|||
|
return string.indexOf(suffix, string.length - suffix.length) !== -1;
|
|||
|
}
|
|||
|
|
|||
|
const inputFileDiv = $("div.input-file");
|
|||
|
const inputFile = inputFileDiv.text();
|
|||
|
const outputFileDiv = $("div.output-file");
|
|||
|
const outputFile = outputFileDiv.text();
|
|||
|
|
|||
|
|
|||
|
if (!endsWith(inputFile, "standard input")
|
|||
|
&& !endsWith(inputFile, "standard input")) {
|
|||
|
inputFileDiv.attr("style", "font-weight: bold");
|
|||
|
}
|
|||
|
|
|||
|
if (!endsWith(outputFile, "standard output")
|
|||
|
&& !endsWith(outputFile, "standard output")) {
|
|||
|
outputFileDiv.attr("style", "font-weight: bold");
|
|||
|
}
|
|||
|
|
|||
|
const titleDiv = $("div.header div.title");
|
|||
|
|
|||
|
|
|||
|
|
|||
|
String.prototype.replaceAll = function (search, replace) {
|
|||
|
return this.split(search).join(replace);
|
|||
|
};
|
|||
|
|
|||
|
$(".sample-test .title").each(function () {
|
|||
|
const preId = ("id" + Math.random()).replaceAll(".", "0");
|
|||
|
const cpyId = ("id" + Math.random()).replaceAll(".", "0");
|
|||
|
|
|||
|
$(this).parent().find("pre").attr("id", preId);
|
|||
|
const $copy = $("<div title='Copy' data-clipboard-target='#" + preId + "' id='" + cpyId + "' class='input-output-copier'>Copy</div>");
|
|||
|
$(this).append($copy);
|
|||
|
|
|||
|
const clipboard = new Clipboard('#' + cpyId, {
|
|||
|
text: function (trigger) {
|
|||
|
const pre = document.querySelector('#' + preId);
|
|||
|
const lines = pre.querySelectorAll(".test-example-line");
|
|||
|
return Codeforces.filterClipboardText(pre.innerText, lines.length);
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
const isInput = $(this).parent().hasClass("input");
|
|||
|
|
|||
|
clipboard.on('success', function (e) {
|
|||
|
if (isInput) {
|
|||
|
Codeforces.showMessage("The example input has been copied into the clipboard");
|
|||
|
} else {
|
|||
|
Codeforces.showMessage("The example output has been copied into the clipboard");
|
|||
|
}
|
|||
|
e.clearSelection();
|
|||
|
});
|
|||
|
});
|
|||
|
|
|||
|
$(".test-form-item input").change(function () {
|
|||
|
addPendingSubmissionMessage($($(this).closest("form")), "You changed the answer, do not forget to submit it if you want to save the changes");
|
|||
|
const index = $(this).closest(".problemindexholder").attr("problemindex");
|
|||
|
let test = "";
|
|||
|
$(this).closest("form input").each(function () {
|
|||
|
const test_ = $(this).attr("name");
|
|||
|
if (test_ && test_.substring(0, 4) === "test") {
|
|||
|
test = test_;
|
|||
|
}
|
|||
|
});
|
|||
|
if (index.length > 0 && test.length > 0) {
|
|||
|
const indexTest = index + "::" + test;
|
|||
|
window.changedTests.add(indexTest);
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
$(window).on('beforeunload', function () {
|
|||
|
if (window.changedTests.size > 0) {
|
|||
|
return 'Dialog text here';
|
|||
|
}
|
|||
|
});
|
|||
|
|
|||
|
autosize($('.test-explanation textarea'));
|
|||
|
|
|||
|
$(".test-example-line").hover(function() {
|
|||
|
$(this).attr("class").split(" ").forEach((clazz) => {
|
|||
|
if (clazz.substr(0, "test-example-line-".length) === "test-example-line-") {
|
|||
|
let end = clazz.substr("test-example-line-".length);
|
|||
|
if (end !== "even" && end !== "odd" && end !== "0") {
|
|||
|
let top = 1E20;
|
|||
|
let left = 1E20;
|
|||
|
let problem = $(this).closest(".problemindexholder");
|
|||
|
$(this).closest(".input").find("." + clazz).css("background-color", "#FFFDE7").each(function() {
|
|||
|
top = Math.min(top, $(this).offset().top);
|
|||
|
left = Math.min(left, $(this).offset().left);
|
|||
|
});
|
|||
|
let testCaseMarker = problem.find(".testCaseMarker_" + end);
|
|||
|
if (testCaseMarker.length === 0) {
|
|||
|
const html = "<div class=\"testCaseMarker testCaseMarker_" + end + " notice\"></div>";
|
|||
|
problem.append($(html));
|
|||
|
testCaseMarker = problem.find(".testCaseMarker_" + end);
|
|||
|
}
|
|||
|
if (testCaseMarker) {
|
|||
|
testCaseMarker.show()
|
|||
|
.offset({top, left: left - 20})
|
|||
|
.text(end);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
}, function() {
|
|||
|
$(this).attr("class").split(" ").forEach((clazz) => {
|
|||
|
if (clazz.substr(0, "test-example-line-".length) === "test-example-line-") {
|
|||
|
let end = clazz.substr("test-example-line-".length);
|
|||
|
if (end !== "even" && end !== "odd" && end !== "0") {
|
|||
|
$("." + clazz).css("background-color", "");
|
|||
|
$(this).closest(".problemindexholder").find(".testCaseMarker_" + end).hide();
|
|||
|
}
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
|
|||
|
});
|
|||
|
</script>
|
|||
|
</div>
|
|||
|
<div
|
|||
|
style="margin-bottom: 2em;"
|
|||
|
>
|
|||
|
|
|||
|
|
|||
|
<div class="problemindexholder" problemindex="B" data-uuid="ps_8fea890aeb1ab9751af32ed2e8e2557a851d4e2f">
|
|||
|
<div style="display: none; margin:1em 0;text-align: center; position: relative;" class="alert alert-info diff-notifier">
|
|||
|
<div>The problem statement has recently been changed. <a class="view-changes" href="#">View the changes.</a></div>
|
|||
|
<span class="diff-notifier-close" style="position: absolute; top: 0.2em; right: 0.3em; cursor: pointer; font-size: 1.4em;">×</span>
|
|||
|
</div>
|
|||
|
<div class="ttypography"><div class="problem-statement"><div class="header"><div class="title">B. Blank Space</div><div class="time-limit"><div class="property-title">time limit per test</div>1 second</div><div class="memory-limit"><div class="property-title">memory limit per test</div>256 megabytes</div><div class="input-file"><div class="property-title">input</div>standard input</div><div class="output-file"><div class="property-title">output</div>standard output</div></div><div><p>You are given a binary array $$$a$$$ of $$$n$$$ elements, a binary array is an array consisting only of $$$0$$$s and $$$1$$$s. </p><p>A blank space is a segment of <span class="tex-font-style-bf">consecutive</span> elements consisting of only $$$0$$$s. </p><p>Your task is to find the length of the longest blank space.</p></div><div class="input-specification"><div class="section-title">Input</div><p>The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases.</p><p>The first line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 100$$$) — the length of the array.</p><p>The second line of each test case contains $$$n$$$ space-separated integers $$$a_i$$$ ($$$0 \leq a_i \leq 1$$$) — the elements of the array.</p></div><div class="output-specification"><div class="section-title">Output</div><p>For each test case, output a single integer — the length of the longest blank space.</p></div><div class="sample-tests"><div class="section-title">Example</div><div class="sample-test"><div class="input"><div class="title">Input</div><pre><div class="test-example-line test-example-line-even test-example-line-0">5</div><div class="test-example-line test-example-line-odd test-example-line-1">5</div><div class="test-example-line test-example-line-odd test-example-line-1">1 0 0 1 0</div><div class="test-example-line test-example-line-even test-example-line-2">4</div><div class="test-example-line test-example-line-even test-example-line-2">0 1 1 1</div><div class="test-example-line test-example-line-odd test-example-line-3">1</div><div class="test-example-line test-example-line-odd test-example-line-3">0</div><div class="test-example-line test-example-line-even test-example-line-4">3</div><div class="test-example-line test-example-line-even test-example-line-4">1 1 1</div><div class="test-example-line test-example-line-odd test-example-line-5">9</div><div class="test-example-line test-example-line-odd test-example-line-5">1 0 0 0 1 0 0 0 1</div></pre></div><div class="output"><div class="title">Output</div><pre>2
|
|||
|
1
|
|||
|
1
|
|||
|
0
|
|||
|
3
|
|||
|
</pre></div></div></div></div><p> </p></div>
|
|||
|
</div>
|
|||
|
|
|||
|
<script>
|
|||
|
$(function () {
|
|||
|
Codeforces.addMathJaxListener(function () {
|
|||
|
let $problem = $("div[problemindex=B]");
|
|||
|
let uuid = $problem.attr("data-uuid");
|
|||
|
let statementText = convertStatementToText($problem.find(".ttypography").get(0));
|
|||
|
|
|||
|
let previousStatementText = Codeforces.getFromStorage(uuid);
|
|||
|
if (previousStatementText) {
|
|||
|
if (previousStatementText !== statementText) {
|
|||
|
$problem.find(".diff-notifier").show();
|
|||
|
|
|||
|
$problem.find(".diff-notifier-close").click(function() {
|
|||
|
Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
|
|||
|
$problem.find(".diff-notifier").hide();
|
|||
|
});
|
|||
|
|
|||
|
$problem.find("a.view-changes").click(function() {
|
|||
|
$.post("/data/diff", {action: "getDiff", a: previousStatementText, b: statementText}, function (result) {
|
|||
|
if (result["success"] === "true") {
|
|||
|
Codeforces.facebox(".diff-popup", "//codeforces.org/s/98536");
|
|||
|
$("#facebox .diff-popup").html(result["diff"]);
|
|||
|
}
|
|||
|
}, "json");
|
|||
|
});
|
|||
|
}
|
|||
|
} else {
|
|||
|
Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
</script>
|
|||
|
|
|||
|
|
|||
|
<script type="text/javascript">
|
|||
|
$(document).ready(function () {
|
|||
|
|
|||
|
function endsWith(string, suffix) {
|
|||
|
return string.indexOf(suffix, string.length - suffix.length) !== -1;
|
|||
|
}
|
|||
|
|
|||
|
const inputFileDiv = $("div.input-file");
|
|||
|
const inputFile = inputFileDiv.text();
|
|||
|
const outputFileDiv = $("div.output-file");
|
|||
|
const outputFile = outputFileDiv.text();
|
|||
|
|
|||
|
|
|||
|
if (!endsWith(inputFile, "standard input")
|
|||
|
&& !endsWith(inputFile, "standard input")) {
|
|||
|
inputFileDiv.attr("style", "font-weight: bold");
|
|||
|
}
|
|||
|
|
|||
|
if (!endsWith(outputFile, "standard output")
|
|||
|
&& !endsWith(outputFile, "standard output")) {
|
|||
|
outputFileDiv.attr("style", "font-weight: bold");
|
|||
|
}
|
|||
|
|
|||
|
const titleDiv = $("div.header div.title");
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
});
|
|||
|
</script>
|
|||
|
</div>
|
|||
|
<div
|
|||
|
style="margin-bottom: 2em;"
|
|||
|
>
|
|||
|
|
|||
|
|
|||
|
<div class="problemindexholder" problemindex="C" data-uuid="ps_0d2acb7158224a0a4c286e2b6b04b72e75f84ded">
|
|||
|
<div style="display: none; margin:1em 0;text-align: center; position: relative;" class="alert alert-info diff-notifier">
|
|||
|
<div>The problem statement has recently been changed. <a class="view-changes" href="#">View the changes.</a></div>
|
|||
|
<span class="diff-notifier-close" style="position: absolute; top: 0.2em; right: 0.3em; cursor: pointer; font-size: 1.4em;">×</span>
|
|||
|
</div>
|
|||
|
<div class="ttypography"><div class="problem-statement"><div class="header"><div class="title">C. Mr. Perfectly Fine</div><div class="time-limit"><div class="property-title">time limit per test</div>2 seconds</div><div class="memory-limit"><div class="property-title">memory limit per test</div>256 megabytes</div><div class="input-file"><div class="property-title">input</div>standard input</div><div class="output-file"><div class="property-title">output</div>standard output</div></div><div><p>Victor wants to become "<span class="tex-font-style-it">Mr. Perfectly Fine</span>". For that, he needs to acquire a certain set of skills. More precisely, he has $$$2$$$ skills he needs to acquire. </p><p>Victor has $$$n$$$ books. Reading book $$$i$$$ takes him $$$m_i$$$ minutes and will give him some (possibly none) of the required two skills, represented by a binary string of length $$$2$$$.</p><p>What is the minimum amount of time required so that Victor acquires all of the two skills? </p></div><div class="input-specification"><div class="section-title">Input</div><p>The input consists of multiple test cases. The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. The description of the test cases follows.</p><p>The first line of each test case contains an integer $$$n$$$ ($$$1 \leq n \leq 2 \cdot 10^5$$$) — the number of books available.</p><p>Then $$$n$$$ lines follow. Line $$$i$$$ contains a positive integer $$$m_i$$$ ($$$1 \leq m_i \leq 2 \cdot 10^5$$$) and a binary string of length $$$2$$$, where $$$s_{i1} = 1$$$ if reading book $$$i$$$ acquires Victor skill $$$1$$$, and $$$s_{i1} = 0$$$ otherwise, and $$$s_{i2} = 1$$$ if reading book $$$i$$$ acquires Victor skill $$$2$$$, and $$$s_{i2} = 0$$$ otherwise.</p><p>It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.</p></div><div class="output-specification"><div class="section-title">Output</div><p>For each test case, output a single integer denoting the minimum amount of minutes required for Victor to obtain both needed skills and $$$-1$$$ in case it's impossible to obtain the two skills after reading any amount of books. </p></div><div class="sample-tests"><div class="section-title">Example</div><div class="sample-test"><div class="input"><div class="title">Input</div><pre><div class="test-example-line test-example-line-even test-example-line-0">6</div><div class="test-example-line test-example-line-odd test-example-line-1">4</div><div class="test-example-line test-example-line-odd test-example-line-1">2 00</div><div class="test-example-line test-example-line-odd test-example-line-1">3 10</div><div class="test-example-line test-example-line-odd test-example-line-1">4 01</div><div class="test-example-line test-example-line-odd test-example-line-1">4 00</div><div class="test-example-line test-example-line-even test-example-line-2">5</div><div class="test-example-line test-example-line-even test-example-line-2">3 01</div><div class="test-example-line test-example-line-even test-example-line-2">3 01</div><div class="test-example-line test-example-line-even test-example-line-2">5 01</div><div class="test-example-line test-example-line-even test-example-line-2">2 10</div><div class="test-example-line test-example-line-even test-example-line-2">9 10</div><div class="test-example-line test-example-line-odd test-example-line-3">1</div><div class="test-example-line test-example-line-odd test-example-line-3">5 11</div><div class="test-example-line test-example-line-even test-example-line-4">3</div><div class="test-example-line test-example-line-even test-example-line-4">9 11</div><div class="test-example-line test-example-line-even test-example-line-4">8 01</div><div class="test-example-line test-example-line-even test-example-line-4">7 10</div><div class="test-example-line test-example-line-odd test-example-line-5">6</div><div class="test-example-line test-example-line-odd test-example-line-5">4 01</div><div class="test-example-line test-example-line-odd test-example-line-5">6
|
|||
|
5
|
|||
|
5
|
|||
|
9
|
|||
|
-1
|
|||
|
8
|
|||
|
</pre></div></div></div><div class="note"><div class="section-title">Note</div><p>In the first test case, we can use books $$$2$$$ and $$$3$$$, with a total amount of minutes spent equal to $$$3 + 4 = 7$$$.</p><p>In the second test case, we can use the books $$$1$$$ and $$$4$$$, with a total amount of minutes spent equal to $$$3 + 2 = 5$$$.</p><p>In the third test case, we have only one option and that is reading book $$$1$$$ for a total amount of minutes spent equal to $$$5$$$.</p></div></div><p> </p></div>
|
|||
|
</div>
|
|||
|
|
|||
|
<script>
|
|||
|
$(function () {
|
|||
|
Codeforces.addMathJaxListener(function () {
|
|||
|
let $problem = $("div[problemindex=C]");
|
|||
|
let uuid = $problem.attr("data-uuid");
|
|||
|
let statementText = convertStatementToText($problem.find(".ttypography").get(0));
|
|||
|
|
|||
|
let previousStatementText = Codeforces.getFromStorage(uuid);
|
|||
|
if (previousStatementText) {
|
|||
|
if (previousStatementText !== statementText) {
|
|||
|
$problem.find(".diff-notifier").show();
|
|||
|
|
|||
|
$problem.find(".diff-notifier-close").click(function() {
|
|||
|
Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
|
|||
|
$problem.find(".diff-notifier").hide();
|
|||
|
});
|
|||
|
|
|||
|
$problem.find("a.view-changes").click(function() {
|
|||
|
$.post("/data/diff", {action: "getDiff", a: previousStatementText, b: statementText}, function (result) {
|
|||
|
if (result["success"] === "true") {
|
|||
|
Codeforces.facebox(".diff-popup", "//codeforces.org/s/98536");
|
|||
|
$("#facebox .diff-popup").html(result["diff"]);
|
|||
|
}
|
|||
|
}, "json");
|
|||
|
});
|
|||
|
}
|
|||
|
} else {
|
|||
|
Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
</script>
|
|||
|
|
|||
|
|
|||
|
<script type="text/javascript">
|
|||
|
$(document).ready(function () {
|
|||
|
|
|||
|
function endsWith(string, suffix) {
|
|||
|
return string.indexOf(suffix, string.length - suffix.length) !== -1;
|
|||
|
}
|
|||
|
|
|||
|
const inputFileDiv = $("div.input-file");
|
|||
|
const inputFile = inputFileDiv.text();
|
|||
|
const outputFileDiv = $("div.output-file");
|
|||
|
const outputFile = outputFileDiv.text();
|
|||
|
|
|||
|
|
|||
|
if (!endsWith(inputFile, "standard input")
|
|||
|
&& !endsWith(inputFile, "standard input")) {
|
|||
|
inputFileDiv.attr("style", "font-weight: bold");
|
|||
|
}
|
|||
|
|
|||
|
if (!endsWith(outputFile, "standard output")
|
|||
|
&& !endsWith(outputFile, "standard output")) {
|
|||
|
outputFileDiv.attr("style", "font-weight: bold");
|
|||
|
}
|
|||
|
|
|||
|
const titleDiv = $("div.header div.title");
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
});
|
|||
|
</script>
|
|||
|
</div>
|
|||
|
<div
|
|||
|
style="margin-bottom: 2em;"
|
|||
|
>
|
|||
|
|
|||
|
|
|||
|
<div class="problemindexholder" problemindex="D" data-uuid="ps_6ef7f67ca94e5b78a4675d7155c96fce9e92a8e4">
|
|||
|
<div style="display: none; margin:1em 0;text-align: center; position: relative;" class="alert alert-info diff-notifier">
|
|||
|
<div>The problem statement has recently been changed. <a class="view-changes" href="#">View the changes.</a></div>
|
|||
|
<span class="diff-notifier-close" style="position: absolute; top: 0.2em; right: 0.3em; cursor: pointer; font-size: 1.4em;">×</span>
|
|||
|
</div>
|
|||
|
<div class="ttypography"><div class="problem-statement"><div class="header"><div class="title">D. Gold Rush</div><div class="time-limit"><div class="property-title">time limit per test</div>2 seconds</div><div class="memory-limit"><div class="property-title">memory limit per test</div>256 megabytes</div><div class="input-file"><div class="property-title">input</div>standard input</div><div class="output-file"><div class="property-title">output</div>standard output</div></div><div><p>Initially you have a single pile with $$$n$$$ gold nuggets. In an operation you can do the following: </p><ul> <li> Take any pile and split it into two piles, so that one of the resulting piles has exactly twice as many gold nuggets as the other. (All piles should have an integer number of nuggets.) </li></ul> <center> <img class="tex-graphics" src="https://espresso.codeforces.com/723dd5ce328f1a04932ecf7a71a71f198294eaa3.png" style="max-width: 100.0%;max-height: 100.0%;" /><p><span class="tex-font-size-small">One possible move is to take a pile of size $$$6$$$ and split it into piles of sizes $$$2$$$ and $$$4$$$, which is valid since $$$4$$$ is twice as large as $$$2$$$.</span> </p></center> Can you make a pile with <span class="tex-font-style-bf">exactly</span> $$$m$$$ gold nuggets using zero or more operations?</div><div class="input-specification"><div class="section-title">Input</div><p>The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases.</p><p>The only line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 10^7$$$) — the starting and target pile sizes, respectively.</p></div><div class="output-specification"><div class="section-title">Output</div><p>For each test case, output "<span class="tex-font-style-tt">YES</span>" if you can make a pile of size exactly $$$m$$$, and "<span class="tex-font-style-tt">NO</span>" otherwise.</p><p>You can output the answer in any case (for example, the strings "<span class="tex-font-style-tt">yEs</span>", "<span class="tex-font-style-tt">yes</span>", "<span class="tex-font-style-tt">Yes</span>" and "<span class="tex-font-style-tt">YES</span>" will be recognized as a positive answer).</p></div><div class="sample-tests"><div class="section-title">Example</div><div class="sample-test"><div class="input"><div class="title">Input</div><pre><div class="test-example-line test-example-line-even test-example-line-0">11</div><div class="test-example-line test-example-line-odd test-example-line-1">6 4</div><div class="test-example-line test-example-line-even test-example-line-2">9 4</div><div class="test-example-line test-example-line-odd test-example-line-3">4 2</div><div class="test-example-line test-example-line-even test-example-line-4">18 27</div><div class="test-example-line test-example-line-odd test-example-line-5">27 4</div><div class="test-example-line test-example-line-even test-example-line-6">27 2</div><div class="test-example-line test-example-line-odd test-example-line-7">27 10</div><div class="test-example-line test-example-line-even test-example-line-8">1 1</div><div class="test-example-line test-example-line-odd test-example-line-9">3 1</div><div class="test-example-line test-example-line-even test-example-line-10">5 1</div><div class="test-example-line test-example-line-odd test-example-line-11">746001 2984004</div></pre></div><div class="output"><div class="title">Output</div><pre>YES
|
|||
|
YES
|
|||
|
NO
|
|||
|
NO
|
|||
|
YES
|
|||
|
YES
|
|||
|
NO
|
|||
|
YES
|
|||
|
YES
|
|||
|
NO
|
|||
|
NO
|
|||
|
</pre></div></div></div><div class="note"><div class="section-title">Note</div><p>The first test case is pictured in the statement. We can make a pile of size $$$4$$$.</p><p>In the second test case, we can perform the following operations: $$$\{\color{red}{9}\} \to \{\color{red}{6},3\} \to \{4,2,3\}$$$. The pile that is split apart is colored red before each operation.</p><p>In the third test case, we can't perform a single operation.</p><p>In the fourth test case, we can't end up with a larger pile than we started with.</p></div></div><p> </p></div>
|
|||
|
</div>
|
|||
|
|
|||
|
<script>
|
|||
|
$(function () {
|
|||
|
Codeforces.addMathJaxListener(function () {
|
|||
|
let $problem = $("div[problemindex=D]");
|
|||
|
let uuid = $problem.attr("data-uuid");
|
|||
|
let statementText = convertStatementToText($problem.find(".ttypography").get(0));
|
|||
|
|
|||
|
let previousStatementText = Codeforces.getFromStorage(uuid);
|
|||
|
if (previousStatementText) {
|
|||
|
if (previousStatementText !== statementText) {
|
|||
|
$problem.find(".diff-notifier").show();
|
|||
|
|
|||
|
$problem.find(".diff-notifier-close").click(function() {
|
|||
|
Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
|
|||
|
$problem.find(".diff-notifier").hide();
|
|||
|
});
|
|||
|
|
|||
|
$problem.find("a.view-changes").click(function() {
|
|||
|
$.post("/data/diff", {action: "getDiff", a: previousStatementText, b: statementText}, function (result) {
|
|||
|
if (result["success"] === "true") {
|
|||
|
Codeforces.facebox(".diff-popup", "//codeforces.org/s/98536");
|
|||
|
$("#facebox .diff-popup").html(result["diff"]);
|
|||
|
}
|
|||
|
}, "json");
|
|||
|
});
|
|||
|
}
|
|||
|
} else {
|
|||
|
Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
</script>
|
|||
|
|
|||
|
|
|||
|
<script type="text/javascript">
|
|||
|
$(document).ready(function () {
|
|||
|
|
|||
|
function endsWith(string, suffix) {
|
|||
|
return string.indexOf(suffix, string.length - suffix.length) !== -1;
|
|||
|
}
|
|||
|
|
|||
|
const inputFileDiv = $("div.input-file");
|
|||
|
const inputFile = inputFileDiv.text();
|
|||
|
const outputFileDiv = $("div.output-file");
|
|||
|
const outputFile = outputFileDiv.text();
|
|||
|
|
|||
|
|
|||
|
if (!endsWith(inputFile, "standard input")
|
|||
|
&& !endsWith(inputFile, "standard input")) {
|
|||
|
inputFileDiv.attr("style", "font-weight: bold");
|
|||
|
}
|
|||
|
|
|||
|
if (!endsWith(outputFile, "standard output")
|
|||
|
&& !endsWith(outputFile, "standard output")) {
|
|||
|
outputFileDiv.attr("style", "font-weight: bold");
|
|||
|
}
|
|||
|
|
|||
|
const titleDiv = $("div.header div.title");
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
});
|
|||
|
</script>
|
|||
|
</div>
|
|||
|
<div
|
|||
|
style="margin-bottom: 2em;"
|
|||
|
>
|
|||
|
|
|||
|
|
|||
|
<div class="problemindexholder" problemindex="E" data-uuid="ps_ad03a4dd2df3b94d6fca955c1c92dc79a2e856df">
|
|||
|
<div style="display: none; margin:1em 0;text-align: center; position: relative;" class="alert alert-info diff-notifier">
|
|||
|
<div>The problem statement has recently been changed. <a class="view-changes" href="#">View the changes.</a></div>
|
|||
|
<span class="diff-notifier-close" style="position: absolute; top: 0.2em; right: 0.3em; cursor: pointer; font-size: 1.4em;">×</span>
|
|||
|
</div>
|
|||
|
<div class="ttypography"><div class="problem-statement"><div class="header"><div class="title">E. The Lakes</div><div class="time-limit"><div class="property-title">time limit per test</div>3 seconds</div><div class="memory-limit"><div class="property-title">memory limit per test</div>256 megabytes</div><div class="input-file"><div class="property-title">input</div>standard input</div><div class="output-file"><div class="property-title">output</div>standard output</div></div><div><p>You are given an $$$n \times m$$$ grid $$$a$$$ of non-negative integers. The value $$$a_{i,j}$$$ represents the depth of water at the $$$i$$$-th row and $$$j$$$-th column. </p><p>A lake is a set of cells such that:</p><ul> <li> each cell in the set has $$$a_{i,j} > 0$$$, and </li><li> there exists a path between any pair of cells in the lake by going up, down, left, or right a number of times and without stepping on a cell with $$$a_{i,j} = 0$$$. </li></ul><p>The volume of a lake is the sum of depths of all the cells in the lake.</p><p>Find the largest volume of a lake in the grid.</p></div><div class="input-specification"><div class="section-title">Input</div><p>The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 10^4$$$) — the number of test cases.</p><p>The first line of each test case contains two integers $$$n, m$$$ ($$$1 \leq n, m \leq 1000$$$) — the number of rows and columns of the grid, respectively.</p><p>Then $$$n$$$ lines follow each with $$$m$$$ integers $$$a_{i,j}$$$ ($$$0 \leq a_{i,j} \leq 1000$$$) — the depth of the water at each cell.</p><p>It is guaranteed that the sum of $$$n \cdot m$$$ over all test cases does not exceed $$$10^6$$$.</p></div><div class="output-specification"><div class="section-title">Output</div><p>For each test case, output a single integer — the largest volume of a lake in the grid.</p></div><div class="sample-tests"><div class="section-title">Example</div><div class="sample-test"><div class="input"><div class="title">Input</div><pre><div class="test-example-line test-example-line-even test-example-line-0">5</div><div class="test-example-line test-example-line-odd test-example-line-1">3 3</div><div class="test-example-line test-example-line-odd test-example-line-1">1 2 0</div><div class="test-example-line test-example-line-odd test-example-line-1">3 4 0</div><div class="test-example-line test-example-line-odd test-example-line-1">0 0 5</div><div class="test-example-line test-example-line-even test-example-line-2">1 1</div><div class="test-example-line test-example-line-even test-example-line-2">0</div><div class="test-example-line test-example-line-odd test-example-line-3">3 3</div><div class="test-example-line test-example-line-odd test-example-line-3">0 1 1</div><div class="test-example-line test-example-line-odd test-example-line-3">1 0 1</div><div class="test-example-line test-example-line-odd test-example-line-3">1 1 1</div><div class="test-example-line test-example-line-even test-example-line-4">5 5</div><div class="test-example-line test-example-line-even test-example-line-4">1 1 1 1 1</div><div class="test-example-line test-example-line-even test-example-line-4">1 0 0 0 1</div><div class="test-example-line test-example-line-even test-example-line-4">1 0 5 0 1</div><div class="test-example-line test-example-line-even test-example-line-4">1 0 0 0 1</div><div class="test-example-line test-example-line-even test-example-line-4">1 1 1 1 1</div><div class="test-example-line test-example-line-odd test-example-line-5">5 5</div><div class="test-example-line test-example-line-odd test-example-line-5">1 1 1 1 1</div><div class="test-example-line test-example-line-odd test-example-line-5">1 0 0 0 1</div><div class="test-example-line test-example-line-odd test-example-line-5">1 1 4 0 1</div><div class="test-example-line test-example-line-odd test-example-line-5">1 0 0 0 1</div><div class="test-example-line test-example-line-odd test-example-line-5">1 1 1 1 1</div></pre></div><div class="output"><div class="title">Output</div><pre>10
|
|||
|
0
|
|||
|
7
|
|||
|
16
|
|||
|
21
|
|||
|
</pre></div></div></div></div><p> </p></div>
|
|||
|
</div>
|
|||
|
|
|||
|
<script>
|
|||
|
$(function () {
|
|||
|
Codeforces.addMathJaxListener(function () {
|
|||
|
let $problem = $("div[problemindex=E]");
|
|||
|
let uuid = $problem.attr("data-uuid");
|
|||
|
let statementText = convertStatementToText($problem.find(".ttypography").get(0));
|
|||
|
|
|||
|
let previousStatementText = Codeforces.getFromStorage(uuid);
|
|||
|
if (previousStatementText) {
|
|||
|
if (previousStatementText !== statementText) {
|
|||
|
$problem.find(".diff-notifier").show();
|
|||
|
|
|||
|
$problem.find(".diff-notifier-close").click(function() {
|
|||
|
Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
|
|||
|
$problem.find(".diff-notifier").hide();
|
|||
|
});
|
|||
|
|
|||
|
$problem.find("a.view-changes").click(function() {
|
|||
|
$.post("/data/diff", {action: "getDiff", a: previousStatementText, b: statementText}, function (result) {
|
|||
|
if (result["success"] === "true") {
|
|||
|
Codeforces.facebox(".diff-popup", "//codeforces.org/s/98536");
|
|||
|
$("#facebox .diff-popup").html(result["diff"]);
|
|||
|
}
|
|||
|
}, "json");
|
|||
|
});
|
|||
|
}
|
|||
|
} else {
|
|||
|
Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
</script>
|
|||
|
|
|||
|
|
|||
|
<script type="text/javascript">
|
|||
|
$(document).ready(function () {
|
|||
|
|
|||
|
function endsWith(string, suffix) {
|
|||
|
return string.indexOf(suffix, string.length - suffix.length) !== -1;
|
|||
|
}
|
|||
|
|
|||
|
const inputFileDiv = $("div.input-file");
|
|||
|
const inputFile = inputFileDiv.text();
|
|||
|
const outputFileDiv = $("div.output-file");
|
|||
|
const outputFile = outputFileDiv.text();
|
|||
|
|
|||
|
|
|||
|
if (!endsWith(inputFile, "standard input")
|
|||
|
&& !endsWith(inputFile, "standard input")) {
|
|||
|
inputFileDiv.attr("style", "font-weight: bold");
|
|||
|
}
|
|||
|
|
|||
|
if (!endsWith(outputFile, "standard output")
|
|||
|
&& !endsWith(outputFile, "standard output")) {
|
|||
|
outputFileDiv.attr("style", "font-weight: bold");
|
|||
|
}
|
|||
|
|
|||
|
const titleDiv = $("div.header div.title");
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
});
|
|||
|
</script>
|
|||
|
</div>
|
|||
|
<div
|
|||
|
style="margin-bottom: 2em;"
|
|||
|
>
|
|||
|
|
|||
|
|
|||
|
<div class="problemindexholder" problemindex="F" data-uuid="ps_8cd8b59d4005b03ded13a6455e781c2550f7c86f">
|
|||
|
<div style="display: none; margin:1em 0;text-align: center; position: relative;" class="alert alert-info diff-notifier">
|
|||
|
<div>The problem statement has recently been changed. <a class="view-changes" href="#">View the changes.</a></div>
|
|||
|
<span class="diff-notifier-close" style="position: absolute; top: 0.2em; right: 0.3em; cursor: pointer; font-size: 1.4em;">×</span>
|
|||
|
</div>
|
|||
|
<div class="ttypography"><div class="problem-statement"><div class="header"><div class="title">F. Forever Winter</div><div class="time-limit"><div class="property-title">time limit per test</div>2 seconds</div><div class="memory-limit"><div class="property-title">memory limit per test</div>256 megabytes</div><div class="input-file"><div class="property-title">input</div>standard input</div><div class="output-file"><div class="property-title">output</div>standard output</div></div><div><p>A <span class="tex-font-style-it">snowflake</span> graph is generated from two integers $$$x$$$ and $$$y$$$, both greater than $$$1$$$, as follows: </p><ul> <li> Start with one central vertex. </li><li> Connect $$$x$$$ new vertices to this central vertex. </li><li> Connect $$$y$$$ new vertices to <span class="tex-font-style-bf">each</span> of these $$$x$$$ vertices. </li></ul> For example, below is a snowflake graph for $$$x=5$$$ and $$$y=3$$$. <center> <img class="tex-graphics" src="https://espresso.codeforces.com/9f2183c62c4c713927bb18746d1f5455da90f612.png" style="max-width: 100.0%;max-height: 100.0%;" /><p><span class="tex-font-size-small">The snowflake graph above has a central vertex $$$15$$$, then $$$x=5$$$ vertices attached to it ($$$3$$$, $$$6$$$, $$$7$$$, $$$8$$$, and $$$20$$$), and then $$$y=3$$$ vertices attached to each of those.</span> </p></center> Given a snowflake graph, determine the values of $$$x$$$ and $$$y$$$.</div><div class="input-specification"><div class="section-title">Input</div><p>The first line contains a single integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases.</p><p>The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$2 \leq n \leq 200$$$; $$$1 \leq m \leq \min\left(1000, \frac{n(n-1)}{2}\right)$$$) — the number of vertices and edges in the graph, respectively.</p><p>The next $$$m$$$ lines each contain two integers each $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq n$$$, $$$u \neq v$$$) — the numbers of vertices connected by an edge. The graph does not contain multiple edges and self-loops.</p><p><span class="tex-font-style-bf">It is guaranteed that this graph is a snowflake graph for some integers $$$x$$$ and $$$y$$$ both greater than $$$1$$$.</span></p></div><div class="output-specification"><div class="section-title">Output</div><p>For each test case, on a separate line output the values of $$$x$$$ and $$$y$$$, in that order, separated by a space.</p></div><div class="sample-tests"><div class="section-title">Example</div><div class="sample-test"><div class="input"><div class="title">Input</div><pre><div class="test-example-line test-example-line-even test-example-line-0">3</div><div class="test-example-line test-example-line-odd test-example-line-1">21 20</div><div class="test-example-line test-example-line-odd test-example-line-1">21 20</div><div class="test-example-line test-example-line-odd test-example-line-1">5 20</div><div class="test-example-line test-example-line-odd test-example-line-1">13 20</div><div class="test-example-line test-example-line-odd test-example-line-1">1 3</div><div class="test-example-line test-example-line-odd test-example-line-1">11 3</div><div class="test-example-line test-example-line-odd test-example-line-1">10 3</div><div class="test-example-line test-example-line-odd test-example-line-1">4 8</div><div class="test-example-line test-example-line-odd test-example-line-1">19 8</div><div class="test-example-line test-example-line-odd test-example-line-1">14 8</div><div class="test-example-line test-example-line-odd test-example-line-1">9 7</div><div class="test-example-line test-example-line-odd test-example-line-1">12 7</div><div class="test-example-line test-example-line-odd test-example-line-1">17 7</div><div class="test-example-line test-example-line-odd test-example-line-1">18 6</div><div class="test-example-line test-example-line-odd test-example-line-1">16 6</div><div class="test-example-line test-example-line-odd test-example-line-1">2 6</div><div class="test-example-line test-example-line-odd test-example-li
|
|||
|
2 2
|
|||
|
2 3
|
|||
|
</pre></div></div></div><div class="note"><div class="section-title">Note</div><p>The first test case is pictured in the statement. Note that the output <span class="tex-font-style-tt">3 5</span> is <span class="tex-font-style-bf">incorrect</span>, since $$$x$$$ should be output before $$$y$$$.</p></div></div><p> </p></div>
|
|||
|
</div>
|
|||
|
|
|||
|
<script>
|
|||
|
$(function () {
|
|||
|
Codeforces.addMathJaxListener(function () {
|
|||
|
let $problem = $("div[problemindex=F]");
|
|||
|
let uuid = $problem.attr("data-uuid");
|
|||
|
let statementText = convertStatementToText($problem.find(".ttypography").get(0));
|
|||
|
|
|||
|
let previousStatementText = Codeforces.getFromStorage(uuid);
|
|||
|
if (previousStatementText) {
|
|||
|
if (previousStatementText !== statementText) {
|
|||
|
$problem.find(".diff-notifier").show();
|
|||
|
|
|||
|
$problem.find(".diff-notifier-close").click(function() {
|
|||
|
Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
|
|||
|
$problem.find(".diff-notifier").hide();
|
|||
|
});
|
|||
|
|
|||
|
$problem.find("a.view-changes").click(function() {
|
|||
|
$.post("/data/diff", {action: "getDiff", a: previousStatementText, b: statementText}, function (result) {
|
|||
|
if (result["success"] === "true") {
|
|||
|
Codeforces.facebox(".diff-popup", "//codeforces.org/s/98536");
|
|||
|
$("#facebox .diff-popup").html(result["diff"]);
|
|||
|
}
|
|||
|
}, "json");
|
|||
|
});
|
|||
|
}
|
|||
|
} else {
|
|||
|
Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
</script>
|
|||
|
|
|||
|
|
|||
|
<script type="text/javascript">
|
|||
|
$(document).ready(function () {
|
|||
|
|
|||
|
function endsWith(string, suffix) {
|
|||
|
return string.indexOf(suffix, string.length - suffix.length) !== -1;
|
|||
|
}
|
|||
|
|
|||
|
const inputFileDiv = $("div.input-file");
|
|||
|
const inputFile = inputFileDiv.text();
|
|||
|
const outputFileDiv = $("div.output-file");
|
|||
|
const outputFile = outputFileDiv.text();
|
|||
|
|
|||
|
|
|||
|
if (!endsWith(inputFile, "standard input")
|
|||
|
&& !endsWith(inputFile, "standard input")) {
|
|||
|
inputFileDiv.attr("style", "font-weight: bold");
|
|||
|
}
|
|||
|
|
|||
|
if (!endsWith(outputFile, "standard output")
|
|||
|
&& !endsWith(outputFile, "standard output")) {
|
|||
|
outputFileDiv.attr("style", "font-weight: bold");
|
|||
|
}
|
|||
|
|
|||
|
const titleDiv = $("div.header div.title");
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
});
|
|||
|
</script>
|
|||
|
</div>
|
|||
|
<div
|
|||
|
style="margin-bottom: 2em;"
|
|||
|
>
|
|||
|
|
|||
|
|
|||
|
<div class="problemindexholder" problemindex="G" data-uuid="ps_893f143f8b93d438c56016d7228b197648b2430e">
|
|||
|
<div style="display: none; margin:1em 0;text-align: center; position: relative;" class="alert alert-info diff-notifier">
|
|||
|
<div>The problem statement has recently been changed. <a class="view-changes" href="#">View the changes.</a></div>
|
|||
|
<span class="diff-notifier-close" style="position: absolute; top: 0.2em; right: 0.3em; cursor: pointer; font-size: 1.4em;">×</span>
|
|||
|
</div>
|
|||
|
<div class="ttypography"><div class="problem-statement"><div class="header"><div class="title">G. Hits Different</div><div class="time-limit"><div class="property-title">time limit per test</div>2.5 seconds</div><div class="memory-limit"><div class="property-title">memory limit per test</div>256 megabytes</div><div class="input-file"><div class="property-title">input</div>standard input</div><div class="output-file"><div class="property-title">output</div>standard output</div></div><div><p>In a carnival game, there is a huge pyramid of cans with $$$2023$$$ rows, numbered in a regular pattern as shown.</p><center> <img class="tex-graphics" src="https://espresso.codeforces.com/3f72320a7f225babc9b2b244a719e59e9e8f028d.png" style="max-width: 100.0%;max-height: 100.0%;" /><p><span class="tex-font-size-small">If can $$$9^2$$$ is hit initially, then all cans colored red in the picture above would fall.</span> </p></center><p>You throw a ball at the pyramid, and it hits a single can with number $$$n^2$$$. This causes all cans that are stacked on top of this can to fall (that is, can $$$n^2$$$ falls, then the cans directly above $$$n^2$$$ fall, then the cans directly above those cans, and so on). For example, the picture above shows the cans that would fall if can $$$9^2$$$ is hit.</p><p>What is the <span class="tex-font-style-bf">sum</span> of the numbers on all cans that fall? Recall that $$$n^2 = n \times n$$$.</p></div><div class="input-specification"><div class="section-title">Input</div><p>The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases.</p><p>The only line of each test case contains a single integer $$$n$$$ ($$$1 \leq n \leq 10^6$$$) — it means that the can you hit has label $$$n^2$$$.</p></div><div class="output-specification"><div class="section-title">Output</div><p>For each test case, output a single integer — the sum of the numbers on all cans that fall.</p><p>Please note, that the answer for some test cases won't fit into 32-bit integer type, so you should use at least 64-bit integer type in your programming language (like <span class="tex-font-style-tt">long long</span> for C++). For all valid inputs, the answer will always fit into 64-bit integer type.</p></div><div class="sample-tests"><div class="section-title">Example</div><div class="sample-test"><div class="input"><div class="title">Input</div><pre><div class="test-example-line test-example-line-even test-example-line-0">10</div><div class="test-example-line test-example-line-odd test-example-line-1">9</div><div class="test-example-line test-example-line-even test-example-line-2">1</div><div class="test-example-line test-example-line-odd test-example-line-3">2</div><div class="test-example-line test-example-line-even test-example-line-4">3</div><div class="test-example-line test-example-line-odd test-example-line-5">4</div><div class="test-example-line test-example-line-even test-example-line-6">5</div><div class="test-example-line test-example-line-odd test-example-line-7">6</div><div class="test-example-line test-example-line-even test-example-line-8">10</div><div class="test-example-line test-example-line-odd test-example-line-9">1434</div><div class="test-example-line test-example-line-even test-example-line-10">1000000</div></pre></div><div class="output"><div class="title">Output</div><pre>156
|
|||
|
1
|
|||
|
5
|
|||
|
10
|
|||
|
21
|
|||
|
39
|
|||
|
46
|
|||
|
146
|
|||
|
63145186
|
|||
|
58116199242129511
|
|||
|
</pre></div></div></div><div class="note"><div class="section-title">Note</div><p>The first test case is pictured in the statement. The sum of the numbers that fall is $$$$$$1^2 + 2^2 + 3^2 + 5^2 + 6^2 + 9^2 = 1 + 4 + 9 + 25 + 36 + 81 = 156.$$$$$$</p><p>In the second test case, only the can labeled $$$1^2$$$ falls, so the answer is $$$1^2=1$$$.</p><p>In the third test case, the cans labeled $$$1^2$$$ and $$$2^2$$$ fall, so the answer is $$$1^2+2^2=1+4=5$$$.</p><p>In the fourth test case, the cans labeled $$$1^2$$$ and $$$3^2$$$ fall, so the answer is $$$1^2+3^2=1+9=10$$$.</p><p>In the fifth test case, the cans labeled $$$1^2$$$, $$$2^2$$$, and $$$4^2$$$ fall, so the answer is $$$1^2+2^2+4^2=1+4+16=21$$$.</p></div></div><p> </p></div>
|
|||
|
</div>
|
|||
|
|
|||
|
<script>
|
|||
|
$(function () {
|
|||
|
Codeforces.addMathJaxListener(function () {
|
|||
|
let $problem = $("div[problemindex=G]");
|
|||
|
let uuid = $problem.attr("data-uuid");
|
|||
|
let statementText = convertStatementToText($problem.find(".ttypography").get(0));
|
|||
|
|
|||
|
let previousStatementText = Codeforces.getFromStorage(uuid);
|
|||
|
if (previousStatementText) {
|
|||
|
if (previousStatementText !== statementText) {
|
|||
|
$problem.find(".diff-notifier").show();
|
|||
|
|
|||
|
$problem.find(".diff-notifier-close").click(function() {
|
|||
|
Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
|
|||
|
$problem.find(".diff-notifier").hide();
|
|||
|
});
|
|||
|
|
|||
|
$problem.find("a.view-changes").click(function() {
|
|||
|
$.post("/data/diff", {action: "getDiff", a: previousStatementText, b: statementText}, function (result) {
|
|||
|
if (result["success"] === "true") {
|
|||
|
Codeforces.facebox(".diff-popup", "//codeforces.org/s/98536");
|
|||
|
$("#facebox .diff-popup").html(result["diff"]);
|
|||
|
}
|
|||
|
}, "json");
|
|||
|
});
|
|||
|
}
|
|||
|
} else {
|
|||
|
Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
</script>
|
|||
|
|
|||
|
|
|||
|
<script type="text/javascript">
|
|||
|
$(document).ready(function () {
|
|||
|
|
|||
|
function endsWith(string, suffix) {
|
|||
|
return string.indexOf(suffix, string.length - suffix.length) !== -1;
|
|||
|
}
|
|||
|
|
|||
|
const inputFileDiv = $("div.input-file");
|
|||
|
const inputFile = inputFileDiv.text();
|
|||
|
const outputFileDiv = $("div.output-file");
|
|||
|
const outputFile = outputFileDiv.text();
|
|||
|
|
|||
|
|
|||
|
if (!endsWith(inputFile, "standard input")
|
|||
|
&& !endsWith(inputFile, "standard input")) {
|
|||
|
inputFileDiv.attr("style", "font-weight: bold");
|
|||
|
}
|
|||
|
|
|||
|
if (!endsWith(outputFile, "standard output")
|
|||
|
&& !endsWith(outputFile, "standard output")) {
|
|||
|
outputFileDiv.attr("style", "font-weight: bold");
|
|||
|
}
|
|||
|
|
|||
|
const titleDiv = $("div.header div.title");
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
});
|
|||
|
</script>
|
|||
|
</div>
|
|||
|
<div
|
|||
|
style="margin-bottom: 1em;"
|
|||
|
>
|
|||
|
|
|||
|
|
|||
|
<div class="problemindexholder" problemindex="H" data-uuid="ps_b7a5b7b8d22ad9d2e1364485a1138708df2b0b6c">
|
|||
|
<div style="display: none; margin:1em 0;text-align: center; position: relative;" class="alert alert-info diff-notifier">
|
|||
|
<div>The problem statement has recently been changed. <a class="view-changes" href="#">View the changes.</a></div>
|
|||
|
<span class="diff-notifier-close" style="position: absolute; top: 0.2em; right: 0.3em; cursor: pointer; font-size: 1.4em;">×</span>
|
|||
|
</div>
|
|||
|
<div class="ttypography"><div class="problem-statement"><div class="header"><div class="title">H. Don't Blame Me</div><div class="time-limit"><div class="property-title">time limit per test</div>2 seconds</div><div class="memory-limit"><div class="property-title">memory limit per test</div>256 megabytes</div><div class="input-file"><div class="property-title">input</div>standard input</div><div class="output-file"><div class="property-title">output</div>standard output</div></div><div><p>Sadly, the problem setter couldn't think of an interesting story, thus he just asks you to solve the following problem.</p><p>Given an array $$$a$$$ consisting of $$$n$$$ positive integers, count the number of <span class="tex-font-style-bf">non-empty</span> subsequences for which the bitwise $$$\mathsf{AND}$$$ of the elements in the subsequence has exactly $$$k$$$ set bits in its binary representation. The answer may be large, so output it modulo $$$10^9+7$$$.</p><p>Recall that the subsequence of an array $$$a$$$ is a sequence that can be obtained from $$$a$$$ by removing some (possibly, zero) elements. For example, $$$[1, 2, 3]$$$, $$$[3]$$$, $$$[1, 3]$$$ are subsequences of $$$[1, 2, 3]$$$, but $$$[3, 2]$$$ and $$$[4, 5, 6]$$$ are not.</p><p>Note that $$$\mathsf{AND}$$$ represents the <a href="https://en.wikipedia.org/wiki/Bitwise_operation#AND">bitwise AND operation</a>.</p></div><div class="input-specification"><div class="section-title">Input</div><p>Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.</p><p>The first line of each test case consists of two integers $$$n$$$ and $$$k$$$ ($$$1 \leq n \leq 2 \cdot 10^5$$$, $$$0 \le k \le 6$$$) — the length of the array and the number of set bits that the bitwise $$$\mathsf{AND}$$$ the counted subsequences should have in their binary representation.</p><p>The second line of each test case consists of $$$n$$$ integers $$$a_i$$$ ($$$0 \leq a_i \leq 63$$$) — the array $$$a$$$.</p><p>It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$2 \cdot 10^5$$$.</p></div><div class="output-specification"><div class="section-title">Output</div><p>For each test case, output a single integer — the number of subsequences that have exactly $$$k$$$ set bits in their bitwise $$$\mathsf{AND}$$$ value's binary representation. The answer may be large, so output it modulo $$$10^9+7$$$.</p></div><div class="sample-tests"><div class="section-title">Example</div><div class="sample-test"><div class="input"><div class="title">Input</div><pre><div class="test-example-line test-example-line-even test-example-line-0">6</div><div class="test-example-line test-example-line-odd test-example-line-1">5 1</div><div class="test-example-line test-example-line-odd test-example-line-1">1 1 1 1 1</div><div class="test-example-line test-example-line-even test-example-line-2">4 0</div><div class="test-example-line test-example-line-even test-example-line-2">0 1 2 3</div><div class="test-example-line test-example-line-odd test-example-line-3">5 1</div><div class="test-example-line test-example-line-odd test-example-line-3">5 5 7 4 2</div><div class="test-example-line test-example-line-even test-example-line-4">1 2</div><div class="test-example-line test-example-line-even test-example-line-4">3</div><div class="test-example-line test-example-line-odd test-example-line-5">12 0</div><div class="test-example-line test-example-line-odd test-example-line-5">0 2 0 2 0 2 0 2 0 2 0 2</div><div class="test-example-line test-example-line-even test-example-line-6">10 6</div><div class="test-example-line test-example-line-even test-example-line-6">63 0 63 5 5 63 63 4 12 13</div></pre></div><div class="output"><div class="title">Output</div><pre>31
|
|||
|
10
|
|||
|
10
|
|||
|
1
|
|||
|
4032
|
|||
|
15
|
|||
|
</pre></div></div></div></div><p> </p></div>
|
|||
|
</div>
|
|||
|
|
|||
|
<script>
|
|||
|
$(function () {
|
|||
|
Codeforces.addMathJaxListener(function () {
|
|||
|
let $problem = $("div[problemindex=H]");
|
|||
|
let uuid = $problem.attr("data-uuid");
|
|||
|
let statementText = convertStatementToText($problem.find(".ttypography").get(0));
|
|||
|
|
|||
|
let previousStatementText = Codeforces.getFromStorage(uuid);
|
|||
|
if (previousStatementText) {
|
|||
|
if (previousStatementText !== statementText) {
|
|||
|
$problem.find(".diff-notifier").show();
|
|||
|
|
|||
|
$problem.find(".diff-notifier-close").click(function() {
|
|||
|
Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
|
|||
|
$problem.find(".diff-notifier").hide();
|
|||
|
});
|
|||
|
|
|||
|
$problem.find("a.view-changes").click(function() {
|
|||
|
$.post("/data/diff", {action: "getDiff", a: previousStatementText, b: statementText}, function (result) {
|
|||
|
if (result["success"] === "true") {
|
|||
|
Codeforces.facebox(".diff-popup", "//codeforces.org/s/98536");
|
|||
|
$("#facebox .diff-popup").html(result["diff"]);
|
|||
|
}
|
|||
|
}, "json");
|
|||
|
});
|
|||
|
}
|
|||
|
} else {
|
|||
|
Codeforces.putToStorageTtl(uuid, statementText, 6 * 60 * 60);
|
|||
|
}
|
|||
|
});
|
|||
|
});
|
|||
|
</script>
|
|||
|
|
|||
|
|
|||
|
<script type="text/javascript">
|
|||
|
$(document).ready(function () {
|
|||
|
|
|||
|
function endsWith(string, suffix) {
|
|||
|
return string.indexOf(suffix, string.length - suffix.length) !== -1;
|
|||
|
}
|
|||
|
|
|||
|
const inputFileDiv = $("div.input-file");
|
|||
|
const inputFile = inputFileDiv.text();
|
|||
|
const outputFileDiv = $("div.output-file");
|
|||
|
const outputFile = outputFileDiv.text();
|
|||
|
|
|||
|
|
|||
|
if (!endsWith(inputFile, "standard input")
|
|||
|
&& !endsWith(inputFile, "standard input")) {
|
|||
|
inputFileDiv.attr("style", "font-weight: bold");
|
|||
|
}
|
|||
|
|
|||
|
if (!endsWith(outputFile, "standard output")
|
|||
|
&& !endsWith(outputFile, "standard output")) {
|
|||
|
outputFileDiv.attr("style", "font-weight: bold");
|
|||
|
}
|
|||
|
|
|||
|
const titleDiv = $("div.header div.title");
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
});
|
|||
|
</script>
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
|
|||
|
<div id="footer">
|
|||
|
<div><a href="https://codeforces.com/">Codeforces</a> (c) Copyright 2010-2023 Mike Mirzayanov</div>
|
|||
|
<div>The only programming contests Web 2.0 platform</div>
|
|||
|
|
|||
|
</div>
|
|||
|
|
|||
|
</div>
|
|||
|
</div>
|
|||
|
<script type="application/javascript">
|
|||
|
if ('serviceWorker' in navigator && 'fetch' in window && 'caches' in window) {
|
|||
|
navigator.serviceWorker.register('/service-worker-98536.js')
|
|||
|
.then(function (registration) {
|
|||
|
console.log('Service worker registered: ', registration);
|
|||
|
})
|
|||
|
.catch(function (error) {
|
|||
|
console.log('Registration failed: ', error);
|
|||
|
});
|
|||
|
}
|
|||
|
</script>
|
|||
|
<script>(function(){var js = "window['__CF$cv$params']={r:'7ea32e14b8f6b33c'};_cpo=document.createElement('script');_cpo.nonce='',_cpo.src='/cdn-cgi/challenge-platform/scripts/invisible.js',document.getElementsByTagName('head')[0].appendChild(_cpo);";var _0xh = document.createElement('iframe');_0xh.height = 1;_0xh.width = 1;_0xh.style.position = 'absolute';_0xh.style.top = 0;_0xh.style.left = 0;_0xh.style.border = 'none';_0xh.style.visibility = 'hidden';document.body.appendChild(_0xh);function handler() {var _0xi = _0xh.contentDocument || _0xh.contentWindow.document;if (_0xi) {var _0xj = _0xi.createElement('script');_0xj.innerHTML = js;_0xi.getElementsByTagName('head')[0].appendChild(_0xj);}}if (document.readyState !== 'loading') {handler();} else if (window.addEventListener) {document.addEventListener('DOMContentLoaded', handler);} else {var prev = document.onreadystatechange || function () {};document.onreadystatechange = function (e) {prev(e);if (document.readyState !== 'loading') {document.onreadystatechange = prev;handler();}};}})();</script></body>
|
|||
|
</html>
|