返回

CodeForces 828C String Reconstruction

发布时间:2022-11-28 15:14:23 202
# c++# 信息

题目链接:​​http://codeforces.com/contest/828/problem/C​​​
题意:告诉你一些字符串的信息,要求你重组并输出字典序最小的这个字符串,告诉你的信息是,某个子串在某几个位置出现,保证给的信息不冲突
解析:直接模拟做,但是要避免掉一些重复的情况

#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6+100;
string s[maxn];
vector<pair<int,int> >tmp;
int main(void)
{
int n,k,x;
scanf("%d",&n);
for(int i=0;i<n;i++)
{
cin>>s[i]>>k;
for(int j=0;j<k;j++)
{
scanf("%d",&x);
tmp.push_back(make_pair(x,i));
}
}
sort(tmp.begin(),tmp.end());
string ans;
int len = 1;
for(unsigned i = 0;i<tmp.size();i++)
{
int t1 = tmp[i].first,t2 = tmp[i].second;
while(t1>len)
{
ans += 'a';
len++;
}
//len-t1可以避免重复添加
for(unsigned j = len-t1;j<s[t2].length();j++)
{
ans += s[t2][j];
len++;
}
}
cout<<ans<<endl;
return 0;
}

 

特别声明:以上内容(图片及文字)均为互联网收集或者用户上传发布,本站仅提供信息存储服务!如有侵权或有涉及法律问题请联系我们。
举报
评论区(0)
按点赞数排序
用户头像
精选文章
thumb 中国研究员首次曝光美国国安局顶级后门—“方程式组织”
thumb 俄乌线上战争,网络攻击弥漫着数字硝烟
thumb 从网络安全角度了解俄罗斯入侵乌克兰的相关事件时间线
下一篇
CodeForces 820B Mister B and Angle in Polygon 2022-11-28 14:56:28