损坏的RAID5

string讀入卡cin

関同步 ios::sync_with_stdio(false)

由塊號映射到具體位置

塊號id對應第col個字符串

字符串開始的位置st

 #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int n,s,l;
bool vis[];
string t[];
int calraw(int id)
{
return id/(s*(n-));
}
int calcol(int id)
{
int st = (n-calraw(id)%n)%n;
id -= (id/((n-)*s))*(n-)*s;
int ans = (st + id/s)%n;
// cout<<st<<" stid "<<id<<endl;
return ans;
}
int st(int id)
{
int r=calraw(id);
int ans=r**s+*(id%s);
return ans;
}
int ati(char c)
{
if(c>='A'&&c<='Z')
return c-'A'+;
else return c-'';
}
char ita(int x)
{
if(x>=)
return char(x-+'A');
else return char(''+x);
}
string Xor(string s,string t)
{
string ans="";
for(int i=;i<;i++){
int a = ati(s[i]);
int b = ati(t[i]);
ans.append(,ita(a^b));
}
return ans;
}
int main()
{
ios::sync_with_stdio(false);
cin>>n>>s>>l;
int id;
for(int i=;i<l;i++){
cin>>id;
cin>>t[id];
vis[id]=;
}
int len=t[id].length();
int m;
cin>>m; for(int i=;i<m;i++){
cin>>id;
int x=calcol(id);
if(vis[x]){
int y =st(id);
if(y>=len){
cout<<"-\n";
continue;
}
for(int i=y;i<y+;i++){
cout<<t[x][i];
}
cout<<'\n';
}else if(!vis[x]&&l==n-){
int y =st(id);
string S="",T;
if(y>=len){
//puts("-");
cout<<"-\n";
continue;
} for(int i=;i<n;i++){
if(vis[i]){
if(S==""){
S=t[i].substr(y,);
}else{
T=t[i].substr(y,);
S=Xor(S,T);
}
}
}
cout<<S<<'\n';
}
else{
cout<<"-\n";
}
} }
/**
3 2 2
0 000102030405060710111213141516172021222324252627
1 A0A1A2A3A4A5A6A7B0B1B2B3B4B5B6B7C0C1C2C3C4C5C6C7
2 1 2
0 000102030405060710111213141516172021222324252627
1 000102030405060710111213141516172021222324252627
*/

90分代碼:

由其餘已知的n-1個字符串預處理推出其餘一個字符串

查詢O(1)

預處理TLE了

#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include<cstring>
#include<cstdlib>
using namespace std; int n, s, l;
bool vis[];
string t[];
int calraw(int id)
{
return id / (s * (n - ));
}
int calcol(int id)
{
int st = (n - calraw(id) % n) % n;
id -= (id / ((n - ) * s)) * (n - ) * s;
int ans = (st + id / s) % n;
return ans;
}
int st(int id)
{
int r = calraw(id);
int ans = r * * s + * (id % s);
return ans;
}
int ati(char c)
{
if (c >= 'A' && c <= 'Z')
return c - 'A' + ;
else
return c - '';
}
char ita(int x)
{
if (x >= )
return char(x - + 'A');
else
return char('' + x);
} bool tmp[];
int main()
{
ios::sync_with_stdio(false);
cin>>n>>s>>l;
int id;
for (int i = ; i < l; i++)
{
cin >> id;
cin >> t[id];
vis[id] = ;
}
int len = t[id].length();
if (l == n - )
{
string ss="";
int res=; for (int j = ; j < len; j++)
{
memset(tmp,,sizeof tmp);
for (int i = ; i < n; i++)
{
if(vis[i]&&t[i][j]>='A'&&t[i][j]<='Z'){
tmp[t[i][j]-'A'+]+=;
tmp[t[i][j]-'A'+]%=;
}else if(vis[i]){
tmp[t[i][j]-'']+=;
tmp[t[i][j]-'']%=;
}else if(!vis[i]){
res=i;
}
}
int cnt=;
for(int k=;k<;k++){
if(tmp[k])cnt^=k;
}
ss.append(,ita(cnt)); }
vis[res]=;
t[res]=ss; }
int m;
cin >> m; for (int i = ; i < m; i++)
{
cin>>id;
if(id>=(n-)*s*(len/(*s))){
cout<<"-\n";
continue;
}
int x = calcol(id);
//cout<<x<<endl;
if (vis[x])
{
int y = st(id);
// cout<<y<<endl;
if (y >= t[x].length())
{
cout<<"-\n";
continue;
}
for (int i = y; i < y + ; i++)
{
cout<<t[x][i];
}
cout<<"\n";
}
else
{
cout<<"-\n";
}
}
}
/**
3 2 2
0 000102030405060710111213141516172021222324252627
1 A0A1A2A3A4A5A6A7B0B1B2B3B4B5B6B7C0C1C2C3C4C5C6C7
2 1 2
0 000102030405060710111213141516172021222324252627
1 000102030405060710111213141516172021222324252627
*/

