【例题 8-7 UVA - 11572】Unique Snowflakes
2018-01-03 11:03
323 查看
【链接】 我是链接,点我呀:)
【题意】
在这里输入题意
【题解】
类似尺取法。
用set判断这段区间有没有重复的数字。
有的话,就把头节点的那个数字删掉,直到没有为止。
【代码】
/* 1.Shoud it use long long ? 2.Have you ever test several sample(at least therr) yourself? 3.Can you promise that the solution is right? At least,the main ideal 4.use the puts("") or putchar() or printf and such things? 5.init the used array or any value? 6.use error MAX_VALUE? 7.use scanf instead of cin/cout? 8.whatch out the detail input require */ /* 一定在这里写完思路再敲代码!!! */ #include <bits/stdc++.h> using namespace std; const int N = 1e6; int n,a[N+10]; set<int> myset; int main(){ #ifdef LOCAL_DEFINE freopen("rush_in.txt", "r", stdin); #endif ios::sync_with_stdio(0),cin.tie(0); int T; cin >> T; while (T--){ myset.clear(); cin >> n; for (int i = 1;i <= n;i++) cin >> a[i]; int l = 1,ma = 1; myset.insert(a[1]); for (int i = 2;i <= n;i++){ while(myset.find(a[i])!=myset.end()) myset.erase(a[l++]); myset.insert(a[i]); ma = max(ma,i-l+1); } cout <<ma<<endl; } return 0; }
相关文章推荐
- Uva11572 Unique Snowflakes【滑动窗口】【例题8-7】
- uva 11572 Unique Snowflakes
- UVa 11572 - Unique Snowflakes (好题)
- uva 11572 unique snowflakes——yhx
- UVA11572 Unique Snowflakes(滑窗)
- UVA - 11572 Unique Snowflakes 滑动窗口
- UVA ~ 11572 ~ Unique Snowflakes(滑动窗口)
- uva 11572 - Unique Snowflakes
- UVa 11572 - Unique Snowflakes (滑动窗口STL_map||set) 好题!!!
- UVA11572_Unique Snowflakes
- UVa11572 Unique Snowflakes (贪心+尺取法+set容器)
- Uva11572-Unique Snowflakes
- UVA 11572(p239)----Unique snowflakes
- UVa 11572 Unique Snowflakes
- UVA 11572 Unique Snowflakes(最长无重复元素问题) 用dp思路
- Uva - 11572 - Unique Snowflakes
- UVA-11572 Unique Snowflakes(滑动窗口)
- uva 11572 - Unique Snowflakes(和书略有不同)
- uva 11572 Unique Snowflakes
- Uva 11572 Unique snowflakes