uva 11572 Unique Snowflakes (唯一的雪花)
2017-08-12 13:48
381 查看
题目链接
题意输入一个长度为n 的序列,找到一个尽量长的连续子序列Al~Ar,使得该序列中没有相同元素。
分析 用左右端点去遍历 然后用set查重。
题意输入一个长度为n 的序列,找到一个尽量长的连续子序列Al~Ar,使得该序列中没有相同元素。
分析 用左右端点去遍历 然后用set查重。
#include<bits/stdc++.h> using namespace std; int a[1000005],len,l,r,t,n; int main (void){ ios::sync_with_stdio(false); cin>>t; while(t--){ cin>>n; for(int i=0;i<n;i++) cin>>a[i]; set<int>s; l=0;r=0;len=0; while(r<n){ while( r<n && !s.count(a[r])) s.insert(a[r++]); len=max(len,r-l); s.erase(a[l++]); } cout<<len<<endl; } return 0; }
相关文章推荐
- UVA - 11572 Unique Snowflakes(唯一的雪花) : 滑动窗口
- uva 11572 - Unique Snowflakes(Towpointer)
- 解题报告 之 UVA11572 Unique Snowflakes
- UVA-11572-Unique snowflakes
- 例题8-7 唯一的雪花(Unique snowflakes, UVa 11572)
- UVa 11572 Unique Snowflakes
- Uva11572 Unique Snowflakes【滑动窗口】【例题8-7】
- uva 11572 unique snowflakes——yhx
- UVA - 11572 Unique Snowflakes
- UVA 11572 - Unique Snowflakes
- uva 11572 - Unique Snowflakes(与书上方法略有不同)
- UVa 11572 Unique snowflakes【滑动窗口】
- (白书训练计划)UVa 11572 Unique Snowflakes(窗口滑动法)
- UVA 11572 Unique Snowflakes(滑窗|双指针)
- UVA11572 Unique Snowflakes(滑窗)
- 唯一的雪花(Unique snowflakes,UVa 11572)滑动窗口+set
- uva 11572 Unique Snowflakes
- uva 11572 unique snowflakes——yhx
- UVA 11572 Unique Snowflakes
- Unique Snowflakes UVA - 11572