题意 B - Balanced Neighbors 给定一个整数 $N$($3\leq N \leq 100$),构造一个顶点编号为 $1...N$ 的无向图,需满足如下两个条件: 简单图且连通 存在一个整数 $S$,使得对于每个顶点,与其相连的顶点的编号和都为 $S$ 可以证明至少有一个满足上述条件的图,请输出这样的图. 分析 手动尝试一下 $n=3,4,5$,可以找到一个构造方法. 考虑完全 $k$ 分图(类比完全二分图),并保证这 $k$ 部分的和都相等. 如果 $n$ 为偶数,那么我们可…
打的第一场Atcoder,已经知道会被虐得很惨,但没有想到竟然只做出一题-- 思维急需提升. A - Limited Insertion 这题还是很签到的. 感觉正着做不好做,我们反着来,把加数变为删数. 显然每次有多个可以删时要删最后一个可删的,这样前面仍然合法,后面也有可能有更多合法情况. 发现不能删时就puts("-1"). #include<bits/stdc++.h> namespace my_std{ using namespace std; #define r…
Tautonym Puzzle Time Limit: 50 Sec  Memory Limit: 256 MB Description 定义一个序列贡献为1,当且仅当这个序列 由两个相同的串拼接而成,比如123123. 请构造一个序列,使得它子序列的贡献和为n. 要求序列长度<=200,权值<=100. Input 一行一个n. Output 第一行为长度len,表示你构造出的序列长度. 第二行为你构造出的序列. Sample Input 7 Sample Output 4 1 1 1 1…
Atcoder 题面传送门 & 洛谷题面传送门 神仙调整+乱搞题. 首先某些人(including me)一看到最大值最小就二分答案,事实上二分答案对这题正解没有任何启发. 首先将 \(a_i\) 从小到大排序.我们考虑将分配的点对看作一条条线,对于 \(a_x+a_y<M\) 的点对 \((x,y)\) 我们在 \(x,y\) 之间连一条蓝线,对于 \(a_x+a_y\ge M\) 的点对我们在 \(x,y\) 之间连一条红线. 先抛结论,再给证明:如在最优分配方式中,我们的连线方式肯定是…
Time Limit: 2 sec / Memory Limit: 1024 MB Score : 400400 points Problem Statement Snuke has an empty sequence aa. He will perform NN operations on this sequence. In the ii-th operation, he chooses an integer jj satisfying 1≤j≤i1≤j≤i, and insert jj at…
AtCoder Grand Contest 012 A - AtCoder Group Contest 翻译 有\(3n\)个人,每一个人有一个强大值(看我的假翻译),每三个人可以分成一组,一组的强大值定义为三个人中第二强的人的强大值.求\(n\)组最大的强大值之和. 题解 这...不是倒着选两个人,正着选一个人构成一组就好了嘛.. #include<iostream> #include<cstdio> #include<algorithm> using namespa…
AtCoder Grand Contest 031 Atcoder A - Colorful Subsequence description 求\(s\)中本质不同子序列的个数模\(10^9+7\).两个子序列不同当且仅当存在一种字符在两者中的出现次数不同. \(|s|\le10^5\) solution \(\prod_{i='a'}^{'z'}(\mbox{字符}i\mbox{出现的次数}+1)-1\) #include<cstdio> #include<algorithm>…
AtCoder Grand Contest 010 A - Addition 翻译 黑板上写了\(n\)个正整数,每次会擦去两个奇偶性相同的数,然后把他们的和写会到黑板上,问最终能否只剩下一个数. 题解 洛谷认为此题过水,已被隐藏. #include<iostream> #include<cstdio> using namespace std; inline int read() { int x=0;bool t=false;char ch=getchar(); while((ch…
AtCoder Grand Contest 008 A - Simple Calculator 翻译 有一个计算器,上面有一个显示按钮和两个其他的按钮.初始时,计算器上显示的数字是\(x\),现在想把这个数字给变成\(y\).两个按钮的作用分别是让这个数加一和把这个数取反.问最少的按按钮的次数. 题解 神仙特判题,想清楚再写. #include<iostream> using namespace std; int x,y,ans=2147483647; int main() { cin>…
AtCoder Grand Contest 007 A - Shik and Stone 翻译 见洛谷 题解 傻逼玩意 #include<cstdio> int n,m,tot;char ch[10]; int main() { scanf("%d%d",&n,&m); for(int i=1;i<=n;++i) { scanf("%s",ch+1); for(int j=1;j<=m;++j) tot+=ch[j]=='#'…