构造是依次给i行、列赋值1,2,3,…,n(i=n,n−1,…,1)。 Proof 把≥x的元素是作为1,<x的元素视作为0,最后得到1的个数记为fM(x)。那么总和即为fM(1)+fM(2)+⋯+fM(n)。 下面证明:fM(x)≤n2−(x−1)2。 一次操作可以视作为:给一行或一列染x−1个0,n−(x−1)个黑。 尝试加...
#pragmaGCCoptimize(3)#include<bits/stdc++.h>#defineintlonglongusingnamespacestd;constintN=1000100;inta[N],box[N];signedmain(){intT;cin>>T;while(T--){intn;cin>>n;for(inti=1;i<=n;i++)box[i]=0;for(inti=1;i<=n;i++){cin>>a[i];box[a[i]]++;}intcnt=0;for(inti=1;i<...
tie(0); ios::sync_with_stdio(0); const int INF = 2e5 + 100; int T; cin >> T; while(T--){ int n; cin >> n; vector<int> a(n); for(int i = 0; i < n; i++) cin >> a[i]; auto check = [&](){ for(int i = 0; i < n; i++){ if (a[i] == 0){ ...
每次横着填n,n−1...1,在竖着填一遍,最终可以让n覆盖2∗n−1的个区域,同理可以让n−1覆盖2 *(n - 1) - 1个区域,...,看看代码稍微模拟一下可能就明白了。 void solve() { int n; cin >> n; int s = 0; rep(i, n, 1) { s += (2 * i - 1) * i; } cout << s << ...
We are pleased to invite you to participate in Codeforces Round 939 (Div. 2), which will start on Apr/13/2024 17:35 (Moscow time). The problems are from Otomachi_Una and me. This round will be rated for participants whose rating is below 2100. Participants with higher ratings may parti...
秋天寒创建的收藏夹秋天寒内容:Codeforces Round 939 div.2,如果您对当前收藏夹内容感兴趣点击“收藏”可转入个人收藏夹方便浏览
Codeforces Round 942 Div1 (ABC讲解)RegenFallen 立即播放 打开App,流畅又高清100+个相关视频 更多836 1 32:08 App Codeforces Round 943 (Div. 3) (Rank 1 & F 一血) 3842 12 1:58:07 App 【Codeforces实况】CF1965【小粉兔】Round #941 (Div. 1) 2022 3 16:48 App ABC349F题 Subsequence LCM...
Codeforces Round 464 (Div. 2) Finished → Virtual participation Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests. If you've seen these problems, a virtual contest is not for you -...
Codeforces Round #685 (Div. 2) - 2/7 1451A - Subtract or Divide - Accepted 1451B - Non-Substring Subsequence - Accepted 1451C - String Equality - Accepted Codeforces Round #684 (Div. 2) - 2/6 1440A - Buy the String - Accepted 1440B - Sum of Medians - Accepted 1440C1 - Binary...
Codeforces Round #509 (Div. 2)--E. Tree Reconstruction 题意: 是否存在n个点构成的树,切断其中一条边分成两部分的分别点的下标最大值,分别于给出的n-1种情况符合 思路:构造,这个树就是直的,没有分叉,然后,因为不论怎么分,n一定属于其中一部分,所以每种情况其中一个一定是n,所以,就对每对的令一半...