损坏的RAID5的更多相关文章

  1. csp 201903-3 损坏的RAID5

    问题描述 试题编号: 201903-3 试题名称: 损坏的RAID5 时间限制: 1.0s 内存限制: 512.0MB 问题描述: 答题栏     核

  2. ccf 201903-3 损坏的RAID5

    9月份考ccf,暑假打算做一些往年的真题... 这个题,一开始真是把我给看晕了 传说中的大模拟,果然不简单QAQ 首先读懂题目就是一个大难点,特别是对于我这种题目一长就看不进去的人来说 读懂题目之后, ...

  3. CCF-CSP题解 201903-3 损坏的RAID5

    先吐槽先吐槽!因为输入太大,需要用fgets,读n个字符或读到回车终止. char *fgets(char *str, int n, FILE *stream) 因为scanf模拟考试T了10+次.因 ...

  4. 试题编号: 201903-3 试题名称: 损坏的RAID5

    这题的数据未免也太水了,题目的意思好像默认是每块磁盘装载数据的长度是相等的.我写了判断每次取数据是否会超过每块磁盘存的数据的长度,然而并没有什么卵用.交上去20分,写了个数据测了下,如果要求的块太大的 ...

  5. 服务器较稳妥的磁盘阵列方案:RAID5+热备盘

    最近公司这边要整个数据中心,但是我们这边磁盘阵列的方案选择方面需要做好万全的测试 内部测试的服务器当初损坏的磁盘1个做的raid5直接换个新磁盘做替换rebuild就行了 但是现在想的方法是5+1的方 ...

  6. Linux学习之CentOS(二十八)--RAID原理基础及Linux下软件RAID配置

    一.RAID的原理基础 在 讲解RAID的原理基础之前,我们首先来了解一下传统磁盘的劣势.我们知道一台PC机种都会包含CPU.内存.主板.硬盘.网卡等硬件,影响计算机性能的 组建包括:CPU.主板总线 ...

  7. Linux -RAID

    转自:http://www.cnblogs.com/xiaoluo501395377/archive/2013/05/25/3099464.html 硬盘类型 速度 SATA <150M/s S ...

  8. RAID磁盘阵列是什么(一看就懂)

    在单机时代,采用单块磁盘进行数据存储和读写的方式,由于寻址和读写的时间消耗,导致I/O性能非常低,且存储容量还会受到限制.另外,单块磁盘极其容易出现物理故障,经常导致数据的丢失.因此大家就在想,有没有 ...

  9. 服务器RAID设置以及简单理解

    备注: 适用于测试环境,生产环境暂时未验证 1. RAID种类 最高性能的RAID0 完全拆分所有的IO 不进行校验 但是单盘损坏, 数据完全丢失 最高损耗的RAID1 损失一半的存储容量, 做镜像, ...

随机推荐

  1. JavaScript学习总结(一)——闭包、对象、函数

    一.闭包(Closure) 1.1.闭包相关的问题 请在页面中放10个div,每个div中放入字母a-j,当点击每一个div时显示索引号,如第1个div显示0,第10个显示9:方法:找到所有的div, ...

  2. ubuntu 安装 CUDA、 cuDNN 的tips

    CUDA 查看驱动兼容性:https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html 查看GCC 与CUDA 驱动版本的兼容性 ...

  3. array_chunk的用法和php操作大数据

    一.array_chunk() 函数 二.php操作大数据 1.在操作大数量数据与数据库交互时,比如插入大量数据,db就会报错,这时可以把原本的数据用array_chunk分隔成几个数组块,再循环插入 ...

  4. kafka 教程(一)-初识kafka

    消息队列 MQ 消息队列就是 消息 message 加 队列 queue,是一种消息传输的容器,提供生产和消费 API 来存储和获取消息. 消息队列分两种:点对点(p2p).发布订阅(pub/sub) ...

  5. 一篇关于for循环的简单题练习,

    package practice; public class Practice { public static void main(String[] args) { 7.      *     **  ...

  6. ShareSdk等等(三方登录与支付冲突问题)

    1.必须实现前两个方法,第三个方法照成支付回调有问题. //必须实现的方法 - (BOOL)application:(UIApplication *)application handleOpenURL ...

  7. java面试题全集(上)

    1.面向对象的特征有哪些方面? 答:面向对象的特征主要有以下几个方面: - 抽象:抽象是将一类对象的共同特征总结出来构造类的过程,包括数据抽象和行为抽象两方面.抽象只关注对象有哪些属性和行为,并不关注 ...

  8. AIX中磁带设备的使用

    1.AIX中的磁带设备 在UNIX系统中,磁带一般具有如下共同属性. 磁带密度:指磁带使用时采用的低密度方式和高密度方式   回退操作:磁带一次写入操作完成后,是否立刻倒带,回退到磁带头部.   位置 ...

  9. Django中数据库的增删改查

    本随笔使用的是pycharm专业版2019.1.3.Django==1.9.8.Python2.7 这里的Django后台使用了ORM(Object Relational Mapping),全称对象关 ...

  10. 22_4mybatis——动态SQL

    1.创建maven工程并导入坐标 <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE confi ...