Educational Codeforces Round 48 (Rated for Div. 2) CD题解
| Educational Codeforces Round 48 (Rated for Div. 2) |
|---|
C. Vasya And The Mushrooms
题目链接:https://codeforces.com/contest/1016/problem/C
题意:
emmm,说不清楚,还是直接看题目吧。
题解:
这个题人行走的方式是有一定的规律的,最后都是直接走到底,然后从另外一行走回来。并且通过画图观察,会发现他走到格子的时间会有一定的规律。
所以就维护几个前缀和就行了,从1到n枚举一下,还要维护一下目前走过的格子对答案的贡献,如果是奇数那么当前就是从上面出发,如果是偶数就是从下面出发,计算答案的时候根据规律来就行了。
代码如下:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e5 + ;
int n;
ll a[][N], sum123[][N], sum321[][N], sum[][N];
int main() {
ios::sync_with_stdio(false);
cin.tie();
cin >> n;
for(int i = ; i < ; i++) {
for(int j = ; j <= n; j++) {
cin >> a[i][j];
}
}
for(int i = ; i < ; i++) {
for(int j = n; j >= ; j--) {
sum[i][j] = sum[i][j + ] + a[i][j];
sum123[i][j] = sum123[i][j + ] + (ll)(j - ) * a[i][j];
sum321[i][j] = sum321[i][j + ] + (ll)(n + n - j) * a[i][j];
}
}
ll S = , ans = , Sum = , now = ;
ll cnt = , cur = ;
for(ll j = ; j <= n; j++) {
Sum += sum123[cur][j + ] + (j - ) * sum[cur][j + ];
Sum += sum321[cur ^ ][j] + (j - ) * sum[cur ^ ][j];
ans = max(ans, Sum);
now += a[cur ^ ][j] * cnt; cnt++;
now += a[cur ^ ][j + ] * cnt; cnt++;
Sum = now;
cur ^= ;
}
cout << ans;
return ;
}
D. Vasya And The Matrix
题目链接:https://codeforces.com/contest/1016/problem/D
题意:
给出每一行和每一列的异或值,要求你构造一个矩阵满足这个异或值。
题解:
这个构造还是挺巧妙的,首先先把a2...an和b2,b3...bm安排好,然后对于(1,1)这个位置,构造a1^b2^b3...^bm,其余全是0就行了,这个还是比较容易证明的。
反正就是很巧妙。。
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = ;
ll a[N], b[N];
int n, m;
int main() {
ios::sync_with_stdio(false);
cin.tie();
cin >> n >> m;
ll cur = ;
for(int i = ; i <= n; i++)
cin >> a[i], cur ^= a[i];
for(int i = ; i <= m; i++)
cin >> b[i], cur ^= b[i];
if(cur != ) {
cout << "NO";
return ;
}
cout << "YES" << '\n';
cur = a[];
for(int i = ; i <= m; i++)
cur ^= b[i];
cout << cur;
for(int i = ; i <= m; i++)
cout << ' ' << b[i];
cout << '\n';
for(int i = ; i <= n; i++) {
for(int j = ; j <= m; j++) {
if(j == )
cout << a[i];
else
cout << ' ' << ;
}
cout << '\n';
}
return ;
}
Educational Codeforces Round 48 (Rated for Div. 2) CD题解的更多相关文章
- Educational Codeforces Round 59 (Rated for Div. 2) DE题解
Educational Codeforces Round 59 (Rated for Div. 2) D. Compression 题目链接:https://codeforces.com/contes ...
- Educational Codeforces Round 48 (Rated for Div. 2)
http://codeforces.com/contest/1016 A. 没想到这个也会TLE,太粗心了 B. 暴力就好了,多情况讨论又出错... 思路跟我一样的解法 为什么我做了那么多讨论,原 ...
- Educational Codeforces Round 48 (Rated for Div. 2) B 1016B Segment Occurrences (前缀和)
B. Segment Occurrences time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- Educational Codeforces Round 48 (Rated for Div. 2)异或思维
题:https://codeforces.com/contest/1016/problem/D 题意:有一个 n * m 的矩阵, 现在给你 n 个数, 第 i 个数 a[ i ] 代表 i 这一行所 ...
- Educational Codeforces Round 48 (Rated for Div. 2)——A. Death Note ##
A. Death Note time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- Educational Codeforces Round 48 (Rated for Div. 2)G. Appropriate Team
题意:求满足条件的(i,j)对数:\(gcd(v,a_i)=x,lcm(v,a_j)=y\) 题解:\(x|a_i,a_j|y\),\(x|y\),考虑质因子p,假设a_i中p次数为a,x中次数为b, ...
- Educational Codeforces Round 48 (Rated for Div. 2) D 1016D Vasya And The Matrix (构造)
D. Vasya And The Matrix time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- 【Educational Codeforces Round 48 (Rated for Div. 2) C】 Vasya And The Mushrooms
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然在没有一直往右走然后走到头再往上走一格再往左走到头之前. 肯定是一直在蛇形走位.. 这个蛇形走位的答案贡献可以预处理出来.很容易 ...
- 【Educational Codeforces Round 48 (Rated for Div. 2) D】Vasya And The Matrix
[链接] 我是链接,点我呀:) [题意] 告诉你每一行.每一列的异或和. 让你求出一个符合要求的原矩阵. [题解] 显然应该有 a1^a2^....^an = b1^b2^....^bn 也即两边同时 ...
随机推荐
- 2>&1和&>的区别
简单记录下: COMMAND > /path/file 2>&1 COMMAND &> /path/file 这两个效果都是一样的,都是把正确的输入.错误输入存放到同 ...
- 【CSVRead】-jmeter
csv read 读取文件
- 【转】cocos2d工具汇总
位图字体工具Bitmap Font Tools BMFont (Windows)FonteditorGlyph DesignerHieroLabelAtlasCreator 粒子编辑工具Particl ...
- 关于java使用double还是float
眼睛一亮在论坛上发现一枚很有价值的评论赶紧抄下来... 记住java一定要用double,更鼓不变,就算数值不大也要用double.了解java虚拟机的底层会知道,float放在内存中其实是当作dou ...
- FPGA学习-PS2接口
选自http://m.elecfans.com/article/774143.html
- logisitic回归
线性回归目的是找到一条直线(或者超平面)尽可能地接近所有的训练数据点,而对数几率回归的目的是找到一条直线(或者超平面)尽可能地分开两种不同类别的数据点. 对数几率回归感觉更像是一个分类问题.https ...
- DeepLearning Intro - sigmoid and shallow NN
This is a series of Machine Learning summary note. I will combine the deep learning book with the de ...
- https的主体过程
https其实就是基于SSL的http.加密后的http信息按理是不会被篡改和查看的. https的过程总体上是按照下面来进行的: 1.客户端发起请求,服务端返回一个SSL证书,证书里面有一公钥A. ...
- Spring MVC 整合Swagger的一些问题总结
在做Spring MVC 整合swagger的时候,遇到的两个问题: 第一个问题 在网上找了一些Spring MVC 和Swagger的例子,照着一步步的配置,结果,到最后,项目都起来了,没有任何问题 ...
- PHP 5.6.32 增加pdo_dblib.so拓展
首先说明,php增加pdo_dblib.so拓展不需要重新编译php源文件,只需要增加dblib源包即可. 1.下载安装所需包 1.#下载 wget http://mirrors.ibiblio.or ...