Skip to main content

Userscript for SPOJ

Greasemonkey is an userscript manager that let's users manipulate any web page before or after it is loaded on browsers. It is available as an extension in browsers. 

https://en.wikipedia.org/wiki/Greasemonkey

In short, it runs custom piece of  code on any websites.
In SPOJ problem page, there's problem-tag, which is really helpful but not always. The same thing with auto showed comment table. Most of the time while scrolling, I see hints that I do not want to read unless I am stuck.

So, to rectify the situation, I wrote a few lines of javascript to hide the problem-tag and  comment table. I also wrote another line to select CPP as the default language in the solution submission form.

Setup: Greasemonkey for Firefox or Tampermonkey for Chrome
Then go to New User Script & copy-paste the code.
That's it. 

Comments

Popular posts from this blog

SPOJ - GSS1

Considering input series: { 4 , -10 , 3 , 100 , -20 , 1 } Query(x,y) = Max { a[i]+a[i+1]+...+a[j] ; x ≤ i ≤ j ≤ y } A node contains-  [ START & END is a node's segment limit ] Prefix is the maximum sum starting at START, end can be anywhere. There are two possibilities of the maximum. One, node's leftChild's prefix or two, adding leftChild's sum + rightChild's prefix. (which will make the prefix contiguous) Suffix is the maximum sum ending at END, start can be anywhere. There's two possibility of the maximum. One, node's rightChild's already calculated suffix or two, add rightChild's sum + leftChild's suffix   (which will make the suffix contiguous). Sum : leftChild's sum + rightChild's sum. MAX Maximum of  -  prefix (result is in the node, starts from START but doesn't end in END ) suffix  (result is in the node, doesn't start from START but surely ends in END ) leftChild's max ( result is in left ...

Bitwise Sieve w/ code sample

Sieve of Eratosthenes is explained HERE Bitwise sieve is an optimized implementation of  Sieve of Eratosthenes. It does the same thing but more memory efficient because it uses logic operations( &,|,>>,<< ) on binary numbers. In normal implementation, we use an array as flag to check if a number is prime or not.we know index of an array ( i.e  myarray[n]  ) is 32 bit long. If an array is 10 index long, that it has 32x10(=320) bits.  We use bits of that array as flag. that way we can flag numbers upto 320 as prime or not prime. i.e, how to check the flag status of 51 in myarray[ n ] ? We'll divide 5 by 32, that will give us the index number of the certain bit, then we'll mod 5 by 32, that will give us the certain bit position to check for 0 or 1. Remember bit positions are defined from right to left, starting from 0. Meaning LST = 0 and MST = 31. So we need to define two functions, one to set that certain bit as 0 or 1, another to check if...

SPOJ 5 - PALIN

Problem Statement Explanation is here Sample Solution : #include<bits/stdc++.h> using namespace std; char k[1000005]; int l,i,j,mid; bool chkNine() {     cout<<""; //for SPOJ's internal problem, this line is needed     for(i=0;i<l;i++)     {         if( k[i]!='9' ) return false;     } } void nextPalin() {     int f=0;     l=strlen(k);     if(chkNine()) {         memset(k,'0',l);         k[0] ='1';         k[l]='1';         k[l+1]='\0';         return;     }     // calc mid,i,j     if(l%2==0)     {         i= ( l/2 )-1;      ...