题目链接:http://codeforces.com/contest/828/problem/C

题解:有点意思的题目,可用优先队列解决一下具体看代码理解。或者用并查集或者用线段树都行。

#include <iostream>
#include <cstring>
#include <queue>
#include <vector>
#include <cstdio>
#include <map>
#include <string>
#include <vector>
using namespace std;
const int M = 2e6 + 10;
const int N = 1e5 + 10;
int pos;
struct TnT {
int sta, ed , num;
TnT() {}
TnT(int sta , int ed , int num):sta(sta), ed(ed), num(num) {}
bool operator <(const TnT &a) const {
return ed - pos > a.ed - pos;
}
};
priority_queue<TnT>q;
vector<int>vc[M];
string s[N];
int main() {
int n, k, pp;
scanf("%d" , &n);
int Max = 1;
for(int i = 1 ; i <= n ; i++) {
cin >> s[i];
cin >> k;
int len = s[i].size();
for(int j = 0 ; j < k ; j++) {
cin >> pp;
Max = max(Max , pp + len - 1);
vc[pp - 1].push_back(i);
}
}
for(pos = 0 ; pos < Max ; pos++) {
int len = vc[pos].size();
for(int i = 0 ; i < len ; i++) {
int L = s[vc[pos][i]].size();
q.push(TnT(pos , pos + L - 1 , vc[pos][i]));
}
if(q.empty()) cout << 'a';
else {
cout << s[q.top().num][pos - q.top().sta];
while(!q.empty()) {
if(q.top().ed == pos) q.pop();
else break;
}
}
}
cout << endl;
return 0;
}

codeforces 828 C. String Reconstruction(思维+优先队列)的更多相关文章

  1. CodeForces - 827A:String Reconstruction (基础并查集)

    Ivan had string s consisting of small English letters. However, his friend Julia decided to make fun ...

  2. Educational Codeforces Round 94 (Rated for Div. 2) String Similarity、RPG Protagonist、Binary String Reconstruction、Zigzags 思维

    题目链接:String Similarity 题意: 首先题目定义了两个串的相似(串的构成是0.1),如果两个串存在对于一个下标k,它们的值一样,那么这两个串就相似 然后题目给你一个长度为2n-1的串 ...

  3. Codeforces Round #423 (Div. 2, rated, based on VK Cup Finals) C. String Reconstruction 并查集

    C. String Reconstruction 题目连接: http://codeforces.com/contest/828/problem/C Description Ivan had stri ...

  4. Codeforces - 828C String Reconstruction —— 并查集find()函数

    题目链接:http://codeforces.com/contest/828/problem/C C. String Reconstruction time limit per test 2 seco ...

  5. Codeforces C - String Reconstruction

    C - String Reconstruction 方法一:把确定的点的父亲节点设为下一个点,这样访问过的点的根节点都是没访问过的点. 代码: #include<bits/stdc++.h> ...

  6. CodeForces - 828C String Reconstruction 并查集(next跳)

    String Reconstruction Ivan had string s consisting of small English letters. However, his friend Jul ...

  7. Codeforces828 C. String Reconstruction

    C. String Reconstruction time limit per test 2 seconds memory limit per test 256 megabytes input sta ...

  8. CF1400-C. Binary String Reconstruction

    CF1400-C. Binary String Reconstruction 题意: 对于一个二进制字符串\(s\),以及一个给定的\(x\),你可以通过一下操作来得到字符串\(w\): 对于字符串\ ...

  9. [CodeForces]String Reconstruction

    http://codeforces.com/contest/828/problem/C 并查集的神奇应用. #include<bits/stdc++.h> using namespace ...

随机推荐

  1. SpringBoot的yml配置

    Spring Boot的yml配置 #开发配置 spring: data: solr: host: http://localhost:6789/solr/mote mvc: view: # 页面默认前 ...

  2. 前端面试 js 你有多了解call,apply,bind?

    函数原型链中的 apply,call 和 bind 方法是 JavaScript 中相当重要的概念,与 this 关键字密切相关,相当一部分人对它们的理解还是比较浅显,所谓js基础扎实,绕不开这些基础 ...

  3. ipad pro 为什么不行

    TalkingData公布的数据显示,iPad Pro在中国发行首月的销量仅为49 300台,而此前iPad Air 2发行首月后销量曾高达55.7万台.那么到底是什么原因,让这个被寄予厚望的iPad ...

  4. python 字符串格式化format

    通过{}和:来代替传统%方式   1.位置参数 位置参数不受顺序约束,且可以为{},只要format里有相对应的参数值即可,参数索引从0开,传入位置参数列表可用*列表 >>> li ...

  5. MongoDB之数据库备份与恢复

    MongoDB之数据备份与恢复 一,需求 一段时间备份数据库数据,以防意外导致数据丢失 二,备份与恢复 2.1,数据库备份 1,常用命令格式 mongodump -h IP --port 端口 -u ...

  6. Activiti6系列(2)- 运行和编译

    前言 Activiti6.0在官网已经无法下载了,需要在Github上下载. 下载地址: https://github.com/Activiti/Activiti/releases/download/ ...

  7. Selenium+java - Ajax浮动框处理

    Ajax浮动框 我们常遇到的某些网站首页输入框,点击后显示的浮动下拉热点,如下图: 实际案例 模拟场景如下: hao123首页搜索输入框,单击搜索框,点击浮动框中的哪吒票房破30亿,单击后选项的文字内 ...

  8. java虚拟机学习笔记(六)---垃圾收集算法

    主要讨论集中垃圾收集算法的思想及发展过程. 1.标记-清除法 最基础的收集算法是标记-清除法,算法分为标记和清除两个阶段:首先标记出所有需要回收的对象,在标记完成后统一回收所有被标记的对象,其标记过程 ...

  9. TI MSP430工程配置及2019年电赛A题编程示例(使用430 F5529)

    配置 第一步:右击工程,选择Options 第二步:在General Options的Target选项卡里选择对应的器件Device,这里是MSP430G2231 第三步:在Debugger里选择FE ...

  10. java并发编程(一)----线程基础知识

    在任何的生产环境中我们都不可逃避并发这个问题,多线程作为并发问题的技术支持让我们不得不去了解.这一块知识就像一个大蛋糕一样等着我们去分享,抱着学习的心态,记录下自己对并发的认识. 1.线程的状态: 线 ...