shisukenohara's blog

By shisukenohara, history, 4 weeks ago, In English

Link To My Website

Try It Out!!

Features

The website allows you to run code with stdin in Python3 or C++17 and it also allows you to smoothly try to hack someone else's solution smoothly via manually written test cases or generator (PS: It also tells if the code gives TLE or MLE).

  • Edit: As pointed out by near_ai, A new feature is added that doesn't let you run malicious code or the code which can potentially be harmful for the system.
  • Edit: Added the feature that lets input allowed Time (in seconds) and allowed Memory (in MB) in both Correct Code and New Code in Hack Interface making the functionality more robust.
  • Edit: As suggested by RangeyBhakt and more, added safe sandboxing.

Motivation

As a competitive programming enthusiast, I always wanted to hack a solution but as of now even after being a Codeforces Expert, I have never successfully hacked a solution.

As of now there are multiple websites that allow one to write code with stdin but there is nothing that makes it smooth to hack someone else's code via manual test cases or generator smoothly (at least I didn't find one), so I made one.

Note:

  • Please try it and give feedback or suggestions in comments
  • Please upvote if you like the website or the blog

Full text and comments »

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

By shisukenohara, history, 5 weeks ago, In English

How Codeforces Helped Me Brainstorm a New Concept for My University's Major Project

Personally, I think Leetcode is great for getting started with DSA, AtCoder is excellent for practicing specific algorithm implementations like Binary Search or DP, and then there’s Codeforces, which, for me, is perfect for brainstorming.

What Happened with My Major Project

So, a bit of context: I’m working on my University’s Major Project, which involves Blockchain and Artificial Intelligence. After presenting the synopsis, the panellist told me: I should innovate or implement something that doesn’t exist yet or can improve existing technologies.

But how do I innovate in a field as crowded as blockchain? It’s already a mature technology. But then I started to think about the challenges that concurrent requests would bring as my project on Production Level expects a lot of concurrent requests. In blockchain, proof of work (the process that validates each block) can take time, and this might not be ideal if the system is supposed to handle a high number of requests all at once.

How Codeforces Helped Me Brainstorm

Normally, blockchains are like a single linked list. They’re just a long chain of blocks, one after the other, each one depending on the previous block’s data. This is secure, but when you need to handle lots of requests at the same time, waiting for one block to be validated before the next one gets created is a bottleneck.

Enter Blocktree

So, I came up with something I call Blocktree. Here’s the basic idea:

  • Blockchain is linear. One block after another. It’s like a straight path.
  • Blocktree is more like a branching structure. Instead of generating one block at a time, multiple blocks can be created in parallel. These blocks can run on different branches of the tree, and later on, they can converge at specific points, or what I call merge nodes.

Note: I don't know if this already exists, I am just saying I founded this concept on my own without any external help.

Why is this useful? Well, if you’re working with a system that needs to handle a ton of concurrent requests, Blocktree can process multiple transactions at once. Each branch of the tree works on a separate batch of transactions. Eventually, these branches can come back together and ensure everything is still in sync, just like how a regular blockchain works.

Where Codeforces Comes In

So why do I credit Codeforces with this idea? It’s because of the way it challenges you to think.

I started imagining blockchain not as a chain but as a graph or tree. In competitive programming, especially on Codeforces, you’re constantly optimizing things for time and space complexity, so I was already in the mindset of improving the performance of existing systems. That’s how Blocktree was born.

Benefits of Blocktree

  1. Parallel Processing: By having multiple blocks being generated simultaneously, you can increase the number of transactions processed in the same amount of time.

  2. Better Scalability: Since the system isn’t stuck with just one sequential chain, it can scale better as the number of requests grows.

  3. Reduced Bottlenecks: Traditional blockchains can slow down as the number of transactions increases. Blocktree sidesteps that by allowing multiple “lanes” for transactions.

  4. Fault Tolerance: If one branch runs into a problem (say, it’s compromised), the rest of the branches can keep going, which helps with system resilience.

Wrapping It Up

So yeah, that’s how Codeforces helped me come up with Blocktree. While working through those complex problems on the platform, I started seeing how blockchain could evolve from a linear chain into a more flexible and scalable structure.

Blocktree isn’t some fully-fledged system yet—it’s still an idea I’m working on for my major project—but I’m excited to develop it further and see how it works in a real-world scenario.

Credits:

  • Wikipedia for external links for Beginners
  • ChatGPT for paraphrasing and "turning this blog into better english"

Full text and comments »

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

By shisukenohara, history, 7 weeks ago, In English

I am new at CP, and have only given one contest Can someone please help me and tell me what is wrong in my approach for the question 431C - k-Tree. I am trying Dynamic Programming.

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double

const int MOD = 1000000007;
vector<vector<int>> memo;

int dp(int k, int n, int d, int found)
{
  if(n==0)
  {
    if(found) return 1;
    else return 0;
  }
  if(n<0)
  {
    return 0;
  }
  if(memo[n][found]!=-1)
  {
    return memo[n][found];
  }
  int total = 0;
  for(int i=1; i<=k; i++)
  {
    if(n-i < 0) break;
    total = (total%MOD + dp(k, n-i, d, found || i>=d)%MOD)%MOD;
  }
  return memo[n][found] = total%MOD;
  
}

int32_t main() 
{
  int k, n, d;
  cin >> k >> n >> d;
  memo = vector<vector<int>>(n+1, vector<int>(2, -1));
  cout << dp(k, n, d, 0) << "\n";
  return 0;
}

Fails on Test case 5: 4 3 2

Expected: 6

Output: 3

Full text and comments »

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