牛客国庆集训派对Day2
题目链接:https://www.nowcoder.com/acm/contest/202/A
A
题意:给出最大4096*64和64*4096的矩阵,其中有一个矩阵只含有0和1,问你它们相乘所得到得矩阵所有元素异或
思路:一开始我想到的是能不能将01矩阵的一排都用二进制表示,但是发现2的64次方大于4096,反而增大了复杂度,于是没有做出这题,题解是将矩阵分块,最多分成8块,这样01矩阵的种数有255种,然后再暴力求解,看起来很难写,但是捋清楚思路和写法,这题不难写
#include <cstdio>
#include <iostream>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <vector>
#include <stack>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
#define ll long long
const int maxn=4096+10;
int A[maxn][70];
int B[maxn][70];
int de[maxn][10][(1<<8)+10];
int main()
{
int n,p,m;
cin>>n>>p>>m;
for(int i=1; i<=n; i++)
{
for(int j=1; j<=p; j++)
{
string a;
cin>>a;
int l=1;
for(int k=a.size()-1; k>=0; k--)
{
if(a[k]>='0'&&a[k]<='9')
A[i][j]+=(a[k]-'0')*l;
else A[i][j]+=(a[k]-'A'+10)*l;
l*=16;
}
// cout<<A[i][j]<<endl;
}
}
for(int i=1; i<=m; i++)
{
for(int j=1; j<=p; j++)
{
scanf("%1d",&B[i][j]);
}
}
int len=p/8+(p%8!=0);
// cout<<len<<endl;
for(int i=1; i<=n; i++)
{
for(int j=1; j<=len; j++)
{
for(int k=0; k<(1<<8); k++)
{
for(int t=0; t<8; t++)
{
if(k&(1<<t))de[i][j][k]+=A[i][t+1+(j-1)*8];
}
}
}
}
int ans=0;
for(int nn=1; nn<=n; nn++)
{
for(int i=1; i<=m; i++)
{
int d=0;
for(int j=1; j<=len; j++)
{
int g=0;
for(int k=1; k<=8; k++)
{
g+=B[i][(j-1)*8+k]*(1LL<<(k-1));
}
// cout<<g<<endl;
// cout<<g<<endl;
d+=de[nn][j][g];
}
//cout<<d<<endl;
ans^=d;
// cout<<ans<<endl;
}
}
printf("%d\n",ans);
return 0;
}
牛客国庆集训派对Day2的更多相关文章
- 牛客国庆集训派对Day2 Solution
A 矩阵乘法 思路: 1° 牛客机器太快了,暴力能过. #include <bits/stdc++.h> using namespace std; #define N 5000 in ...
- 牛客国庆集训派对Day2 H 期望
小贝喜欢玩卡牌游戏.某个游戏体系中共有N种卡牌,其中M种是稀有的.小贝每次和电脑对决获胜之后都会有一个抽卡机会,这时系统会随机从N种卡中选择一张给小贝.普通卡可能多次出现,而稀有卡牌不会被重复抽到.小 ...
- 牛客国庆集训派对Day2 F、平衡二叉树 【构造+记忆化搜索】
任意门:https://www.nowcoder.com/acm/contest/202/F 时间限制:C/C++ 1秒,其他语言2秒空间限制:C/C++ 1048576K,其他语言2097152K6 ...
- 图论+思维(2019牛客国庆集训派对day2)
题意:https://ac.nowcoder.com/acm/contest/1107/J n个点的完全图编号0-n-1,第i个点的权值为2^i,原先是先手选取一些边,然后后手选取一些点,满足先手选取 ...
- 2019牛客国庆集训派对day2
A(模拟): #include <bits/stdc++.h> using namespace std; const int inf = 0x3f3f3f3f; const double ...
- 牛客国庆集训派对Day6 A Birthday 费用流
牛客国庆集训派对Day6 A Birthday:https://www.nowcoder.com/acm/contest/206/A 题意: 恬恬的生日临近了.宇扬给她准备了一个蛋糕. 正如往常一样, ...
- 2019牛客国庆集训派对day5
2019牛客国庆集训派对day5 I.Strange Prime 题意 \(P=1e10+19\),求\(\sum x[i] mod P = 0\)的方案数,其中\(0 \leq x[i] < ...
- 牛客国庆集训派对Day1 L-New Game!(最短路)
链接:https://www.nowcoder.com/acm/contest/201/L 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 1048576K,其他语言20 ...
- 牛客国庆集训派对Day4 J-寻找复读机
链接:https://www.nowcoder.com/acm/contest/204/J 来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 1048576K,其他语言20 ...
随机推荐
- malloc和calloc用法
malloc和calloc用法 #include <stdio.h> #include <stdlib.h> int main(){ int n; printf("i ...
- Node 各个版本支持ES2015特性的网站
如果想了解Node 各个版本支持ES2015到那个程度,可以看下面网站. https://node.green/
- linux上部署SpringBoot项目及遇到的问题
打开sftp步骤, 在显示的已连接的窗口上右键, 选择connect SFTP Session就可以打开文件上传的窗口 从windows上传文件到linux, 首先linux需要先切换到想要保存文件的 ...
- Python虚拟环境笔记
虚拟环境 为什么需要虚拟环境: 到目前位置,我们所有的第三方包安装都是直接通过pip install xx的方式进行安装的,这样安装会将那个包安装到你的系统级的Python环境中.但是这样有一个问题, ...
- 【Linux常见问题】Centos7的网络配置问题
在配置Centos7网络的时候,可能出出现虚拟机.本地以及外网三者之间ping不通的问题,可以从以下的几个方面排查: 1.确定需要管理员权限才能修改配置网络,如下图: 需要点下更改设置,然后出现下面的 ...
- UVA1627-Team them up!(动态规划)
Problem UVA1627-Team them up! Total Submissions:3577 Solved:648 Time Limit: 3000 mSec Problem Descr ...
- 洛谷P2845-Switching on the Lights 开关灯
Problem 洛谷P2845-Switching on the Lights 开关灯 Accept: 154 Submit: 499Time Limit: 1000 mSec Memor ...
- 转://Oracle undo 自动调优
Oracle 10gr2的后续版本中添加了UNDO信息最短保留时间段自动调优的特性,不再仅仅依据参数UNDO_RETENTION的设定,其调优原则如下:1. 当UNDO TABLESPACE为 fix ...
- 【转】Windows系统中ckplayer视频边下边放,视频转码mp4及"last atom in file was not a moov atom"问题
视频转码成mp4格式并添加关键帧: 1.先下载与自己操作系统相对应的的FFmpeg软件.官网传送门:http://ffmpeg.zeranoe.com/builds/ 下载static版的就可以,zi ...
- 用户对动态PHP网页访问过程,以及nginx解析php步骤
www.example.com | Nginx | 路由到www.example.com/index.php | 加载nginx的fast-cgi模块 | fast-cgi监听127.0.0.1:90 ...