损坏的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. linux-查询某软件的安装的目录

    eg:jenkins\\\ rpm -ql jenkins 安装目录/var/lib/jenkins 配置文件 /etc/sysconfig/jenkins 日志目录 /var/log/jenkins ...

  2. 怎么编写properties文件

    1. 注释 在properties中注释是采用#号开头的方式来进行注释的 2. 编写properties文件 在properties中,一行就是一个键值对,简单的理解就是一行可以保存一个变量,键和值之 ...

  3. npm学习(十一)之package-lock.json

    package-lock.json 描述 对于npm修改node_modules树或package.json的任何操作,都会自动生成package.json,它描述生成的确切树,以便后续安装能够生成相 ...

  4. log4net日志输出配置即输出到文件又输出到visual studio的output窗口

    <configuration> <configSections> <section name="log4net" type="log4net ...

  5. 在eclipse中创建第一个java应用程序,并在控制台输出“hello world”。

    package com.fs.test; public class HelloWorld { public void aMethod() { } public static void main(Str ...

  6. Git 设置 用户名 和 邮箱

    git config --global user.name "Vincent" git config --global user.email "********@qq.c ...

  7. python-装饰器1

    python-装饰器1 定义本质就是函数,(装饰其他函数)就是为其他函数添加附加功能原则:1.不能修改被装饰的函数的源代码2.不能修改被装饰的函数的调用方式 def logger(): print(' ...

  8. SpringCloud系列:前言

    准备写springcloud系列了,先吐槽下自己,之前准备把学到的东西写下来,都因为工作或自己太懒(主要还是懒),写了个开篇就GG了,这次springcloud一定会坚持写完.加油! 这里先说下我搭建 ...

  9. Awkward Response AtCoder - 2656 ( 二分+交互题)

    Problem Statement This is an interactive task. Snuke has a favorite positive integer, N. You can ask ...

  10. 二叉树中序遍历,先序遍历,后序遍历(递归栈,非递归栈,Morris Traversal)

    例题 中序遍历94. Binary Tree Inorder Traversal 先序遍历144. Binary Tree Preorder Traversal 后序遍历145. Binary Tre ...