RC-v1 简版2048
#include<iostream>
using namespace std;
const int N = 110;
int stack[N],n,m;
int main()
{
cin>>n>>m;
int tt = -1;
while(n -- ){
int t;
cin>>t;
if(tt != -1 && stack[tt] == t){
while(tt != -1 && stack[tt] == t){
stack[tt--] = ++t;
}
tt ++;
}else{
stack[++tt] = t;
if(tt>=m) break;
}
}
cout<<stack[0];
for(int i=1;i<min(m,tt+1);i++) cout<<" "<<stack[i];
return 0;
}
RC-v2 为 i 做 e
#include<iostream>
#include<cstring>
#include<unordered_map>
using namespace std;
const int N = 1e5+10;
int n;
unordered_map<string,string> h;
int main()
{
cin>>n;
string str,sex;
while(n -- ){
cin>>str>>sex;
h[str] = sex;
}
bool flag = true;
int t;
cin>>t;
for(int i=1;i<=t;i++){
int m;
cin>>m;
int cnt = 0,t = m;
while(m -- ){
cin>>str;
if(h[str] == "i") cnt++;
}
if(cnt == t) {
if(!flag) cout<<" ";
cout<<i;
flag = false;
}
}
if(flag) cout<<"None";
return 0;
}
RC-v3 乘法小宇宙
#include<iostream>
#include<algorithm>
using namespace std;
const int N = 10;
int a[N],n,k,cnt,cnt2 = 0;
int ans[N],res[N],alls[30];
int h[N];
struct P{
int x,y;
}p[10001];
bool cmp(const P p1, const P p2)
{
if(p1.x == p2.x) return p1.y<p2.y;
else return p1.x<p2.x;
}
int cal()
{
int t = 0;
for(int i=0;i<n;i++) t = t * 10 + ans[i];
return t;
}
bool check(int t,int k)
{
int cnt1 = 0;
while(t){
cnt1 ++;
if(!h[t%10]) return false;
t/=10;
}
if(cnt1 != n+k) return false;
return true;
}
void dfs1(int u)
{
if(u == n){
int t = cal();
for(int i=0;i<cnt;i++){
if(check(t*(alls[i]/10),1) && check(t*(alls[i]%10),1) && check(t*alls[i],2)){
p[cnt2++] = {t,alls[i]};
}
}
return ;
}
for(int i=0;i<k;i++){
ans[u] = a[i];
dfs1(u+1);
}
}
void dfs(int u)
{
if(u == 2){
alls[cnt++] = res[0] * 10 + res[1];
//cout<<alls[cnt - 1]<<endl;
return ;
}
for(int i=0;i<k;i++){
res[u] = a[i];
dfs(u+1);
}
}
int main()
{
cin>>n>>k;
for(int i=0;i<k;i++) cin>>a[i],h[a[i]] = 1;
dfs(0);
dfs1(0);
sort(p,p+cnt2,cmp);
for(int i=0;i<cnt2;i++){
cout<<p[i].x<<" "<<p[i].y<<endl;
}
if(cnt2 == 0) cout<<"No Solution";
return 0;
}
RC-v4 实时中位线
#include<iostream>
using namespace std;
const int N = 110;
int n;
int h[N];
int main()
{
cin>>n;
int len = 1;
for(int i=1;i<=n;i++){
int t;
scanf("%d",&t);
len = max(len,t);
h[t] ++;
int sum = 0,j = 0,ans1 = -1;
for(;j<=len;j++){
sum += h[j];
if(sum >= (i+1)/2&&ans1 == -1) ans1 = j;
if(sum >= i/2+1) break;
}
//cout<<ans1<<" "<<j<<endl;
int k = 1;
if(i%2 == 0) k = 2;
else j = 0;
printf("%.1lf\n",1.0*(j+ans1)/k);
}
return 0;
}