diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c091839 --- /dev/null +++ b/.gitignore @@ -0,0 +1,50 @@ +# Compiled source # +################### +*.com +*.class +*.dll +*.exe +*.o +*.so +*.pyc + +# Numerous always-ignore extensions +################### +*.diff +*.err +*.orig +*.log +*.rej +*.swo +*.swp +*.vi +*~ + +*.sass-cache +# Folders to ignore +################### +.hg +.svn +.CVS +# OS or Editor folders +################### +.DS_Store +Icon? +Thumbs.db +ehthumbs.db +nbproject +.cache +.project +.settings +.tmproj +*.esproj +*.sublime-project +*.sublime-workspace +# Dreamweaver added files +################### +_notes +dwsync.xml +# Komodo +################### +*.komodoproject +.komodotools diff --git a/FoxListeningToMusic.html b/FoxListeningToMusic.html index e7c0f87..5da9d78 100644 --- a/FoxListeningToMusic.html +++ b/FoxListeningToMusic.html @@ -8,6 +8,6 @@
  • song 0 -> song 1 (with probability 1/4)
  • song 1 (with probability 1/2)
  • -1)    
    {1, 10, 100, 1000, 10000}
    0
    Returns: {0.2, 0.2, 0.2, 0.2, 0.2 }
    2)    
    {5, 8, 4, 7}
    10
    Returns: {0.1875, 0.3125, 0.1875, 0.3125 }
    3)    
    {10, 1}
    9
    Returns: {0.9990234375, 9.765625E-4 }
    4)    
    {58, 47, 36, 25, 14, 3}
    100
    Returns: 
    +
    1)    
    {1, 10, 100, 1000, 10000}
    0
    Returns: {0.2, 0.2, 0.2, 0.2, 0.2 }
    2)    
    {5, 8, 4, 7}
    10
    Returns: {0.1875, 0.3125, 0.1875, 0.3125 }
    3)    
    {10, 1}
    9
    Returns: {0.9990234375, 9.765625E-4 }
    4)    
    {58, 47, 36, 25, 14, 3}
    100
    Returns:
     {0.32895835374381194, 0.26291497538241776, 0.18463894970453887, 0.1312301113062895,
      0.07518634032025856, 0.017071269542683242 }

    This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.

    diff --git a/FoxListeningToMusic.java b/FoxListeningToMusic.java index cf6cbb5..a35c3ef 100644 --- a/FoxListeningToMusic.java +++ b/FoxListeningToMusic.java @@ -8,18 +8,18 @@ public class FoxListeningToMusic { public double[] getProbabilities(int[] length, int T) { - + } - + public static void main(String[] args) { long time; double[] answer; boolean errors = false; double[] desiredAnswer; - + boolean same; - + time = System.currentTimeMillis(); answer = new FoxListeningToMusic().getProbabilities(new int[]{1, 2}, 1); System.out.println("Time: " + (System.currentTimeMillis()-time)/1000.0 + " seconds"); @@ -200,8 +200,8 @@ public static void main(String[] args) else System.out.println("Match :-)"); System.out.println(); - - + + if (errors) System.out.println("Some of the test cases had errors :-("); else diff --git a/MinimumLiars.java b/MinimumLiars.java index cfca63d..c070356 100644 --- a/MinimumLiars.java +++ b/MinimumLiars.java @@ -27,22 +27,22 @@ public int getMinimum(int[] claim) } } } - + if (mid == sz) { return -1; } else { return l; } } - + public static void main(String[] args) { long time; int answer; boolean errors = false; int desiredAnswer; - - + + time = System.currentTimeMillis(); answer = new MinimumLiars().getMinimum(new int[]{1,1,1,2}); System.out.println("Time: " + (System.currentTimeMillis()-time)/1000.0 + " seconds"); @@ -123,8 +123,8 @@ public static void main(String[] args) else System.out.println("Match :-)"); System.out.println(); - - + + if (errors) System.out.println("Some of the test cases had errors :-("); else diff --git a/TheJackpotDivTwo.java b/TheJackpotDivTwo.java index 16df319..970efd0 100644 --- a/TheJackpotDivTwo.java +++ b/TheJackpotDivTwo.java @@ -23,16 +23,16 @@ public int[] find(int[] money, int jackpot) Arrays.sort(money); return money; } - + public static void main(String[] args) { long time; int[] answer; boolean errors = false; int[] desiredAnswer; - + boolean same; - + time = System.currentTimeMillis(); answer = new TheJackpotDivTwo().find(new int[]{1, 2, 3, 4}, 2); System.out.println("Time: " + (System.currentTimeMillis()-time)/1000.0 + " seconds"); @@ -177,8 +177,8 @@ public static void main(String[] args) else System.out.println("Match :-)"); System.out.println(); - - + + if (errors) System.out.println("Some of the test cases had errors :-("); else diff --git a/TheNumbersWithLuckyLastDigit.java b/TheNumbersWithLuckyLastDigit.java index 09777b9..38295e0 100644 --- a/TheNumbersWithLuckyLastDigit.java +++ b/TheNumbersWithLuckyLastDigit.java @@ -10,7 +10,7 @@ public int find(int n) { return solve(n,0); } - + int solve(int n,int flag) { int x1 = n/2; int x2 = n-x1; @@ -23,7 +23,7 @@ int solve(int n,int flag) { } } //System.out.println(" ---- " + n + " ----- "); - //System.out.println("" + x1 + " --- " + x2 + ""); + //System.out.println("" + x1 + " --- " + x2 + ""); if (solve2(x1,x2)) { return 2; } else { @@ -42,28 +42,28 @@ int solve(int n,int flag) { return -1; } } - + boolean solve2 (int x1, int x2) { - + if ( x1 <= 0 || x2 <=0 ) return false; - - System.out.println(")))) " + x1 + " --- " + x2 + ""); - + + System.out.println(")))) " + x1 + " --- " + x2 + ""); + if (isl(x1)) { if (isl(x2)) { return true; } else { - System.out.println(">>>>> " + (x1-1) + " --- " + (x2+1) + ""); + System.out.println(">>>>> " + (x1-1) + " --- " + (x2+1) + ""); return solve2(x1-1,x2+1); } } else { - System.out.println("xxxx " + (x1-1) + " --- " + (x2+1) + ""); + System.out.println("xxxx " + (x1-1) + " --- " + (x2+1) + ""); return solve2(x1-1,x2+1); } } - + boolean isl(int n) { - + Integer nn = n; String ns = nn.toString(); //int res = n % (Math.pow( 10*Integer.parseInt(ns.charAt(0)), ns.length())); @@ -73,18 +73,18 @@ boolean isl(int n) { return false; } } - + public static void main(String[] args) { int answer = new TheNumbersWithLuckyLastDigit().find(51); System.out.println(answer); - + /*long time; int answer; boolean errors = false; int desiredAnswer; - - + + time = System.currentTimeMillis(); answer = new TheNumbersWithLuckyLastDigit().find(99); System.out.println("Time: " + (System.currentTimeMillis()-time)/1000.0 + " seconds"); @@ -149,8 +149,8 @@ public static void main(String[] args) else System.out.println("Match :-)"); System.out.println(); - - + + if (errors) System.out.println("Some of the test cases had errors :-("); else diff --git a/archive/ActivateGame.cpp b/archive/ActivateGame.cpp index 4c8274b..4a56f09 100755 --- a/archive/ActivateGame.cpp +++ b/archive/ActivateGame.cpp @@ -22,7 +22,7 @@ using namespace std; #define pb push_back #define all(v) v.begin(),v.end() -#define sz size() +#define sz size() #define loop(i,m) for(ui i=0;i > act; int solve( int x, int y ){ - + cout < cc || y > rr || x < 0 || y < 0)return 0; - + int maxx = 0; int res; for(int i = -1 ; i<=1;i++ ){ @@ -74,16 +74,16 @@ int solve( int x, int y ){ } } } - + return maxx; } int ActivateGame::findMaxScore(vector grid) { - + rr= grid.sz; if(rr > 0)cc= grid[0].sz; else cc =0; - + act.resize(rr); g.resize(rr); loop(i,rr){ @@ -96,9 +96,9 @@ int ActivateGame::findMaxScore(vector grid) { act[i].pb(false); } } - + act[0][0]=true; - + return solve(0,0); // return 5; } @@ -205,23 +205,23 @@ double test3() { int main() { int time; bool errors = false; - + time = test0(); if (time < 0) errors = true; - + time = test1(); if (time < 0) errors = true; - + time = test2(); if (time < 0) errors = true; - + time = test3(); if (time < 0) errors = true; - + if (!errors) cout <<"You're a stud (at least on the example cases)!" < buses, int at) { str << buses[i]; str >> arr >> intr >> count; str.clear(); - + cout <<"aaaa: " << at <<" "< arr+intr*(count-1)){ return }*/ - + for(int j = arr ;j < arr+intr*(count-1);j+=intr){ cout << j << " "<< at << " "< buses, int at) { } } } - + if(minn == INT_MAX)return -1; - + return minn; } @@ -218,27 +218,27 @@ double test4() { int main() { int time; bool errors = false; - + time = test0(); if (time < 0) errors = true; - + time = test1(); if (time < 0) errors = true; - + time = test2(); if (time < 0) errors = true; - + time = test3(); if (time < 0) errors = true; - + time = test4(); if (time < 0) errors = true; - + if (!errors) cout <<"You're a stud (at least on the example cases)!" <K of the N ministers, and to his horror, none of the K ministers has received the correct letter.



    The king is furious with his secretary, but he decides to give him one last chance to save his job. He asks the secretary the following question. In how many ways was it possible for him to distribute the letters so that the current situation would arise? In other words, how many different ways could the letters have been distributed such that a wrong letter went to each of the K ministers that has been called so far? Two ways are considered different if at least one minister gets a different letter. If the secretary can answer this question correctly, he can keep his job. Your job is to help the secretary by calculating the correct answer for him. Since the answer can be very large, return the answer modulo 1,000,000,007.

    -

    Definition

        
    Class:CarelessSecretary
    Method:howMany
    Parameters:int, int
    Returns:int
    Method signature:int howMany(int N, int K)
    (be sure your method is public)
        

    Constraints

    -N will be between 1 and 1000, inclusive.-K will be between 1 and N, inclusive.-K will be between 1 and 12, inclusive.

    Examples

    0)    
    2
    1
    Returns: 1
    There are two ministers, and one of them must not get his own letter. Therefore, the only possibility is that they get each other's letters.
    1)    
    3
    1
    Returns: 4
    The minister who must not get his own letter might get any of the two remaining letters. For each possibility, there are 2 ways to give the letters to the other ministers. Hence, the answer is 2*2 = 4. +

    Definition

        
    Class:CarelessSecretary
    Method:howMany
    Parameters:int, int
    Returns:int
    Method signature:int howMany(int N, int K)
    (be sure your method is public)
        

    Constraints

    -N will be between 1 and 1000, inclusive.
    -K will be between 1 and N, inclusive.
    -K will be between 1 and 12, inclusive.

    Examples

    0)
        
    2
    1
    Returns: 1
    There are two ministers, and one of them must not get his own letter. Therefore, the only possibility is that they get each other's letters.
    1)
        
    3
    1
    Returns: 4
    The minister who must not get his own letter might get any of the two remaining letters. For each possibility, there are 2 ways to give the letters to the other ministers. Hence, the answer is 2*2 = 4.
    2)
        
    3
    3
    Returns: 2
    Three ministers, and none of them get their own letters.
    3)
        
    7
    4
    Returns: 2790
    4)
        
    9
    1
    Returns: 322560
    5)
        
    714
    9
    Returns: 466134693

    This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.

    diff --git a/archive/CarelessSecretary.java b/archive/CarelessSecretary.java index 4108d50..139da24 100755 --- a/archive/CarelessSecretary.java +++ b/archive/CarelessSecretary.java @@ -8,9 +8,9 @@ public class CarelessSecretary { public int howMany(int N, int K) { - + } - - + + } //Powered by [KawigiEdit] 2.0! diff --git a/archive/CarelessSecretary.java.bak b/archive/CarelessSecretary.java.bak index 7a57813..02030c0 100755 --- a/archive/CarelessSecretary.java.bak +++ b/archive/CarelessSecretary.java.bak @@ -8,17 +8,17 @@ public class CarelessSecretary { public int howMany(int N, int K) { - + } - + public static void main(String[] args) { long time; int answer; boolean errors = false; int desiredAnswer; - - + + time = System.currentTimeMillis(); answer = new CarelessSecretary().howMany(2, 1); System.out.println("Time: " + (System.currentTimeMillis()-time)/1000.0 + " seconds"); @@ -115,8 +115,8 @@ public class CarelessSecretary else System.out.println("Match :-)"); System.out.println(); - - + + if (errors) System.out.println("Some of the test cases had errors :-("); else diff --git a/archive/ColorfulTilesEasy.cpp b/archive/ColorfulTilesEasy.cpp index a72c9c9..a887919 100755 --- a/archive/ColorfulTilesEasy.cpp +++ b/archive/ColorfulTilesEasy.cpp @@ -21,7 +21,7 @@ using namespace std; #define pb push_back #define all(v) v.begin(),v.end() -#define sz size() +#define sz size() #define loop(i,m) for(ui i=0;i= 0;i--){ - if( + if( (s[i]=='A' && t[ssiz-i-1] == 'T') || (s[i]=='T' && t[ssiz-i-1] == 'A') || (s[i]=='C' && t[ssiz-i-1] == 'G') || (s[i]=='G' && t[ssiz-i-1] == 'C') ){ - + } else{ return false; @@ -153,19 +153,19 @@ double test2() { int main() { int time; bool errors = false; - + time = test0(); if (time < 0) errors = true; - + time = test1(); if (time < 0) errors = true; - + time = test2(); if (time < 0) errors = true; - + if (!errors) cout <<"You're a stud (at least on the example cases)!" < 0)cc= grid[0].sz; else cc =0; - - + + act.resize(rr); loop(i,rr){ act[i].resize(cc); @@ -108,9 +108,9 @@ int DoorsGame::determineOutcome(string doors, int trophy) { act[i]=false; } } - + act[0][0]=true; - + return solve(0,0); } @@ -280,35 +280,35 @@ double test6() { int main() { int time; bool errors = false; - + time = test0(); if (time < 0) errors = true; - + time = test1(); if (time < 0) errors = true; - + time = test2(); if (time < 0) errors = true; - + time = test3(); if (time < 0) errors = true; - + time = test4(); if (time < 0) errors = true; - + time = test5(); if (time < 0) errors = true; - + time = test6(); if (time < 0) errors = true; - + if (!errors) cout <<"You're a stud (at least on the example cases)!" <song 0 -> song 1 (with probability 1/4)
  • song 1 (with probability 1/2)
  • -
    1)    
    {1, 10, 100, 1000, 10000}
    0
    Returns: {0.2, 0.2, 0.2, 0.2, 0.2 }
    2)    
    {5, 8, 4, 7}
    10
    Returns: {0.1875, 0.3125, 0.1875, 0.3125 }
    3)    
    {10, 1}
    9
    Returns: {0.9990234375, 9.765625E-4 }
    4)    
    {58, 47, 36, 25, 14, 3}
    100
    Returns: 
    +
    1)    
    {1, 10, 100, 1000, 10000}
    0
    Returns: {0.2, 0.2, 0.2, 0.2, 0.2 }
    2)    
    {5, 8, 4, 7}
    10
    Returns: {0.1875, 0.3125, 0.1875, 0.3125 }
    3)    
    {10, 1}
    9
    Returns: {0.9990234375, 9.765625E-4 }
    4)    
    {58, 47, 36, 25, 14, 3}
    100
    Returns:
     {0.32895835374381194, 0.26291497538241776, 0.18463894970453887, 0.1312301113062895,
      0.07518634032025856, 0.017071269542683242 }

    This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.

    diff --git a/archive/FoxListeningToMusic.java b/archive/FoxListeningToMusic.java index cf6cbb5..a35c3ef 100644 --- a/archive/FoxListeningToMusic.java +++ b/archive/FoxListeningToMusic.java @@ -8,18 +8,18 @@ public class FoxListeningToMusic { public double[] getProbabilities(int[] length, int T) { - + } - + public static void main(String[] args) { long time; double[] answer; boolean errors = false; double[] desiredAnswer; - + boolean same; - + time = System.currentTimeMillis(); answer = new FoxListeningToMusic().getProbabilities(new int[]{1, 2}, 1); System.out.println("Time: " + (System.currentTimeMillis()-time)/1000.0 + " seconds"); @@ -200,8 +200,8 @@ public static void main(String[] args) else System.out.println("Match :-)"); System.out.println(); - - + + if (errors) System.out.println("Some of the test cases had errors :-("); else diff --git a/archive/FuzzyLife.cpp b/archive/FuzzyLife.cpp index f59971a..a6f5ca7 100755 --- a/archive/FuzzyLife.cpp +++ b/archive/FuzzyLife.cpp @@ -21,7 +21,7 @@ using namespace std; #define pb push_back #define all(v) v.begin(),v.end() -#define sz size() +#define sz size() #define loop(i,m) for(ui i=0;i= maxx || y+j >= maxy )continue; - + summ += g[x+i][y+j]-'0'; - + } return summ; } @@ -67,19 +67,19 @@ int nsumm(vs g,int x,int y){ vs move(vs g){ int summ=0; vs g2; - + g2.resize(maxx); loop(i,maxx)g2[i].resize(maxy); - + for(int i = 0 ; i < maxx;i++ ) for(int j = 0 ; j < maxy;j++ ){ - + summ = nsumm(g,i,j); if(g[i][j]=='1'){ if(summ < 2 || summ > 3){ - g2[i][j]='0'; + g2[i][j]='0'; } else{ g2[i][j]='1'; @@ -104,10 +104,10 @@ int FuzzyLife::survivingCells(vector g) { int unc=0; vi un; int count=0; - + maxx=g.sz; if(g.sz>0)maxy=g[0].sz; - + for(int i =0;i < maxx ; i++){ for(int j =0;j g) { } } } - + for(int i =0;i < maxx ; i++){ for(int j =0;j g) { } cout <= 0 ; i --){ if(s2[i]==mchar){ m=i; @@ -94,7 +94,7 @@ char mchar; } } } - + mchar = 'B'; s1=row; s2=row; @@ -113,7 +113,7 @@ char mchar; } } } - + for(int i = row.sz-2 ; i >= 0 ; i --){ if(s2[i]==mchar){ m=i; @@ -227,23 +227,23 @@ double test3() { int main() { int time; bool errors = false; - + time = test0(); if (time < 0) errors = true; - + time = test1(); if (time < 0) errors = true; - + time = test2(); if (time < 0) errors = true; - + time = test3(); if (time < 0) errors = true; - + if (!errors) cout <<"You're a stud (at least on the example cases)!" < kingdom) { - + } diff --git a/archive/Islands.html b/archive/Islands.html index 6242c23..afc713e 100755 --- a/archive/Islands.html +++ b/archive/Islands.html @@ -9,8 +9,8 @@



    -Return the combined total length of beaches on all the islands.

    Definition

        
    Class:Islands
    Method:beachLength
    Parameters:vector <string>
    Returns:int
    Method signature:int beachLength(vector <string> kingdom)
    (be sure your method is public)
        

    Constraints

    -kingdom will contain between 1 and 50 elements, inclusive.-Each element of kingdom will contain between 1 and 50 characters, inclusive.-Each element of kingdom will contain the same number of characters.-Each character in kingdom will be either '.' or '#'.

    Examples

    0)    
    {".#...#.."}
    Returns: 4
    There are two small islands with water on two sides of each island.
    1)    
    {"..#.##", 
    - ".##.#.", 
    +Return the combined total length of beaches on all the islands.

    Definition

        
    Class:Islands
    Method:beachLength
    Parameters:vector <string>
    Returns:int
    Method signature:int beachLength(vector <string> kingdom)
    (be sure your method is public)
        

    Constraints

    -kingdom will contain between 1 and 50 elements, inclusive.
    -Each element of kingdom will contain between 1 and 50 characters, inclusive.
    -Each element of kingdom will contain the same number of characters.
    -Each character in kingdom will be either '.' or '#'.

    Examples

    0)
        
    {".#...#.."}
    Returns: 4
    There are two small islands with water on two sides of each island.
    1)
        
    {"..#.##",
    + ".##.#.",
      "#.#..."}
    Returns: 19
    The example in the problem statement.
    2)
        
    {"#...#.....",
      "##..#...#."}
    Returns: 15
    3)
        
    {"....#.",
      ".#....",
    diff --git a/archive/Islands.java b/archive/Islands.java
    index 856a2b9..1e3564c 100755
    --- a/archive/Islands.java
    +++ b/archive/Islands.java
    @@ -16,34 +16,34 @@ public int beachLength(String[] kdm)
     					if( j>0 && kdm[i].charAt(j-1) == '.')ans++;
     					if( j0 && j > 0 && kdm[i-1].charAt(j-1)=='.' && i % 2 == 0){
     						ans ++;
     					}
     					if(i > 0 && j < kdm[i].length()-1 && kdm[i-1].charAt(j+1) == '.' && i % 2 != 0){
     						ans ++;
     					}
    -					
    +
     					if(i < kdm.length-1 && j > 0 && kdm[i+1].charAt(j-1)=='.' && i % 2 == 0){
     						ans ++;
     					}
     					if(i < kdm.length-1 && j < kdm[i].length()-1 && kdm[i+1].charAt(j+1)=='.' && i % 2 != 0){
     						ans ++;
    -					}					
    +					}
     				}
     			}
     		}
     		return ans;
     	}
    -	
    +
     	public static void main(String[] args)
     	{
     		long time;
     		int answer;
     		boolean errors = false;
     		int desiredAnswer;
    -		
    -		
    +
    +
     		time = System.currentTimeMillis();
     		answer = new Islands().beachLength(new String[]{".#...#.."});
     		System.out.println("Time: " + (System.currentTimeMillis()-time)/1000.0 + " seconds");
    @@ -108,8 +108,8 @@ public static void main(String[] args)
     		else
     			System.out.println("Match :-)");
     		System.out.println();
    -		
    -		
    +
    +
     		if (errors)
     			System.out.println("Some of the test cases had errors :-(");
     		else
    diff --git a/archive/JingleRingle.cpp b/archive/JingleRingle.cpp
    index dc51a0e..ca31be4 100755
    --- a/archive/JingleRingle.cpp
    +++ b/archive/JingleRingle.cpp
    @@ -21,7 +21,7 @@ using namespace std;
     
     #define pb push_back
     #define all(v) v.begin(),v.end()
    -#define sz  size() 
    +#define sz  size()
     #define loop(i,m) for(ui i=0;i i + wkt) ? i + wkt : wa;
     			start = (ba < i) ? i : ba;
     			if( (ba >= i && ba <= i+wkt ) && ( wa >= i && wa <= i+wkt ) ){
    @@ -68,7 +68,7 @@ double LateProfessor::getProbability(int wtt, int wkt, int lt, int ba, int wa) {
     				else
     					return 0.0;
     			}
    -			
    +
     			else if( ( wa >= i && wa <= i+wkt ) ){
     				if(last > i+wkt-lt )
     					term2+=wkt-lt < 0 ? 0 : wkt-lt;
    @@ -89,7 +89,7 @@ double LateProfessor::getProbability(int wtt, int wkt, int lt, int ba, int wa) {
     	}
     	if(term3==0.0 && term2 == 0)return 0.0;
     	else if(term3==0.0 && term2 > 0) return 1.0;
    -	
    +
     	return (term2*1.0) / (term3*1.0);
     }
     
    @@ -254,31 +254,31 @@ double test5() {
     int main() {
     	int time;
     	bool errors = false;
    -	
    +
     	time = test0();
     	if (time < 0)
     		errors = true;
    -	
    +
     	time = test1();
     	if (time < 0)
     		errors = true;
    -	
    +
     	time = test2();
     	if (time < 0)
     		errors = true;
    -	
    +
     	time = test3();
     	if (time < 0)
     		errors = true;
    -	
    +
     	time = test4();
     	if (time < 0)
     		errors = true;
    -	
    +
     	time = test5();
     	if (time < 0)
     		errors = true;
    -	
    +
     	if (!errors)
     		cout <<"You're a stud (at least on the example cases)!" <
  • John arrives at time 0.
  • John waits for Dr. Wesley to arrive.
  • If after waitTime seconds Dr. Wesley has not arrived yet, John goes to take a walk for walkTime seconds.
  • -
  • John therefore arrives back to the classroom exactly at time waitTime + walkTime.
  • +
  • John therefore arrives back to the classroom exactly at time waitTime + walkTime.
  • If Dr. Wesley has not arrived yet, John waits another waitTime seconds and then proceeds to take a new walk. The process is repeated until John becomes aware that Dr. Wesley has arrived.
  • Overall, John stands in front of the class door from time 0 to time waitTime, inclusive, then from time walkTime + waitTime to time walkTime + 2*waitTime, inclusive, and so on. At all other time moments he walks outside. diff --git a/archive/LinearTravellingSalesman.cpp b/archive/LinearTravellingSalesman.cpp index ddc19f7..c07a291 100755 --- a/archive/LinearTravellingSalesman.cpp +++ b/archive/LinearTravellingSalesman.cpp @@ -22,7 +22,7 @@ using namespace std; #define pb push_back #define all(v) v.begin(),v.end() -#define sz size() +#define sz size() #define loop(i,m) for(ui i=0;i x, vector y int maxx , maxy,minx,miny; maxx=0; maxy=0; - + minx=INT_MAX; miny=INT_MAX; - + loop(i,x.sz){ if(x[i] > maxx) maxx = x[i]; if(y[i] > maxy) maxy = y[i]; - + if(x[i] < minx) minx = x[i]; if(y[i] < miny) miny = y[i]; } - + return abs(maxx-minx)+abs(maxy-miny); } @@ -196,27 +196,27 @@ double test4() { int main() { int time; bool errors = false; - + time = test0(); if (time < 0) errors = true; - + time = test1(); if (time < 0) errors = true; - + time = test2(); if (time < 0) errors = true; - + time = test3(); if (time < 0) errors = true; - + time = test4(); if (time < 0) errors = true; - + if (!errors) cout <<"You're a stud (at least on the example cases)!" <=4){ loop(i,pow4.sz){ if(pow4[i] >= n && i >0){ @@ -152,19 +152,19 @@ double test2() { int main() { int time; bool errors = false; - + time = test0(); if (time < 0) errors = true; - + time = test1(); if (time < 0) errors = true; - + time = test2(); if (time < 0) errors = true; - + if (!errors) cout <<"You're a stud (at least on the example cases)!" <= num.sz)return true; if(t >= num.sz)return false; - + if(sol[t])return solve(s,t+1); if(t == n && s == t)return solve(s,t+1); @@ -71,21 +71,21 @@ bool solve(int s,int t){ //best[s][t]=1; //return true; } - + return solve(s,t+1); } vector PrimePairs::matches(vector numbers) { vi res; res.clear(); - + num = numbers; prm = new bool[10000]; loop(i,10000){ prm[i]=1; //loop(j,10000)best[i][j]=-1; } - + prm[0]=0; prm[1]=0; prm[2]=0; @@ -108,7 +108,7 @@ vector PrimePairs::matches(vector numbers) { sol.clear(); sol.resize(num.sz); fill(all(sol),0); - + bool fail=false; if(prm[num[0]+num[i]]){ cout << num[i] < a[j]) || ( a[i] == a[j] && c[i] > c[j])){ k= a[i]; a[i]=a[j]; a[j]=k; - + k=c[i]; c[i] = c[j]; c[j] = k; - + } } } @@ -76,7 +76,7 @@ vi c; k= c[i]; c[i]=c[j]; c[j]=k; - + k=b[i]; b[i] = b[j]; b[j] = k; @@ -210,19 +210,19 @@ double test2() { int main() { int time; bool errors = false; - + time = test0(); if (time < 0) errors = true; - + time = test1(); if (time < 0) errors = true; - + time = test2(); if (time < 0) errors = true; - + if (!errors) cout <<"You're a stud (at least on the example cases)!" < sss = new ArryList(); sss.toArray(String.class); } diff --git a/archive/SubAnagrams.java.bak b/archive/SubAnagrams.java.bak index dbd4cba..757951c 100755 --- a/archive/SubAnagrams.java.bak +++ b/archive/SubAnagrams.java.bak @@ -8,17 +8,17 @@ public class SubAnagrams { public int maximumParts(String[] suppliedWord) { - + } - + public static void main(String[] args) { long time; int answer; boolean errors = false; int desiredAnswer; - - + + time = System.currentTimeMillis(); answer = new SubAnagrams().maximumParts(new String[]{"ABABAB"}); System.out.println("Time: " + (System.currentTimeMillis()-time)/1000.0 + " seconds"); @@ -83,8 +83,8 @@ public class SubAnagrams else System.out.println("Match :-)"); System.out.println(); - - + + if (errors) System.out.println("Some of the test cases had errors :-("); else diff --git a/archive/SumRectangle.cpp b/archive/SumRectangle.cpp index fa20001..28a9281 100755 --- a/archive/SumRectangle.cpp +++ b/archive/SumRectangle.cpp @@ -21,7 +21,7 @@ using namespace std; #define pb push_back #define all(v) v.begin(),v.end() -#define sz size() +#define sz size() #define loop(i,m) for(ui i=0;i l, vector t) { vvi grid; - + my = l.sz; mx = t.sz; cout << mx << " "<< my< workingDays) { - + } diff --git a/archive/VacationTime.java b/archive/VacationTime.java index 17c0fbb..44a2c6d 100755 --- a/archive/VacationTime.java +++ b/archive/VacationTime.java @@ -8,7 +8,7 @@ public class VacationTime { public int bestSchedule(int N, int K, int[] w) { - + int minn = 999999; for(int i = 0 ; i+K-1 < N ;i++){ int yy =0; @@ -22,18 +22,18 @@ public int bestSchedule(int N, int K, int[] w) } minn = Math.min(yy,minn); } - + return minn; } - + public static void main(String[] args) { long time; int answer; boolean errors = false; int desiredAnswer; - - + + time = System.currentTimeMillis(); answer = new VacationTime().bestSchedule(3, 3, new int[]{2}); System.out.println("Time: " + (System.currentTimeMillis()-time)/1000.0 + " seconds"); @@ -114,8 +114,8 @@ public static void main(String[] args) else System.out.println("Match :-)"); System.out.println(); - - + + if (errors) System.out.println("Some of the test cases had errors :-("); else diff --git a/archive/WhatsThisChord.cpp b/archive/WhatsThisChord.cpp index 25d1b34..df58b38 100755 --- a/archive/WhatsThisChord.cpp +++ b/archive/WhatsThisChord.cpp @@ -22,7 +22,7 @@ using namespace std; #define pb push_back #define all(v) v.begin(),v.end() -#define sz size() +#define sz size() #define loop(i,m) for(ui i=0;i c) { all.pb("C"); all.pb("C#"); all.pb("D"); - all.pb("D#"); + all.pb("D#"); all.pb("E"); all.pb("F"); all.pb("F#"); @@ -61,7 +61,7 @@ string WhatsThisChord::classify(vector c) { all.pb("A"); all.pb("A#"); all.pb("B"); - + vs strl; strl.pb("E"); strl.pb("A"); @@ -69,7 +69,7 @@ string WhatsThisChord::classify(vector c) { strl.pb("G"); strl.pb("B"); strl.pb("E"); - + set res; int i=0; string sss=""; @@ -85,14 +85,14 @@ string WhatsThisChord::classify(vector c) { sss=""; } set::iterator it; - + vs fres; for (it=res.begin(); it!=res.end(); it++){ fres.pb(*it); } - + vs f2; - + loop(i,all.sz) loop(j,fres.sz){ if(all[i].compare(fres[j])==0){ @@ -100,19 +100,19 @@ string WhatsThisChord::classify(vector c) { cout << f2[f2.sz-1]< c) { } } } - + cout <

    -Musical notes are given the following 12 names, in ascending order: +Musical notes are given the following 12 names, in ascending order:

    C, C#, D, D#, E, F, F#, G, G#, A, A#, B.

    @@ -15,7 +15,7 @@

    -In this problem we will consider a six-string guitar with standard tuning. +In this problem we will consider a six-string guitar with standard tuning. The six strings of such a guitar are tuned to the following notes, in order: E, A, D, G, B, E. (Guitar players, please note that the order used starts with the lowest string.)

    @@ -52,6 +52,6 @@

    Given the vector <int> chord, decide whether it is one of the 12 major or one of the 12 minor chords, as defined above. If it is one of these chords, return its name as a string ("X Major" for major chords, "X Minor" for minor chords). If the chord represented by chord is not one of our chords, return an empty string. -

    Definition

        
    Class:WhatsThisChord
    Method:classify
    Parameters:vector <int>
    Returns:string
    Method signature:string classify(vector <int> chord)
    (be sure your method is public)
        

    Notes

    -When classifying a chord the only thing that matters is the set of notes played. The number of times a note is played does not matter as long as each of the required notes is played at least once.

    Constraints

    -chord will contain exactly 6 elements.
    -Each element of chord will be between -1 and 12, inclusive.

    Examples

    0)
        
    {-1, 3, 2, 0, 1, 0}
    Returns: "C Major"
    This is the C Major chord, as described in the problem statement.
    1)
        
    {3,2,0,0,0,3}
    Returns: "G Major"
    This is another of the basic guitar chords. The strings play the following notes: G, B, D, G, B, G. If we take the C Major chord (C,E,G) and shift it by 7, we get (G,B,D), which is precisely the set of notes in this chord. Hence the chord is G Major.
    2)
        
    {-1,0,2,2,1,0}
    Returns: "A Minor"
    This is the most common way of playing the A Minor chord. The three distinct notes we hear in this case are A, C, and E.
    3)
        
    {-1,4,3,1,2,1}
    Returns: "C# Major"
    4)
        
    {8,10,10,9,8,8}
    Returns: "C Major"
    There are multiple ways to play each chord.
    5)
        
    {0,0,0,0,0,0}
    Returns: ""
    This is not one of our 24 simple chords.
    6)
        
    {-1,-1,4,-1,-1,7}
    Returns: ""
    Neither is this.
    7)
        
    {-1, -1, 2, 0, 1, 0}
    Returns: "C Major"
    The notes played in this chord are {none, none, E, G, C, E}. +

    Definition

        
    Class:WhatsThisChord
    Method:classify
    Parameters:vector <int>
    Returns:string
    Method signature:string classify(vector <int> chord)
    (be sure your method is public)
        

    Notes

    -When classifying a chord the only thing that matters is the set of notes played. The number of times a note is played does not matter as long as each of the required notes is played at least once.

    Constraints

    -chord will contain exactly 6 elements.
    -Each element of chord will be between -1 and 12, inclusive.

    Examples

    0)
        
    {-1, 3, 2, 0, 1, 0}
    Returns: "C Major"
    This is the C Major chord, as described in the problem statement.
    1)
        
    {3,2,0,0,0,3}
    Returns: "G Major"
    This is another of the basic guitar chords. The strings play the following notes: G, B, D, G, B, G. If we take the C Major chord (C,E,G) and shift it by 7, we get (G,B,D), which is precisely the set of notes in this chord. Hence the chord is G Major.
    2)
        
    {-1,0,2,2,1,0}
    Returns: "A Minor"
    This is the most common way of playing the A Minor chord. The three distinct notes we hear in this case are A, C, and E.
    3)
        
    {-1,4,3,1,2,1}
    Returns: "C# Major"
    4)
        
    {8,10,10,9,8,8}
    Returns: "C Major"
    There are multiple ways to play each chord.
    5)
        
    {0,0,0,0,0,0}
    Returns: ""
    This is not one of our 24 simple chords.
    6)
        
    {-1,-1,4,-1,-1,7}
    Returns: ""
    Neither is this.
    7)
        
    {-1, -1, 2, 0, 1, 0}
    Returns: "C Major"
    The notes played in this chord are {none, none, E, G, C, E}. The set of notes played is (C,E,G), hence this is again a C Major chord. (In music theory this chord has a more precise name C/E, but this is irrelevant. It is still a C Major chord.)

    This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.