关闭

CodeForces 840E. In a Trap

链接:link题意:一棵树,点有点权aia_i,每次查询uu到vv路径上的max(aixordis(i,v))max(a_i\,xor\,dis(i, v)),保证uu是vv的祖先。题解:注意到nn和权值都不大,我们考虑值域分块。 考虑维护一个点xx向上256256个点的信息,这样我们后八位在跳的时候不会产生影响。 然后fx,if_{x, i}表示xx向上256256个点的max(ajxordi...
阅读(11) 评论(0)

CodeChef AUG17 简要题解

RAINBOWA签到。#include #define xx first #define yy second #define mp make_pair #define pb push_back #define mset(x, y) memset(x, y, sizeof x) #define mcpy(x, y) memcpy(x, y, sizeof x) usin...
阅读(74) 评论(0)

Topcoder 2017 TCO Algorithm Round 3A Hard

链接:link题意:给一棵nn个节点的树,有mm个人,给每个人分配一个位置,满足一些限制: 如果以rir_i为根,aia_i和bib_i的LCA为xix_i。题解:2-SAT。 考虑第ii个人是否在子树jj里建立一个点,然后怎么建边就很简单了。 注意树形结构的一些限制。 (其实应该可以把边数优化到和点数同阶,但是原题范围n2mn^2m能过,就没去写了)代码:#include <bits/st...
阅读(41) 评论(0)

AtCoder Grand Contest 018 F - Two Trees

Problem Statement There are two rooted trees, each with N vertices. The vertices of each tree are numbered 1 through N. In the first tree, the parent of Vertex i is Vertex Ai. Here, Ai=−1 if ...
阅读(74) 评论(0)

AtCoder Grand Contest 018 E - Sightseeing Plan

Problem Statement Joisino is planning on touring Takahashi Town. The town is divided into square sections by north-south and east-west lines. We will refer to the section that is the x-th from the...
阅读(55) 评论(0)

Topcoder SRM 718 Hard

链接:https://community.topcoder.com/stat?c=problem_statement&pm=14607&rd=16933 题意:给一个排列p[n],定义f(k)表示它长度为k的所有子序列提取出来,对于每一个按大小顺序标号之后形成的本质不同的排列个数是否为C(n, k),现在你要补全一个排列,使∑f(k)最大,然后字典序最小 题解:考虑f(n - 1) = 1的时...
阅读(41) 评论(0)

CodeForces 827F. Dirty Arkady's Kitchen

Arkady likes to walk around his kitchen. His labyrinthine kitchen consists of several important places connected with passages. Unfortunately it happens that these passages are flooded with milk so th...
阅读(82) 评论(0)

AtCoder Grand Contest 017 C - Snuke and Spells

Problem Statement There are N balls in a row. Initially, the i-th ball from the left has the integer Ai written on it. When Snuke cast a spell, the following happens: Let the current number o...
阅读(119) 评论(0)

LOJ #6077. 「2017 山东一轮集训 Day7」逆序对

链接:https://loj.mcfx.us/problem/6077 题解:DP 首先注意到如果从小到大填进去第i个数,那么逆序对会增加[0, i - 1]个 问题转化为:∑x[i] = k, 0 这是个经典问题,我们考虑容斥,至少有j个不满足条件,剩下随便选 不满足条件即x[i] >= i,我们把k减去i,然后就是个组合数的事情了 我们需要求出f(i, j)表示[1, n]中i个...
阅读(112) 评论(0)

Topcoder SRM 716 Hard

链接:https://community.topcoder.com/stat?c=problem_statement&pm=14600&rd=16931 题意:初始有N个区间[i, i],你可以进行k次操作,每次可以将两个已有区间的并(要求也是个区间)加入已有区间,最后考虑每一个合法区间[i, j],记f(i, j)表示覆盖它最少需要的区间数(区间可以相交),记c = max(f(i, j)),...
阅读(52) 评论(0)

BZOJ 2803: [Poi2012]Prefixuffix

Description 对于两个串S1、S2,如果能够将S1的一个后缀移动到开头后变成S2,就称S1和S2循环相同。例如串ababba和串abbaab是循环相同的。 给出一个长度为n的串S,求满足下面条件的最大的L: 1. L 2. S的L前缀和S的L后缀是循环相同的。 Input 第一行一个正整数n (n Output 一个整数,表示最大的L。 ...
阅读(68) 评论(1)

Atcoder Grand Contest 016F - Games on DAG

Problem Statement There is a directed graph G with N vertices and M edges. The vertices are numbered 1 through N, and the edges are numbered 1 through M. Edge i is directed from xi to yi. Her...
阅读(131) 评论(0)

CodeForces 815D. Karen and Cards

Karen just got home from the supermarket, and is getting ready to go to sleep. After taking a shower and changing into her pajamas, she looked at her shelf and saw an album. Curious, she opened i...
阅读(94) 评论(0)

Topcoder 2016 TCO Algorithm Round 3B Hard

链接:https://community.topcoder.com/stat?c=problem_statement&pm=14379&rd=16798 题意:给一个n个点的图,求团的个数,每个点有一个长度为k两个点有边当且仅当i的字符串任意循环移位之后和j玩石头剪刀布胜负次数不变 题解:分析A、B之间有边的性质 定义w为3次单位根 将A看成一个多项式,系数这样定:R = 1, S = w...
阅读(91) 评论(0)

UOJ#214. 【UNR #1】合唱队形

链接:http://uoj.ac/problem/214 数据分治 PART I: 记f(t)表示t时刻还没有结束的概率,那么ans = ∑[t = 0 to inf]f(t) 考虑计算f(t),容斥,2 ^ (n - m)枚举哪些已经成为可行区间 f(t) = ∑[i = 1 to 2 ^ (n - m)] g(h(i), t) * (-1) ^ (bitcount(i)...
阅读(107) 评论(0)
152条 共11页1 2 3 4 5 ... 下一页 尾页
    个人资料
    • 访问:19368次
    • 积分:1637
    • 等级:
    • 排名:千里之外
    • 原创:152篇
    • 转载:0篇
    • 译文:0篇
    • 评论:19条
    最新评论