D. Closest Equals Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnline/problem.php?id=3224 Description You are given sequence a1, a2, ..., an and m queries lj, rj (1 ≤ lj ≤ rj ≤ n). For each query you need to print the minimu…
题目链接: http://codeforces.com/problemset/problem/522/D D. Closest Equals time limit per test3 secondsmemory limit per test256 megabytes 问题描述 You are given sequence a1, a2, ..., an and m queries lj, rj (1 ≤ lj ≤ rj ≤ n). For each query you need to print…
题目链接: D. Closest Equals time limit per test 3 seconds memory limit per test 256 megabytes input standard input output standard output You are given sequence a1, a2, ..., an and m queries lj, rj (1 ≤ lj ≤ rj ≤ n). For each query you need to print the…
题目链接:http://codeforces.com/contest/522/problem/D 题目大意: 给你一个长度为n的序列,然后有m次查询,每次查询输入一个区间[li,lj],对于每一个查询,输出在这个区间内的两个相等的数的最短距离,如果没有相等的则输出-1. 线段树+扫描线,线段树维护的值是区间的最小值,从后往前扫,然后每次要做的事有两个: 1.判断当前这个位置 i 的数刚刚是不是出现过,假设刚刚出现的位置是 l ,如果出现过,则在线段树中把l这个位置的值更新为 l - i,同时更…