#include<iostream>#include<vector>#include<map>usingnamespace std;intmain(){int n, m; cin >> n >> m;
vector<string> a, b, ans;
map<string,bool> aa, bb, mp;for(int i =0; i < n; i ++){
string ss; cin >> ss;if(aa[ss])continue;
aa[ss]=1;
a.push_back(ss);}for(int i =0; i < m; i ++){
string ss; cin >> ss;if(bb[ss])continue;
bb[ss]=1;
b.push_back(ss);}int l =0, r =0;while(l < a.size()&& r < b.size()){if(!mp[a[l]]){
mp[a[l]]=1;
ans.push_back(a[l]);}if(!mp[b[r]]){
mp[b[r]]=1;
ans.push_back(b[r]);}
l ++, r ++;}while(l < a.size()){if(!mp[a[l]]){
mp[a[l]]=1;
ans.push_back(a[l]);}
l ++;}while(r < b.size()){if(!mp[b[r]]){
mp[b[r]]=1;
ans.push_back(b[r]);}
r ++;}for(int i =0; i < ans.size(); i ++){
cout << ans[i];if(i != ans.size()-1) cout << endl;}return0;}
D
#include<iostream>#include<vector>usingnamespace std;typedeflonglong ll;constint N =1e6+2;int f[N], w[N], v[N];bool vis[N];intfind(int x){return x == f[x]? x : f[x]=find(f[x]);}
ll fx(ll x){return x *(x -1)/2;}intmain(){int n, m; cin >> n >> m;for(int i =1; i <= n; i ++) f[i]= i, w[i]=1;while(m --){int a, b; cin >> a >> b;int pa =find(a), pb =find(b);if(pa == pb){
v[pa]++;continue;}
f[pa]= pb;
w[pb]+= w[pa];
v[pb]+= v[pa]+1;}
ll res =0;
vector<int> ans;int cnt1 =0;bool ok =0;for(int i =1; i <= n; i ++){int x =find(i);if(vis[x])continue;
vis[x]=1;
ans.push_back(x);if(w[x]==1) cnt1 ++;elseif(v[x]!=fx(w[x])) ok =1;}for(auto i : ans) res +=fx(w[i])- v[i];if(!ok){if(cnt1 >=2) res ++;elseif(!cnt1){int a =1e6, b =1e6;for(auto i : ans){if(w[i]< a){
a = w[i];if(a < b)swap(a, b);}}
res +=fx(a + b)-fx(a)-fx(b);}else{
ll add =1e12;for(auto i : ans)if(w[i]!=1) add =min(add,fx(w[i]+1)- v[i]);
res += add;}}
cout << res << endl;return0;}
J
#include<iostream>#include<cmath>usingnamespace std;constdouble eps =1e-8;doubledis2(double x1,double y1,double x2,double y2){returnsqrt(pow(x1 - x2,2)+pow(y1 - y2,2));}structPoint{double x, y, r;double x1, y1, x2, y2;Point(double x1,double y1,double x2,double y2){
x =(x1 + x2)/2;
y =(y1 + y2)/2;
r =dis2(x1, y1, x2, y2)/2;}Point(int x,int y):x(x),y(y){}};doubleManDis(double x1,double y1,double x2,double y2){returnabs(x1 - x2)+abs(y1 - y2);}doublefindy(Point a, Point b,double x){double dx =abs(x - b.x);double dy =sqrt(b.r * b.r - dx * dx);if(a.y < b.y)return b.y - dy;return b.y + dy;}doublesolve(){int x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
Point a(x1, y1, x2, y2);
cin >> x1 >> y1 >> x2 >> y2;
Point b(x1, y1, x2, y2);double l, r;if(a.x < b.x) l = b.x - b.r, r = b.x;else l = b.x, r = b.x + b.r;while(abs(l - r)>= eps){double L =(2* l + r)/3, R =(l + r *2)/3;if(ManDis(a.x, a.y, L,findy(a, b, L))<=ManDis(a.x, a.y, R,findy(a, b, R))) r = R;else l = L;}returnManDis(a.x, a.y, l,findy(a, b, l));}intmain(){int n; cin >> n;while(n --)printf("%.10lf\n",solve());return0;}
L
#include<iostream>usingnamespace std;intmain(){int n, m; cin >> n >> m;int res =2;while(n --){int x; cin >> x;
res =max(res,(x + m -1)/ m);}
cout << res << endl;return0;}