时间复杂度O(n2)O(n2)。点击查看代码 #include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<n;++i) #define repn(i,n) for(int i=1;i<=n;++i) #define LL long long #define pii pair <int,int> #define pb push_back #define fi first #define se second #define mpr make_...
#include<vector>#include<iostream>#include<algorithm>usingi64 =longlong;usingvint = std::vector<int>;usingPII = std::pair<int,int>;intmain(void){//Think twice, code once.std::ios::sync_with_stdio(false); i64 a[3]; std::cin >> a[0] >> a[1] >> a[2]; i64 x = a[0] ...
const int N = int(2e5) + 9; Int f[N]; int a[N], c[N], cn; int n; void add(int x) { x = a[x]; if (!c[x]) ++cn; c[x] += 1; } void dec(int x) { x = a[x]; c[x] -= 1; if (!c[x]) --cn; } int main(){ #ifndef ONLINE_JUDGE freopen("in.txt...
AtCoder Regular Contest 138 题解(A-D) Cgfyufsygsm PKU CS3 人赞同了该文章 目录 收起 ARC138A - Larger Score ARC138B - 01 Generation ARC138C - Rotate and Play Game ARC138D - Differ by K bits ARC138A - Larger Score
AtCoder Regular Contest 166, 视频播放量 146、弹幕量 0、点赞数 3、投硬币枚数 0、收藏人数 1、转发人数 0, 视频作者 Known_Error, 作者简介 invictus maneo,相关视频:AtCoder Beginner Contest 323,AtCoder Beginner Contest 322,Codeforces Round 902 (Div. 1, base
AtCoder Regular Contest 100 (ARC100) D - Equal Cut 二分,题目传送门-ARC100D题意给你一个长度为$n$的数列,请切$3$刀,形成$4$个连续非空子序列,问这$4$个非空子序列的各自的元素和的极差为多少。$n\leq2\times10^5$题解如果切一刀,那么问题就很简单
AtCoder Regular Contest 116 (A~F补题记录) A - Odd vs Even \(T(1≤T≤2×10^5)\)组测试数据,每次询问一个正整数\(N(1≤N≤2×10^{18})\)的奇数因子多还是偶数因子多。 【方案一】 设n有cnt个质因子2, 假设n有x个奇数因子,那么就会有m*(2^(cnt)-1)种偶数因子,即用cnt个2的子集和...
We will hold AtCoder Regular Contest 107. Contest URL: https://atcoder.jp/contests/arc107 Start Time: http://www.timeanddate.com/worldclock/fixedtime.html?iso=20201031T2100&p1=248 Duration: 100 minutes Number of Tasks: 6 Writer: maroonrk, yosupo, sigma425 Tester: maroonrk, yosupo, sigma...
题意:N 个通过做 M 道两个选项的单项选择题,求出分数一定不相同的的两个学生有多少组。 解法:如果两个学生的答案中含有同奇同偶个 1,那么显然可以构造出一种方案(具体来说,假设 A 的 1 数量比 B 的多,那么从 A 中拿出(S[A]-S[B])/2个 1 并且保证 B 中这些位是 0),奇数的话由于改变一个答案...
AtCoder Regular Contest 078 D - Fennec VS. Snuke 题意 给一个树,1是白色,n是黑色,其它没有颜色。Fennec每次可以染白色点的直接邻居为白色。Snuke则染黑色点的邻居为黑色。谁先不能动就输了。问谁赢。 题解 先找出1到n的唯一路径path[1..len],然后Fennec可以依次取1到len/2的点及其不在路径上的孩子...