Here you will find solutions of many problems on spoj. If you want solution of some problem which is not listed in blog or have doubt regarding any spoj problem (which i have solved) or any programming concept (data structure) you can mail me @ raj.nishant360@gmail.com
And my humble request to you all that don't copy the code only try to understand the logic and algorithm behind the code. I have started this because if you tried as hard as you can and still can't find any solution to the problem then you can refer to this.
You can read my answer how to start competitive programming CLICK HERE

Monday, March 17, 2014

BOGGLE-Boggle Scoring

Boggle Scoring

below given code is for boogle spoj or boggle scoring spoj.
here c++ inbuilt functions roxxx,,..
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <map>
#include <sstream>
using namespace std;
int main()
{
 int n;
 int a[10]={0,1,1,1,1,2,3,5,11,11};
 scanf("%d ",&n);
 string s[n+9];
 int i;
 for(i=0;i<n;i++)
  getline(cin,s[i]);
 map<string , int >mp;
 map<string ,int >::iterator t;
 i=0;
 string word;
 for(i=0;i<n;i++){
  istringstream iss(s[i]);
  while(iss>>word)
   mp[word]+=1;
 }
 int count=0,max=-1;
 for(i=0;i<n;i++)
 {
  count=0;
  istringstream iss(s[i]);
  while(iss>>word)
  {
   t=mp.find(word);
   if((*t).second==1)
   {
    if((*t).first.size()>7)
     count+=11;
    else
     count+=a[(*t).first.size()];
   }
  }
  if(max<count)
   max=count;
 }
 cout<<max<<endl;
 return 0;
}