Skip to content

Commit

Permalink
added ny10a
Browse files Browse the repository at this point in the history
  • Loading branch information
ramjeet saran committed Aug 21, 2015
1 parent 7374da7 commit 233612b
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions Readme
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ http://www.spoj.com/users/raj94/
40) EASYPROB
41) HPYNOS
42) ARITH2
43) NY10A
44 changes: 44 additions & 0 deletions ny10a.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//DATE: 21/08/2015
//Author: Ramjeet Saran
//http://www.spoj.com/problems/NY10A

#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>

# define MAX(a,b) a>b ? a : b;
# define ull unsigned long long int

using namespace std;

int main(){

int t,j;
map <char, int> TH;
TH['H'] = 1;
TH['T'] = 0;
string in;
cin>>t;
while(t--){
map <int, int> arr;
cin>>j;
cin>>in;
int out = 0;
out = ((((out + TH[in[0]]) * 2) + TH[in[1]]) * 2) + TH[in[2]];
arr[out]++;
for(int i = 3; i < 40; i++){
out = out * 2 + TH[in[i]];
out %= 8;
arr[out]++;
}
cout<<j<<" ";
for(int i = 0; i < 8; i++)
cout<<arr[i]<<" ";
cout<<endl;
}
}

0 comments on commit 233612b

Please sign in to comment.