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 也即两边同时 ...
随机推荐
- Java开发工程师(Web方向) - 01.Java Web开发入门 - 第6章.蜂巢
第6章--蜂巢 蜂巢简介 网站开发完,就需要测试.部署.在服务器上运行. 网易蜂巢: 采用Docker容器化技术的云计算平台 https://c.163.com 容器管理:容器可被视作为云主机的服务器 ...
- 微服务框架Dubbo与Springcloud的区别
微服务框架Dubbo与Springcloud的区别 微服务主要的优势如下: 1.降低复杂度 将原来偶合在一起的复杂业务拆分为单个服务,规避了原本复杂度无止境的积累.每一个微服务专注于单一功能,并通过定 ...
- Codeforces-A. Shortest path of the king(简单bfs记录路径)
A. Shortest path of the king time limit per test 1 second memory limit per test 64 megabytes input s ...
- leetcode-分割回文子串
给定一个字符串 s,将 s 分割成一些子串,使每个子串都是回文串. 返回 s 所有可能的分割方案. 示例: 输入: "aab" 输出: [ ["aa",&quo ...
- Linux的基础预备知识
Linux下一切皆文件 1.root@mk-virtual-machine:/home/mk# root:该位置表示当前终端登录的用户名 mk-virtual-machine:/home/m ...
- How Does Batch Normalization Help Optimization?
1. 摘要 BN 是一个广泛应用的用于快速稳定地训练深度神经网络的技术,但是我们对其有效性的真正原因仍然所知甚少. 输入分布的稳定性和 BN 的成功之间关系很小,BN 对训练过程更根本的影响是:它让优 ...
- matlab 常用集合相关的函数
Matlab常用的集合相关的函数如下: union(A,B) %求集合A和集合B的并集 intersect(A,B) %求集合A和集合 ...
- JS判断是IOS还是Android以及如何解决h5打包后在ios下内容与状态栏重叠问题
h5打包后在ios下内容与状态栏重叠问题: 1:知道设备的类型: var u = navigator.userAgent, app = navigator.appVersion; var isAndr ...
- logstash+elasticsearch 错误摘记
[2017-09-17T06:00:22,511][WARN ][o.e.b.ElasticsearchUncaughtExceptionHandler] [] uncaught exception ...
- c# 计算两个时间的时间差
//计算2个日期之间的天数差 DateTime dt1 = Convert.ToDateTime("2007-8-1"); DateTime dt2 = Convert.ToDat ...