Description You are given two arrays aa and bb, both consisting of nn integers. In one move, you can choose two indices ii and jj (1≤i,j≤n1≤i,j≤n; i≠ji =j) and swap aiai with ajaj and bibi with bjbj. You have to perform the swap in both arrays. You are allowed to ...
Codeforces Round #622 (Div. 2)A~~C1 dp A 水题: 判断7种情况有没就行了 #include<bits/stdc++.h> using namespace std; int main() { int t; cin>>t; while(t--) { int a[3]; cin>>a[0]>>a[1]>>a[2]; sort(a,a+3); int ans=0; if(a[2]) ans++,a[2]--; if(a 杨...
sort(h+1,h+N+N+1);for(inti=1;i<=N+N;i++){intj=i;while(j+1<=N+N&&h[j+1]==h[i]) j++; ans+=(longlong)(j-i+1)*(j-i)/2; i=j; } printf("%I64d\n",ans);return0; }
sort(m[i].rbegin(),m[i].rend());intmaxn=-1;for(inti=0;i<k;++i)for(intj=i;j<k;++j){//注意不能如下注释那么写,因为可以(k-1)+(k-1)+2这样构造出一个k倍的//for(int j=0;j<k-i;++j){inttemp=(k-i-j+k)%k;if(!m[temp].empty()&&!m[i].empty()&&!m[j].empty()...
sort(p+1,p+n+1); for(i=1;i<=n;i++)for(j=1;j<=n;j++)dis[i][j] = Dis(p[i],p[j]), dp[i][j] = inf; dp[1][1] = 0; for(i=2;i<=n;i++) { for(j = 1;j < i; j++) { dp[i][j] = min(dp[i-1][j]+dis[i][i-1], dp[i][j]); ...
sort(pro.begin() , pro.end()) ; for(int i = 0 ; i < pro.size() ; i++) swap(brr[n + 1 - pro[i]] , brr[n - i]) ; for(int i = 1 ; i <= n ; i++) ans[brr[i]] = i ; for(int i = 1 ; i <= n ; i++) cout << ans[i] << ' ' ; ...
//Created by just_sort 2016/9/9 18:40 //Copyright (c) 2016 just_sort.All Rights Reserved // #include <bits/stdc++.h> usingnamespacestd; typedeflonglongLL; constintmaxn=1e6+10; intn,a[maxn],b[maxn]; structFastIO { staticconstintS=1310720; ...
http://codeforces.com/gym/101484/problem/E 题解 凸包板题 #define_CRT_SECURE_NO_WARNINGS#include<cmath>#include<iostream>#include<stdio.h>#include<algorithm>#include<cstring>#include<vector>usingnamespacestd;#definerep(i,t,n) for(int i =(t);i<=(n);++i)#defineper(i,n,t) for(int ...