SPOJ Emoticon challenge

Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
3
down vote
favorite
I tried this spoj problem and solved it using Dynamic Programming, but I was getting Time Limit Exceeded. The challenge is to count the number of occurrences of the subsequence "KEK" in each input string.
Some people in comments stated that they have done in O(n) time. I am getting no idea. can someone give me an idea? Here is my dynamic programming approach.
#include<bits/stdc++.h>
using namespace std;
int dp(string s,int in,int len,int pos)
if(in == len)
return 0;
if(pos == 0)
if(s[in] == 'K')
return dp(s,in+1,len,1)+dp(s,in+1,len,0);
return dp(s,in+1,len,0);
if(pos == 1)
if(s[in] == 'E')
return dp(s,in+1,len,2)+dp(s,in+1,len,1);
return dp(s,in+1,len,1);
if(pos == 2)
if(s[in] == 'K')
return 1+dp(s,in+1,len,2);
return dp(s,in+1,len,2);
int main()
int t;
cin>>t;
while(t--)
string s;
cin>>s;
int l = s.size();
int k = dp(s,0,l,0);
cout<<k<<endl;
return 0;
c++ algorithm programming-challenge time-limit-exceeded dynamic-programming
add a comment |Â
up vote
3
down vote
favorite
I tried this spoj problem and solved it using Dynamic Programming, but I was getting Time Limit Exceeded. The challenge is to count the number of occurrences of the subsequence "KEK" in each input string.
Some people in comments stated that they have done in O(n) time. I am getting no idea. can someone give me an idea? Here is my dynamic programming approach.
#include<bits/stdc++.h>
using namespace std;
int dp(string s,int in,int len,int pos)
if(in == len)
return 0;
if(pos == 0)
if(s[in] == 'K')
return dp(s,in+1,len,1)+dp(s,in+1,len,0);
return dp(s,in+1,len,0);
if(pos == 1)
if(s[in] == 'E')
return dp(s,in+1,len,2)+dp(s,in+1,len,1);
return dp(s,in+1,len,1);
if(pos == 2)
if(s[in] == 'K')
return 1+dp(s,in+1,len,2);
return dp(s,in+1,len,2);
int main()
int t;
cin>>t;
while(t--)
string s;
cin>>s;
int l = s.size();
int k = dp(s,0,l,0);
cout<<k<<endl;
return 0;
c++ algorithm programming-challenge time-limit-exceeded dynamic-programming
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I tried this spoj problem and solved it using Dynamic Programming, but I was getting Time Limit Exceeded. The challenge is to count the number of occurrences of the subsequence "KEK" in each input string.
Some people in comments stated that they have done in O(n) time. I am getting no idea. can someone give me an idea? Here is my dynamic programming approach.
#include<bits/stdc++.h>
using namespace std;
int dp(string s,int in,int len,int pos)
if(in == len)
return 0;
if(pos == 0)
if(s[in] == 'K')
return dp(s,in+1,len,1)+dp(s,in+1,len,0);
return dp(s,in+1,len,0);
if(pos == 1)
if(s[in] == 'E')
return dp(s,in+1,len,2)+dp(s,in+1,len,1);
return dp(s,in+1,len,1);
if(pos == 2)
if(s[in] == 'K')
return 1+dp(s,in+1,len,2);
return dp(s,in+1,len,2);
int main()
int t;
cin>>t;
while(t--)
string s;
cin>>s;
int l = s.size();
int k = dp(s,0,l,0);
cout<<k<<endl;
return 0;
c++ algorithm programming-challenge time-limit-exceeded dynamic-programming
I tried this spoj problem and solved it using Dynamic Programming, but I was getting Time Limit Exceeded. The challenge is to count the number of occurrences of the subsequence "KEK" in each input string.
Some people in comments stated that they have done in O(n) time. I am getting no idea. can someone give me an idea? Here is my dynamic programming approach.
#include<bits/stdc++.h>
using namespace std;
int dp(string s,int in,int len,int pos)
if(in == len)
return 0;
if(pos == 0)
if(s[in] == 'K')
return dp(s,in+1,len,1)+dp(s,in+1,len,0);
return dp(s,in+1,len,0);
if(pos == 1)
if(s[in] == 'E')
return dp(s,in+1,len,2)+dp(s,in+1,len,1);
return dp(s,in+1,len,1);
if(pos == 2)
if(s[in] == 'K')
return 1+dp(s,in+1,len,2);
return dp(s,in+1,len,2);
int main()
int t;
cin>>t;
while(t--)
string s;
cin>>s;
int l = s.size();
int k = dp(s,0,l,0);
cout<<k<<endl;
return 0;
c++ algorithm programming-challenge time-limit-exceeded dynamic-programming
edited Mar 26 at 3:07
user1118321
10.2k11144
10.2k11144
asked Mar 25 at 14:12
Turtle
184
184
add a comment |Â
add a comment |Â
3 Answers
3
active
oldest
votes
up vote
1
down vote
accepted
You are re-copying the string parameter with every recursive call. That will eat up your time.
It appears that you are programming a state machine with three states.
The function has three branches for states 0,1,2 but have no common code (other than precondition checking) and you know the number when you make the call. So, make three separate functions.
The string knows its own size. You donâÂÂt need to pass that separately. The std::string_view is good at nibbling away from the ends, so use that and you donâÂÂt need to pass the in.
I suggest adding a static counter so you can see just how many recursive calls are being made!
DonâÂÂt write using namespace std;.
You can, however, in a CPP file (not H file) or inside a function put individual using std::string; etc. (See SF.7.)
Idea on how to do it in ðª(n)
int f (const std::string& s)
std::vector<int> b;
int n 0;
for (auto c : s)
if (c=='E') b.push_back(n);
else if (c=='K') ++n;
int sum 0;
for (auto i : b)
sum += i*(n-i);
return sum;
The string is only gone through once. That is the key to making it ðª(n). Instead of recursion I push a value on a stack and keep going with the first half of the next go. After reaching the end of the string, pop each value and complete the calculation. (I did FIFO not LIFO but it doesnâÂÂt matter) You can see to convert this to recursion the call will go where the push_back is here, passing the rest of the string and n thus far. The suspended stack frame remembers the current n at that point. When the end of the string is reached and everything starts returning, it returns the total thus far and the final value of n; it adds its own term and returns to the prior.
To make it faster, use static buffer sizes (since you are told the maximum size of everything) and use a faster reading function too.
add a comment |Â
up vote
2
down vote
int dp(string s,int in,int len,int pos)
Where are the comments to explain the meanings of the variables? We're forced to reverse engineer them.
if(in == len)
return 0;
if(pos == 0)
if(s[in] == 'K')
return dp(s,in+1,len,1)+dp(s,in+1,len,0);
return dp(s,in+1,len,0);
if(pos == 1)
if(s[in] == 'E')
return dp(s,in+1,len,2)+dp(s,in+1,len,1);
return dp(s,in+1,len,1);
if(pos == 2)
if(s[in] == 'K')
return 1+dp(s,in+1,len,2);
return dp(s,in+1,len,2);
This is not dynamic programming. A dynamic programming approach to this problem must work on the following basis:
Given a structure
Swhich summarises the prefixstr, and the next characterch, we need to derive a structureS'which summarises the prefixstr + ch.
We have some easy conclusions:
Smust provide us with the number of the desired subsequences, because at the end of the DP run we will only haveScorresponding to the entire string. So it has a field which we can callkek.- If
chis neither'E'nor'K'thenS' = S. - If
ch != 'K'thenS'.kek = S.kek. - If
ch == 'K',Smust provide us with some way of knowing how much biggerS'.kekshould be thanS.kek. Obviously that must be the number of KEK subsequences ending withch, which is the number of KE subsequences instr.
You should be able to carry this reasoning through to fill out the entire list of fields required in S and the logic to update them when reading an 'E' and when reading a 'K'.
Can you write pseudo-code so that I can understand it better?
â Turtle
Mar 26 at 12:30
No, because it's deliberately not sufficiently detailed. You asked for an idea, so I'm giving you a hint. To write code would defeat the point.
â Peter Taylor
Mar 26 at 13:43
I didn't understand the point,Smust provide us with some way of knowing how much biggerS'.kekshould be thanS.kek.
â Turtle
Mar 26 at 14:19
add a comment |Â
up vote
1
down vote
You might be overthinking. The simple solution is:
int sum = 0;
for(int i=0;i<length;i++)
if (input[i] == 'E')
sum += numberOfKBefore[i] * numberOfKAfter[i];
and the dynamic programing part is only to fill up the numberOfKSoFar array with counts of 'K'.
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You are re-copying the string parameter with every recursive call. That will eat up your time.
It appears that you are programming a state machine with three states.
The function has three branches for states 0,1,2 but have no common code (other than precondition checking) and you know the number when you make the call. So, make three separate functions.
The string knows its own size. You donâÂÂt need to pass that separately. The std::string_view is good at nibbling away from the ends, so use that and you donâÂÂt need to pass the in.
I suggest adding a static counter so you can see just how many recursive calls are being made!
DonâÂÂt write using namespace std;.
You can, however, in a CPP file (not H file) or inside a function put individual using std::string; etc. (See SF.7.)
Idea on how to do it in ðª(n)
int f (const std::string& s)
std::vector<int> b;
int n 0;
for (auto c : s)
if (c=='E') b.push_back(n);
else if (c=='K') ++n;
int sum 0;
for (auto i : b)
sum += i*(n-i);
return sum;
The string is only gone through once. That is the key to making it ðª(n). Instead of recursion I push a value on a stack and keep going with the first half of the next go. After reaching the end of the string, pop each value and complete the calculation. (I did FIFO not LIFO but it doesnâÂÂt matter) You can see to convert this to recursion the call will go where the push_back is here, passing the rest of the string and n thus far. The suspended stack frame remembers the current n at that point. When the end of the string is reached and everything starts returning, it returns the total thus far and the final value of n; it adds its own term and returns to the prior.
To make it faster, use static buffer sizes (since you are told the maximum size of everything) and use a faster reading function too.
add a comment |Â
up vote
1
down vote
accepted
You are re-copying the string parameter with every recursive call. That will eat up your time.
It appears that you are programming a state machine with three states.
The function has three branches for states 0,1,2 but have no common code (other than precondition checking) and you know the number when you make the call. So, make three separate functions.
The string knows its own size. You donâÂÂt need to pass that separately. The std::string_view is good at nibbling away from the ends, so use that and you donâÂÂt need to pass the in.
I suggest adding a static counter so you can see just how many recursive calls are being made!
DonâÂÂt write using namespace std;.
You can, however, in a CPP file (not H file) or inside a function put individual using std::string; etc. (See SF.7.)
Idea on how to do it in ðª(n)
int f (const std::string& s)
std::vector<int> b;
int n 0;
for (auto c : s)
if (c=='E') b.push_back(n);
else if (c=='K') ++n;
int sum 0;
for (auto i : b)
sum += i*(n-i);
return sum;
The string is only gone through once. That is the key to making it ðª(n). Instead of recursion I push a value on a stack and keep going with the first half of the next go. After reaching the end of the string, pop each value and complete the calculation. (I did FIFO not LIFO but it doesnâÂÂt matter) You can see to convert this to recursion the call will go where the push_back is here, passing the rest of the string and n thus far. The suspended stack frame remembers the current n at that point. When the end of the string is reached and everything starts returning, it returns the total thus far and the final value of n; it adds its own term and returns to the prior.
To make it faster, use static buffer sizes (since you are told the maximum size of everything) and use a faster reading function too.
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You are re-copying the string parameter with every recursive call. That will eat up your time.
It appears that you are programming a state machine with three states.
The function has three branches for states 0,1,2 but have no common code (other than precondition checking) and you know the number when you make the call. So, make three separate functions.
The string knows its own size. You donâÂÂt need to pass that separately. The std::string_view is good at nibbling away from the ends, so use that and you donâÂÂt need to pass the in.
I suggest adding a static counter so you can see just how many recursive calls are being made!
DonâÂÂt write using namespace std;.
You can, however, in a CPP file (not H file) or inside a function put individual using std::string; etc. (See SF.7.)
Idea on how to do it in ðª(n)
int f (const std::string& s)
std::vector<int> b;
int n 0;
for (auto c : s)
if (c=='E') b.push_back(n);
else if (c=='K') ++n;
int sum 0;
for (auto i : b)
sum += i*(n-i);
return sum;
The string is only gone through once. That is the key to making it ðª(n). Instead of recursion I push a value on a stack and keep going with the first half of the next go. After reaching the end of the string, pop each value and complete the calculation. (I did FIFO not LIFO but it doesnâÂÂt matter) You can see to convert this to recursion the call will go where the push_back is here, passing the rest of the string and n thus far. The suspended stack frame remembers the current n at that point. When the end of the string is reached and everything starts returning, it returns the total thus far and the final value of n; it adds its own term and returns to the prior.
To make it faster, use static buffer sizes (since you are told the maximum size of everything) and use a faster reading function too.
You are re-copying the string parameter with every recursive call. That will eat up your time.
It appears that you are programming a state machine with three states.
The function has three branches for states 0,1,2 but have no common code (other than precondition checking) and you know the number when you make the call. So, make three separate functions.
The string knows its own size. You donâÂÂt need to pass that separately. The std::string_view is good at nibbling away from the ends, so use that and you donâÂÂt need to pass the in.
I suggest adding a static counter so you can see just how many recursive calls are being made!
DonâÂÂt write using namespace std;.
You can, however, in a CPP file (not H file) or inside a function put individual using std::string; etc. (See SF.7.)
Idea on how to do it in ðª(n)
int f (const std::string& s)
std::vector<int> b;
int n 0;
for (auto c : s)
if (c=='E') b.push_back(n);
else if (c=='K') ++n;
int sum 0;
for (auto i : b)
sum += i*(n-i);
return sum;
The string is only gone through once. That is the key to making it ðª(n). Instead of recursion I push a value on a stack and keep going with the first half of the next go. After reaching the end of the string, pop each value and complete the calculation. (I did FIFO not LIFO but it doesnâÂÂt matter) You can see to convert this to recursion the call will go where the push_back is here, passing the rest of the string and n thus far. The suspended stack frame remembers the current n at that point. When the end of the string is reached and everything starts returning, it returns the total thus far and the final value of n; it adds its own term and returns to the prior.
To make it faster, use static buffer sizes (since you are told the maximum size of everything) and use a faster reading function too.
edited May 18 at 20:59
answered May 18 at 20:33
JDÃ Âugosz
5,047731
5,047731
add a comment |Â
add a comment |Â
up vote
2
down vote
int dp(string s,int in,int len,int pos)
Where are the comments to explain the meanings of the variables? We're forced to reverse engineer them.
if(in == len)
return 0;
if(pos == 0)
if(s[in] == 'K')
return dp(s,in+1,len,1)+dp(s,in+1,len,0);
return dp(s,in+1,len,0);
if(pos == 1)
if(s[in] == 'E')
return dp(s,in+1,len,2)+dp(s,in+1,len,1);
return dp(s,in+1,len,1);
if(pos == 2)
if(s[in] == 'K')
return 1+dp(s,in+1,len,2);
return dp(s,in+1,len,2);
This is not dynamic programming. A dynamic programming approach to this problem must work on the following basis:
Given a structure
Swhich summarises the prefixstr, and the next characterch, we need to derive a structureS'which summarises the prefixstr + ch.
We have some easy conclusions:
Smust provide us with the number of the desired subsequences, because at the end of the DP run we will only haveScorresponding to the entire string. So it has a field which we can callkek.- If
chis neither'E'nor'K'thenS' = S. - If
ch != 'K'thenS'.kek = S.kek. - If
ch == 'K',Smust provide us with some way of knowing how much biggerS'.kekshould be thanS.kek. Obviously that must be the number of KEK subsequences ending withch, which is the number of KE subsequences instr.
You should be able to carry this reasoning through to fill out the entire list of fields required in S and the logic to update them when reading an 'E' and when reading a 'K'.
Can you write pseudo-code so that I can understand it better?
â Turtle
Mar 26 at 12:30
No, because it's deliberately not sufficiently detailed. You asked for an idea, so I'm giving you a hint. To write code would defeat the point.
â Peter Taylor
Mar 26 at 13:43
I didn't understand the point,Smust provide us with some way of knowing how much biggerS'.kekshould be thanS.kek.
â Turtle
Mar 26 at 14:19
add a comment |Â
up vote
2
down vote
int dp(string s,int in,int len,int pos)
Where are the comments to explain the meanings of the variables? We're forced to reverse engineer them.
if(in == len)
return 0;
if(pos == 0)
if(s[in] == 'K')
return dp(s,in+1,len,1)+dp(s,in+1,len,0);
return dp(s,in+1,len,0);
if(pos == 1)
if(s[in] == 'E')
return dp(s,in+1,len,2)+dp(s,in+1,len,1);
return dp(s,in+1,len,1);
if(pos == 2)
if(s[in] == 'K')
return 1+dp(s,in+1,len,2);
return dp(s,in+1,len,2);
This is not dynamic programming. A dynamic programming approach to this problem must work on the following basis:
Given a structure
Swhich summarises the prefixstr, and the next characterch, we need to derive a structureS'which summarises the prefixstr + ch.
We have some easy conclusions:
Smust provide us with the number of the desired subsequences, because at the end of the DP run we will only haveScorresponding to the entire string. So it has a field which we can callkek.- If
chis neither'E'nor'K'thenS' = S. - If
ch != 'K'thenS'.kek = S.kek. - If
ch == 'K',Smust provide us with some way of knowing how much biggerS'.kekshould be thanS.kek. Obviously that must be the number of KEK subsequences ending withch, which is the number of KE subsequences instr.
You should be able to carry this reasoning through to fill out the entire list of fields required in S and the logic to update them when reading an 'E' and when reading a 'K'.
Can you write pseudo-code so that I can understand it better?
â Turtle
Mar 26 at 12:30
No, because it's deliberately not sufficiently detailed. You asked for an idea, so I'm giving you a hint. To write code would defeat the point.
â Peter Taylor
Mar 26 at 13:43
I didn't understand the point,Smust provide us with some way of knowing how much biggerS'.kekshould be thanS.kek.
â Turtle
Mar 26 at 14:19
add a comment |Â
up vote
2
down vote
up vote
2
down vote
int dp(string s,int in,int len,int pos)
Where are the comments to explain the meanings of the variables? We're forced to reverse engineer them.
if(in == len)
return 0;
if(pos == 0)
if(s[in] == 'K')
return dp(s,in+1,len,1)+dp(s,in+1,len,0);
return dp(s,in+1,len,0);
if(pos == 1)
if(s[in] == 'E')
return dp(s,in+1,len,2)+dp(s,in+1,len,1);
return dp(s,in+1,len,1);
if(pos == 2)
if(s[in] == 'K')
return 1+dp(s,in+1,len,2);
return dp(s,in+1,len,2);
This is not dynamic programming. A dynamic programming approach to this problem must work on the following basis:
Given a structure
Swhich summarises the prefixstr, and the next characterch, we need to derive a structureS'which summarises the prefixstr + ch.
We have some easy conclusions:
Smust provide us with the number of the desired subsequences, because at the end of the DP run we will only haveScorresponding to the entire string. So it has a field which we can callkek.- If
chis neither'E'nor'K'thenS' = S. - If
ch != 'K'thenS'.kek = S.kek. - If
ch == 'K',Smust provide us with some way of knowing how much biggerS'.kekshould be thanS.kek. Obviously that must be the number of KEK subsequences ending withch, which is the number of KE subsequences instr.
You should be able to carry this reasoning through to fill out the entire list of fields required in S and the logic to update them when reading an 'E' and when reading a 'K'.
int dp(string s,int in,int len,int pos)
Where are the comments to explain the meanings of the variables? We're forced to reverse engineer them.
if(in == len)
return 0;
if(pos == 0)
if(s[in] == 'K')
return dp(s,in+1,len,1)+dp(s,in+1,len,0);
return dp(s,in+1,len,0);
if(pos == 1)
if(s[in] == 'E')
return dp(s,in+1,len,2)+dp(s,in+1,len,1);
return dp(s,in+1,len,1);
if(pos == 2)
if(s[in] == 'K')
return 1+dp(s,in+1,len,2);
return dp(s,in+1,len,2);
This is not dynamic programming. A dynamic programming approach to this problem must work on the following basis:
Given a structure
Swhich summarises the prefixstr, and the next characterch, we need to derive a structureS'which summarises the prefixstr + ch.
We have some easy conclusions:
Smust provide us with the number of the desired subsequences, because at the end of the DP run we will only haveScorresponding to the entire string. So it has a field which we can callkek.- If
chis neither'E'nor'K'thenS' = S. - If
ch != 'K'thenS'.kek = S.kek. - If
ch == 'K',Smust provide us with some way of knowing how much biggerS'.kekshould be thanS.kek. Obviously that must be the number of KEK subsequences ending withch, which is the number of KE subsequences instr.
You should be able to carry this reasoning through to fill out the entire list of fields required in S and the logic to update them when reading an 'E' and when reading a 'K'.
edited Mar 26 at 9:44
answered Mar 26 at 8:26
Peter Taylor
14k2454
14k2454
Can you write pseudo-code so that I can understand it better?
â Turtle
Mar 26 at 12:30
No, because it's deliberately not sufficiently detailed. You asked for an idea, so I'm giving you a hint. To write code would defeat the point.
â Peter Taylor
Mar 26 at 13:43
I didn't understand the point,Smust provide us with some way of knowing how much biggerS'.kekshould be thanS.kek.
â Turtle
Mar 26 at 14:19
add a comment |Â
Can you write pseudo-code so that I can understand it better?
â Turtle
Mar 26 at 12:30
No, because it's deliberately not sufficiently detailed. You asked for an idea, so I'm giving you a hint. To write code would defeat the point.
â Peter Taylor
Mar 26 at 13:43
I didn't understand the point,Smust provide us with some way of knowing how much biggerS'.kekshould be thanS.kek.
â Turtle
Mar 26 at 14:19
Can you write pseudo-code so that I can understand it better?
â Turtle
Mar 26 at 12:30
Can you write pseudo-code so that I can understand it better?
â Turtle
Mar 26 at 12:30
No, because it's deliberately not sufficiently detailed. You asked for an idea, so I'm giving you a hint. To write code would defeat the point.
â Peter Taylor
Mar 26 at 13:43
No, because it's deliberately not sufficiently detailed. You asked for an idea, so I'm giving you a hint. To write code would defeat the point.
â Peter Taylor
Mar 26 at 13:43
I didn't understand the point,
S must provide us with some way of knowing how much bigger S'.kek should be than S.kek.â Turtle
Mar 26 at 14:19
I didn't understand the point,
S must provide us with some way of knowing how much bigger S'.kek should be than S.kek.â Turtle
Mar 26 at 14:19
add a comment |Â
up vote
1
down vote
You might be overthinking. The simple solution is:
int sum = 0;
for(int i=0;i<length;i++)
if (input[i] == 'E')
sum += numberOfKBefore[i] * numberOfKAfter[i];
and the dynamic programing part is only to fill up the numberOfKSoFar array with counts of 'K'.
add a comment |Â
up vote
1
down vote
You might be overthinking. The simple solution is:
int sum = 0;
for(int i=0;i<length;i++)
if (input[i] == 'E')
sum += numberOfKBefore[i] * numberOfKAfter[i];
and the dynamic programing part is only to fill up the numberOfKSoFar array with counts of 'K'.
add a comment |Â
up vote
1
down vote
up vote
1
down vote
You might be overthinking. The simple solution is:
int sum = 0;
for(int i=0;i<length;i++)
if (input[i] == 'E')
sum += numberOfKBefore[i] * numberOfKAfter[i];
and the dynamic programing part is only to fill up the numberOfKSoFar array with counts of 'K'.
You might be overthinking. The simple solution is:
int sum = 0;
for(int i=0;i<length;i++)
if (input[i] == 'E')
sum += numberOfKBefore[i] * numberOfKAfter[i];
and the dynamic programing part is only to fill up the numberOfKSoFar array with counts of 'K'.
answered May 18 at 13:59
user158037
41136
41136
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodereview.stackexchange.com%2fquestions%2f190440%2fspoj-emoticon-challenge%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password