损坏的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. [转帖]教你如何修改运行中的docker容器的端口映射

    教你如何修改运行中的docker容器的端口映射   在docker run创建并运行容器的时候,可以通过-p指定端口映射规则.但是,我们经常会遇到刚开始忘记设置端口映射或者设置错了需要修改.当dock ...

  2. java 集合 队列(Queue)

    特点:特殊线性表,先进先出(FIFO first-in-first-out) 方法: java5中 添加java.util.Queue接口,java.util.Collection 的扩展类 add( ...

  3. POJ2387 Til the Cows Come Home (最短路 dijkstra)

    AC代码 POJ2387 Til the Cows Come Home Bessie is out in the field and wants to get back to the barn to ...

  4. 360度3D 旋转插件

    Circlr插件是一款基于jQuery的可以对图片进行360度全方位旋转展示的插件.Circlr通过按一定角度规律拍摄的产品图片,制作出可以使用鼠标拖动.鼠标滚轮和移动触摸来进行图片逐帧旋转的效果.比 ...

  5. 作业调度框架Quartz.NET-现学现用-01-快速入门 - 简书

    原文:作业调度框架Quartz.NET-现学现用-01-快速入门 - 简书 前言 你需要应用执行一个任务吗?这个任务每天或每周星期二晚上11:30,或许仅仅每个月的最后一天执行.一个自动执行而无须干预 ...

  6. Python杂章

    IDLE常用的快捷键: Ctrl+]:缩进代码 Ctrl+[:取消缩进 Alt+3:注释代码 Alt+4:去掉注释 F5:运行代码 Ctrl+Z:撤销一步 print('你好,Python!')

  7. laravel 学习之第二章

    Controller Controller之Request 获取请求的值 namespace App\Http\Controllers; use Illuminate\http\Request; pu ...

  8. Linux下单机部署ELK日志收集、分析环境

    一.ELK简介 ELK是elastic 公司旗下三款产品ElasticSearch .Logstash .Kibana的首字母组合,主要用于日志收集.分析与报表展示. ELK Stack包含:Elas ...

  9. Codeforces 964 等比数列逆元处理 贪心删偶数度节点

    A B C 注意sum要在mod范围内 且不能用/a*b来推 #include<bits/stdc++.h> using namespace std; typedef long long ...

  10. Django学习系列5:为视图编写单元测试

    打开lists/tests.py编写 """向浏览器返回真正的HTML响应,添加一个新的测试方法""" from django.test i ...