Tensor's blog

By Tensor, 6 years ago, In English

This is my profile on Typeracer, i've completed 1980 race :D but still not that fast typist. if you already have a profile or sign up and take a race then share your profile or speed, just for having some fun :-)

good luck and have some fun

Read more »

 
 
 
 
  • Vote: I like it
  • +24
  • Vote: I do not like it

By Tensor, 7 years ago, In English

Is this an incoming seven days contest or it's just a mistake ?!!

Read more »

 
 
 
 
  • Vote: I like it
  • +3
  • Vote: I do not like it

By Tensor, 7 years ago, In English

This is somehow far from competitive programming but recently I'm trying to get enrolled in a summer of code project with boost library ( an open source C++ library ), to get enrolled in the boost summer of code projects requires a competency test, mine was writing a simple C++11 vector-like class.

I've written an std::vector like class but not with all methods like that of the STL (it's not required to fully complete the class), so it would be appreciated to give any feedback about my code and tell me if any issues are found.

Thanks in advance :)

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By Tensor, 7 years ago, In English

I have been solving this problem, but i don't know what is wrong with my submission.

#include <unordered_map>
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <unordered_set>

using namespace std;

const int N = 101, inf = 1e9;

char a[N], b[N];

int f[N][N][N], n, m;

int dp(int i, int j, int k, int val) {
  if (i < 0 || j < 0)
    return -inf;
  if (k == 0)
    return val;
  int &ret = f[i][j][k];
  if (ret + 1)
    return ret;
  ret = 0;
  if (a[i] == b[j])
    ret = max(ret, dp(i - 1, j - 1, k - 1, val + a[i]));
  else {
    ret = max(ret, dp(i - 1, j, k, val));
    ret = max(ret, dp(i, j - 1, k, val));
  }
  return ret;
}

int main(void) {
#ifdef DEBUG  
  freopen("in.txt", "r", stdin);
//  freopen("o.txt", 'w', stdout);
#endif
  int tc, k;
  for (scanf("%d", &tc); tc--; ) {
    scanf("%s %s %d", a, b, &k);
    n = (int)strlen(a), m = (int)strlen(b);
    memset(f, -1, sizeof(f));
    printf("%d\n", dp(n - 1, m - 1, k, 0));
  }
  return 0;
}

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By Tensor, 7 years ago, In English

currently i'm trying to change gedit settings in order to be more capable of compiling, running, automatically inserting templates... etc. the problem is i don't know how to change the settings i searched the web and find zillions of answers but still can't configure the settings!

any help would be pleased :)

thanks in advance :-)

Read more »

 
 
 
 
  • Vote: I like it
  • +1
  • Vote: I do not like it

By Tensor, 7 years ago, In English

trying to increase the stack size while running c++ code from terminal, i tried google and get gcc -Wl,--stack,200000000 and also g++ -Wl,--stack,200000000 i tried to write these through the terminal but i get something like cannot find and error and fatal error, any help please!

thanks in advance

UP solved

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By Tensor, 7 years ago, In English

while solving a certain problem in c++, I tried to see the execution time on my pc.

Running the program on the terminal and mingwG++ gives time 0.14, while running it through visual studio it gives me 3.874!!!!!

please can anyone explain me this phenomenon, why there is such a great difference between both executions ?!

thanks in advance.

Read more »

 
 
 
 
  • Vote: I like it
  • +3
  • Vote: I do not like it

By Tensor, 7 years ago, In English

please can anyone explain to me why we use combinations in such problems like problem D ?!

thanks in advance and happy new year :-)

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By Tensor, 7 years ago, In English

may be some of you know how to collect all contests in one calender, i've found this site with this calender, just click on +google calender in the bottom right of the calender in the site and it's all yours and will be synchronized automatically with all contest from codeforces, hackerrank, topcoder, timus, codechef and googlejam i think.

happy coding!

Read more »

 
 
 
 
  • Vote: I like it
  • +5
  • Vote: I do not like it

By Tensor, 7 years ago, In English

I do believe in books and practicing alot depending on my own, that's how i started tell now. But it turns that books, practicing alot and a coach the three together is the fastest method to do better quickly.

I need a coach to train me and give me that advices that would make me better and better and grow faster in competitive programming. Is there anyone willing to help me ?

thanks in advance..

UP: fortunately i had found one :-)

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By Tensor, 7 years ago, In English

I'm new to dynamic programming, I had been reading this book but don't know if it a good resource for learning dynamic programming approaches, so if any one had any book (not a tutorial 'please') on dynamic programming please tell me..

thanks in advance!

Read more »

 
 
 
 
  • Vote: I like it
  • +4
  • Vote: I do not like it

By Tensor, 7 years ago, In English

I had been solving this problem

this is my code so far ... any help would be appreciated.

thanks in advance.

Read more »

 
 
 
 
  • Vote: I like it
  • +2
  • Vote: I do not like it

By Tensor, 7 years ago, In English
  • have been trying this problem but in vain .

here is my code so far. I have considered the graph as DAG.

any help plese. thanks in advance

Read more »

 
 
 
 
  • Vote: I like it
  • 0
  • Vote: I do not like it

By Tensor, 7 years ago, In English

I'm solving this problem but there is a little problem for first test case my solution on visual studio returns (2 6) the right answer. after submitting i get wrong answer on test case 1!! getting (1 6) either than (2 6). here is my code please can any one tell me what's the problem?!! thanks in advance!

Read more »

 
 
 
 
  • Vote: I like it
  • -3
  • Vote: I do not like it

By Tensor, 7 years ago, In English
  • This is just a method i used to make me able to include bits/stdc++.h
  • in visual c++.
  • for those had minGW installed on PC :
  • C:\MinGW\mingw32\lib\gcc\mingw32\4.8.1\include\c++\mingw32\bits
  • copy this folder and then go to this adress
  • C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include
  • paste your folder. go to your visual studio project type bits you will see
  • the auto-complete for the library and then choose stdc++.h
  • for those don't have minGW:
  • you should write your own header file and include all libraries in it then
  • go to C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\include
  • make new folder name it "bits" and name the header file stdc++.h
  • then paste it in "bits" folder.
  • Hope this helps!
  • Happy coding

Read more »

 
 
 
 
  • Vote: I like it
  • +28
  • Vote: I do not like it

By Tensor, 7 years ago, In English

any one can help me with this Problem from spoj. I have tried zillions time. once I used 3D bfs getting wrong answer then using 2D bfs getting between wrong answer and time limit.

2D bfs 3D bfs

thanks in advance!

Read more »

 
 
 
 
  • Vote: I like it
  • +3
  • Vote: I do not like it