yadv's blog

By yadv, history, 3 years ago, In English

I wanted to know that how codeforces backend is made / can be made. Couldn't find any article/blog so thought of asking. I know it may sound pretty basic to some but just wanted to know out of curiosity:D

Wanted to know:

  • The tech stack used

  • How authentication is handled

  • How every users data is stored, like previous history etc.

  • How upcoming contest opens / happens within a fixed time window

  • How the questions are loaded and submission/score count happens for every user.

  • How the final leaderboard is calculated and displayed

  • How the security is maintained.

Full text and comments »

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

By yadv, history, 4 years ago, In English

Help needed regarding today's contest. Problem D (Colored Rectangles).

I tried to solve this problem using a 3-dimensional dp array but I'm not able to figure out where I went wrong. My code is written below with comments, and it won't take much of your time. Thank you.

int r,g,b; cin>>r>>g>>b;    // number of red, green and blue pair
vi ar(r),ag(g),ab(b);      // vector to store each of them. (ar is for red, ag is for green, ab for blue)

for (ll i = 0; i < r; ++i)      
  cin>>ar[i];
for (ll i = 0; i < g; ++i)
   cin>>ag[i];
for (ll i = 0; i < b; ++i)
  cin>>ab[i];


// declaring a 3d vector to store all the possible choices for red,green and blue
//dp vector is 1-based index

vector<vector<vector<int>>> dp (r+1,vector<vector<int> >(g+1,vector <int>(b+1,0)));

for (ll i = 1; i < r+1; ++i)
{
  for (ll j = 1; j < g+1; ++j)
  {
    for (ll k = 1; k < b+1; ++k)
    {
       // exclude
      dp[i][j][k]=dp[i-1][j-1][k-1];

      // red & green include
      dp[i][j][k]=max(dp[i][j][k], ((ar[i-1]*ag[j-1])+dp[i-1][j-1][k]));

       // red & blue include
      dp[i][j][k]=max(dp[i][j][k], ((ar[i-1]*ab[k-1])+dp[i-1][j][k-1]));

       // green & blue
      dp[i][j][k]=max(dp[i][j][k], ((ab[k-1]*ag[j-1])+dp[i][j-1][k-1]));    
    }
  }
}
cout<<dp[r][g][b];

Full text and comments »

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

By yadv, history, 4 years ago, In English

I was recently solving atcoder dp problems but for Knapsack 1 & Knapsack 2 I'm having a little problem. I saw errichto's stream and saw others code as well but wasn't able to find out where I'm going wrong.

Here is my code for Knapsack-I: https://atcoder.jp/contests/dp/submissions/15549225

And this is for Knapsack-II : https://atcoder.jp/contests/dp/submissions/15548921

Thank you for your time.

Full text and comments »

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

By yadv, history, 4 years ago, In English

From several months I have been seeing this sort of pattern in blog that whenever a beginner asks a question people down-vote it. Some of their doubts are really genuine but no body answers them straightly. The point of writing this blog is that if someone asks a problem and if the problem is really bad then do down-vote it I'm with you but don't do it unnecessary. Don't let the person who is in learning phase feel that his/her doubt is stupid.

Hope you got it! Take your time before down-voting this:)

Full text and comments »

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