做雕塑网站,用个人的信息备案网站吗,网站怎么发布,中企动力中山分公司网站链接
Problem - 620C - Codeforces
思路 :
贪心 : 对于每一段区间#xff0c;从前往后贪#xff0c;如果前面一段区间有重复数字#xff0c;那么就直接合并成答案的一段区间#xff0c;然后继续寻找下一段区间#xff0c;对于最后一段#xff0c;如果没有匹配的话从前往后贪如果前面一段区间有重复数字那么就直接合并成答案的一段区间然后继续寻找下一段区间对于最后一段如果没有匹配的话就直接合并到已经加入到答案的最后一段区间里面
代码 :
#includebits/stdc.h
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl \n
#define lowbit(x) (x(-x))
#define sz(a) (int)a.size()
#define pb push_back
#define all(a) a.begin(), a.end()
#define int long long
#define PII pairint,int
typedef long long LL;
const int mod 1e97;
const int N 3e510;
using namespace std;int n ;
int a[N];inline void solve(){cin n;vectorPII b;int ans 0;unordered_mapint,int mp;int pre 1;for(int i1;in;i){cin a[i];}for(int i1;in;i){mp[a[i]];if(mp[a[i]]1){ans ;mp.clear();b.push_back({pre,i});pre i 1;}}int x,y;if(!b.size()) cout -1 endl;else{cout ans endl;int len b.size();for(int i0;ilen-1;i) cout b[i].first b[i].second endl;cout b[len-1].first n endl;}return ;
}signed main()
{IOSint _ 1;// cin _;while(_ --) solve();return 0;
}