题目传送门:E - At Least One (atcoder.jp) 题意: 给定大小为N的两个数组A,B,求长度分别为1~M的满足以下条件的连续序列数量,条件为: 对于每个i(从1~N),Ai和Bi至少有一个包含于此序列之内. 思路:双指针 + 差分 容易知道,当序列[L, R]是满足条件的连续序列时,则左边界向左拓展,右边界向右拓展时,得到的新序列依旧满足条件. 那么我们枚举左边界L,然后移动右边界,使得其为满足条件的最小右边界(记为Rmin),则长度在[Rmin - L + 1, M -…
AtCoder Beginner Contest 260 - AtCoder D - Draw Your Cards 题意:N张卡牌数字 1-n,以某种顺序排放,每次拿一张,如果这一张比前面某一张小(不是最大的) ,就把它放在比他大的牌中数字最小的,如果没有就单独放在第一个位置,当某个位置的牌数达到k张,就将他们拿走,问最后每张牌都会在第几次操作被拿走,如果没被拿走输出 -1. 题解:可以利用set或者map这种自动排序的迭代器来进行存储,然后利用二分找到第一个比它大的数字,然后进行操作即可.…
题目传送门:G - Scalene Triangle Area (atcoder.jp) 题意: 给定大小为N*N的OX矩阵,若矩阵的(s,t)处为O,其覆盖范围为:满足以下条件的所有位置(i,j) s <= i && t <= j (i - s) + (j - t) / 2 < M 再给出Q次询问,对于每次询问(x,y),要求给出对应位置被覆盖了多少次. 思路:imos 不妨先考虑 n = 7, m = 3, 且仅在左上角处为 'O' .那么矩阵上每个位置被覆盖次数如T…
题目传送门:F - Find 4-cycle (atcoder.jp) 题意: 给定一个无向图,其包含了S.T两个独立点集(即S.T内部间的任意两点之间不存在边),再给出图中的M条边(S中的点与T中的点之间的边). 求图中包含的一个四元环,若存在则输出环中包含的顶点,否则输出-1. 思路: 首先,四元环只能是由两个S中的点和两个T中的点构成,记为a.b,u.v,且a.b与u.v都直接有边相连. |S| 为 300000,|T| 为 3000.于是我们考虑枚举S中点,记为Si,再枚举与Si相连的两…
A - Happy Birthday! Time limit : 2sec / Memory limit : 1000MB Score: 100 points Problem Statement E869120's and square1001's 16-th birthday is coming soon.Takahashi from AtCoder Kingdom gave them a round cake cut into 16 equal fan-shaped pieces. E869…
没看到Beginner,然后就做啊做,发现A,B太简单了...然后想想做完算了..没想到C卡了一下,然后还是做出来了.D的话瞎想了一下,然后感觉也没问题.假装all kill.2333 AtCoder Beginner Contest 052 A题意: 输出大的面积? 思路: max(A*B,C*D); AtCoder Beginner Contest 052 B题意: 枚举过程,然后...太水了.. AtCoder Beginner Contest 052 C题意: 输出N!的因子个数mod1…
A - ABC/ARC Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Smeke has decided to participate in AtCoder Beginner Contest (ABC) if his current rating is less than 1200, and participate in AtCoder Regular Contest (ARC) oth…
AtCoder Beginner Contest 136 题目链接 A - +-x 直接取\(max\)即可. Code #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 2e5 + 5; int main() { ios::sync_with_stdio(false); cin.tie(0); int a, b; cin >> a >> b; cout &…
AtCoder Beginner Contest 137 F 数论鬼题(虽然不算特别数论) 希望你在浏览这篇题解前已经知道了费马小定理 利用用费马小定理构造函数\(g(x)=(x-i)^{P-1}\) \[x=i,g(x)=0\] \[x\ne i ,g(x)=1\] 则我们可以构造 \[f(x)=\sum^{i=0}_{P-1}(-a_i*(x-i)^{P-1}+a_i)\] 对于第\(i\)条式子当且仅当\(a_i=1 \ and \ x=i\)时取到\(1\) 代码写的比较奇怪 const…
A - Rating Goal Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Takahashi is a user of a site that hosts programming contests.When a user competes in a contest, the rating of the user (not necessarily an integer) changes…