#include<bits/stdc++.h>#define inf 0x7fffffff//#define ll long long#define int long long//#define double long double#define eps 1e-8//#define mod 1e9+7usingnamespace std;constint mod=1e9+7;constint M=1e5;constint N=1e7+5;//空间最大限制 4e8int n,m;signedmain(){// ios::sync_with_stdio(false);while(scanf("%lld%lld",&n,&m)!=EOF){
set <int> s;
set <int>:: iterator it;for(int i=1;i<=n+m;i++){int x;scanf("%lld",&x);
s.insert(x);}
it=s.begin();printf("%lld",*it);for(it++;it!=s.end();it++)printf(" %lld",*it);puts("");}return0;}
1002 火车进站问题
#include<bits/stdc++.h>#define inf 0x7fffffff//#define ll long long//#define int long long//#define double long double#define eps 1e-8//#define mod 1e9+7usingnamespace std;constint mod=1e9+7;constint M=1e5;constint N=1e7+5;//空间最大限制 4e8int n,m;int a[N],b[N];int in[N];signedmain(){// ios::sync_with_stdio(false);while(scanf("%d",&n)!=EOF){int top=0,cnt=1;for(int i=1;i<=n;i++)scanf("%1d",&a[i]);for(int i=1;i<=n;i++)scanf("%1d",&b[i]);for(int i=1;i<=n;i++){
in[++top]=a[i];while(b[cnt]==in[top]&&top&&cnt<=n) top--,cnt++;}if(top>0){puts("No.\nFINISH");continue;}puts("Yes.");
top=0,cnt=1;for(int i=1;i<=n;i++){
in[++top]=a[i];puts("in");while(b[cnt]==in[top]&&top&&cnt<=n){puts("out");
top--,cnt++;}}puts("FINISH");}return0;}
1003 统计书名
#include<bits/stdc++.h>#define inf 0x7fffffff//#define ll long long//#define int long long//#define double long double#define eps 1e-8//#define mod 1e9+7usingnamespace std;constint mod=1e9+7;constint M=1e5;constint N=1e7+5;//空间最大限制 4e8
map < string ,int> mp;int n,ans;signedmain(){// ios::sync_with_stdio(false);while(cin>>n){
mp.clear();
ans=0;while(n--){
string s;
cin>>s;if(mp[s])continue;
mp[s]=1;
ans++;}
cout<<ans<<endl;}return0;}
1004 第M个数列
#include<bits/stdc++.h>#define inf 0x7fffffff//#define ll long long//#define int long long//#define double long double#define eps 1e-8//#define mod 1e9+7usingnamespace std;constint mod=1e9+7;constint M=1e5;constint N=1e7+5;//空间最大限制 4e8int n,m,a[N];signedmain(){// ios::sync_with_stdio(false);while(cin>>n>>m){int ans=0;for(int i=1;i<=n;i++) a[i]=i;do{
ans++;if(ans==m)break;}while(next_permutation(a+1,a+n+1));printf("%d",a[1]);for(int i=2;i<=n;i++)printf(" %d",a[i]);puts("");}return0;}
传送门1001 {A} + {B}#include <bits/stdc++.h>#define inf 0x7fffffff//#define ll long long#define int long long//#define double long double#define eps 1e-8//#define mod 1e9+7using namespace std;const int mod=1e9+7;const int M=1e5;const int N=