Codeforces Blown Garland
/*
Lionel Messi is such a player that you may catch him, you may touch him, you may feel him
and definitely you may Love him.
Lionel Messi is Messi. A little Magician in this World.
*/
// Accepted
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef map<char, int>mpci;
typedef unsigned long long ull;
const int mod = 1000007;
const int high = 6;
int ar[high];
int main()
{
fast;
string in;
int i , len=0 , j;
char ch[] = {'R' , 'B' , 'Y' , 'G'};
mpci mp;
while(cin >> in)
{
len = in.length();
mp.clear();
for(i=0; i<len; i++)
{
if(in[i] == 'R') ar[0] = i;
else if(in[i] == 'B') ar[1] = i;
else if(in[i] == 'Y') ar[2] = i;
else if(in[i] == 'G') ar[3] = i;
}
for(i=0; i<4; i++)
{
j = ar[i] + 4;
while(j < len)
{
if(ch[i] != in[j]) mp[ch[i]]++;
j+=4;
}
j = ar[i] - 4;
while(j >= 0)
{
if(ch[i] != in[j]) mp[ch[i]]++;
j-=4;
}
}
cout << mp['R'] << " " << mp['B'] << " " << mp['Y'] << " " << mp['G'] << "\n";
}
return 0;
}
Lionel Messi is such a player that you may catch him, you may touch him, you may feel him
and definitely you may Love him.
Lionel Messi is Messi. A little Magician in this World.
*/
// Accepted
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0)
#define bfast cin.tie(0)
#define outs(x) cout << x << " "
#define outn(x) cout << x << "\n"
#define sf scanf
#define pf printf
#define nl puts("")
#define psb push_back
typedef long long LL;
typedef vector<int>vii;
typedef vector<LL>vll;
typedef map<char, int>mpci;
typedef unsigned long long ull;
const int mod = 1000007;
const int high = 6;
int ar[high];
int main()
{
fast;
string in;
int i , len=0 , j;
char ch[] = {'R' , 'B' , 'Y' , 'G'};
mpci mp;
while(cin >> in)
{
len = in.length();
mp.clear();
for(i=0; i<len; i++)
{
if(in[i] == 'R') ar[0] = i;
else if(in[i] == 'B') ar[1] = i;
else if(in[i] == 'Y') ar[2] = i;
else if(in[i] == 'G') ar[3] = i;
}
for(i=0; i<4; i++)
{
j = ar[i] + 4;
while(j < len)
{
if(ch[i] != in[j]) mp[ch[i]]++;
j+=4;
}
j = ar[i] - 4;
while(j >= 0)
{
if(ch[i] != in[j]) mp[ch[i]]++;
j-=4;
}
}
cout << mp['R'] << " " << mp['B'] << " " << mp['Y'] << " " << mp['G'] << "\n";
}
return 0;
}
Comments
Post a Comment