当前位置:网站首页>Ccf-csp 201903-3 damaged RAID5 70 points to be optimized
Ccf-csp 201903-3 damaged RAID5 70 points to be optimized
2022-06-09 02:42:00 【Confident little screw】
Original link :CCF-CSP 201903-3 The damaged RAID5
#include <bits/stdc++.h>
using namespace std;
const int N=1e3+10;
struct node
{
int exist=0;
string str;
vector<string> kuai;
node()
{
exist=0;
str="";
kuai={
};
}
}raid[N];
map<int,pair<int,int>> mp;
vector<int> ex;
string change(string s1,string s2)
{
string dict="0123456789ABCDEF";
unordered_map<char,int> tmp={
{
'0',0},{
'1',1},{
'2',2},{
'3',3},{
'4',4},\
{
'5',5},{
'6',6},{
'7',7},{
'8',8},{
'9',9},{
'A',10},{
'B',11},{
'C',12},\
{
'D',13},{
'E',14},{
'F',15}};
string res;
for(int i=0;i<s1.size();i++)
{
int n1=tmp[s1[i]];
int n2=tmp[s2[i]];
int n3=n1^n2;
res+=dict[n3];
}
return res;
}
int main()
{
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,s,l;
cin>>n>>s>>l;
int len=0,num=0;
for(int i=0;i<l;i++)
{
string str;
int id;
cin>>id>>str;
ex.push_back(id);
raid[id].str=str;
raid[id].exist=1;
int j=0;
len=str.size()/8;
while(j<str.size())
{
string t;
t=str.substr(j,8);
raid[id].kuai.push_back(t);
j+=8;
}
}
int cur=0,h=0,p=n;
int sum=0;
while(sum<n*len)
{
if(p==0) p=n-1;
else p--;
int cnt=(p+1+n)%n;
//cout<<"p:"<<p<<endl;
while(cnt!=p)
{
for(int i=h;i<h+s;i++)
{
pair<int,int> tmp=make_pair(cnt,i);
//cout<<cnt<<" "<<i<<" "<<cur<<endl;
mp[cur]=tmp;
cur++;
}
cnt=(cnt+1+n)%n;
}
h+=s;
sum+=n*s;
}
//cout<<"cur:"<<cur<<endl;
int m; cin>>m;
for(int i=0;i<m;i++)
{
int bi;
cin>>bi;
if(bi>=cur)
{
cout<<"-"<<endl;
continue;
}
int id=mp[bi].first;
int pos=mp[bi].second;
//cout<<id<<" "<<pos<<endl;
if(raid[id].exist==1)
{
cout<<raid[id].kuai[pos]<<endl;
}
else
{
if(l<n-1)
{
cout<<"-"<<endl;
continue;
}
string res="00000000";
for(int j=0;j<ex.size();j++)
{
res=change(res,raid[ex[j]].kuai[pos]);
}
cout<<res<<endl;
}
}
return 0;
}
边栏推荐
猜你喜欢

Deux facteurs importants affectant la défaillance de togglerowselection ()

Leetcode 1310. Subarray XOR query prefix and + XOR

Tiflash source code reading (III) design and implementation analysis of tiflash deltatree storage engine - Part 1

Summary of 14 anomaly detection methods

Self implemented web server

Leetcode 454. Quad add II hash

接口测试系列——转转交易业务场景接口测试实践

数字电路加法器 基本原理(一)

蓝桥杯_青蛙的约会_扩展欧几里得

C#中的反射原理及应用
随机推荐
What is a security tag based access control mechanism? What are the characteristics?
Calendar time operation
Jericho's notes on SPI host configuration parameters: 【 chapter 】
Leetcode 560. And is the prefix and of the subarray of K
Basic principle of digital circuit adder (I)
Range of acwing 789 numbers
pkg-config --modversion opencvPackage opencv was not found in the pkg-config search path. Perhaps y
测试、预发布、生产环境测试时的侧重点是哪些?
4426 divisible substring (enumeration + number theory)
Dynamic programming / memo method n's K splitting n's maximum addend K splitting
SQLite3 syntax (2)
String 3-387. First unique character in string
Greedy method / non 01 knapsack problem
Karmada v1.2 release: open a new era of full-text search
How does the technical leader bring down a team?
What are the focuses of testing, pre release and production environment testing?
杰理之SPI 从机【篇】
Reflection principle and application in C #
"The original, skillful and vulgar skills of cloud native" -- composition of Volume I of the national new college entrance examination in 2022
LeetCode 1155. 擲骰子的N種方法**