-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bubbles and Buckets_11495.cpp
87 lines (70 loc) · 1.32 KB
/
Bubbles and Buckets_11495.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include<iostream>
using namespace std;
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<bitset>
#include<map>
#include<set>
#include<climits>
#include<algorithm>
#include<utility>
#include<cstdlib>
#include<cctype>
#include<queue>
#include<sstream>
#define read(x) scanf("%d",&x)
#define write(x) printf("%d\n",x)
#define assign(x,n) x=(int*)calloc(n,4)
#define rep(i,n) for(i=1;i<=n;++i)
#define max(a,b) ((a)>(b))?(a):(b)
typedef long long int ull;
vector <int> arr;
int n;
long long int inv=0;
void merge(int l,int md,int r)
{
int a=l,b=md+1,c=0,i;
vector <int> temp(r-l+1);
while(a<=md && b<=r)
{
if(arr[a]<arr[b])temp[c++]=arr[a++];
else {
temp[c++]=arr[b++];
inv+=md-a+1;
}
}
while(a<=md)temp[c++]=arr[a++];
while(b<=r)temp[c++]=arr[b++];
for(i=l;i<=r;i++)arr[i]=temp[i-l];
}
void ms(int l,int h)
{
if(l>=h || l<0 || h<0 || l> (n-1) || h>(n-1))return;
int md=(l+h)/2;
ms(l,md);
ms(md+1,h);
merge(l,md,h);
}
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int i,k;
while(read(n) && n)
{
for(i=0;i<n;i++)
{
read(k);
arr.push_back(k);
}
inv=0;
ms(0,n-1);
if(inv%2)cout<<"Marcelo\n";
else cout<<"Carlos\n";
arr.clear();
}
return 0;
}