Comments

Yes, the Firefox Add-on has also been published!

Auto comment: topic has been updated by SilverTongue1729 (previous revision, new revision, compare).

Sure, will do it soon. For now you can use a user script manager extension like TamperMonkey, and then install this script from GreasyFork.

Thanks!

Auto comment: topic has been updated by SilverTongue1729 (previous revision, new revision, compare).

Auto comment: topic has been updated by SilverTongue1729 (previous revision, new revision, compare).

Yes it is!!

An alternate solution to D which doesn't use DP:

Similar to the solution in the editorial I used a DSU to keep track of components, but to check whether elements $$$i$$$ and $$$i+d_i$$$ are connected, I simply need to check among operations $$$j$$$ where $$$d_j = d_i$$$, and $$$a_j \% d_j = i\%d_i$$$. I used a map to store sets of operations together based on $$$d_j$$$ and $$$a_j\%d_j$$$, and I stored each operation as a pair $$$[ a_j, a_j + k_j \cdot d_j ]$$$.

Now each set of operations can now simply be represented as sets of intervals, and I used a datastructure which I called an IntervalSet which internally uses an std::set to efficiently a insert intervals in amortized $$$O(\text{log n})$$$ and store them efficiently by combining overlapping intervals and query whether an interval is completely included in the set in $$$O(\text{log n})$$$ where $$$n$$$ is the number of intervals in the set. This allows me to simply query whether $$$[i,i+d_i]$$$ is included in the among the operations with $$$d_j = d_i$$$, and $$$a_j \% d_j = i\%d_i$$$ which makes the code very simple.

void solve(){
  int n,m; cin>>n>>m;
  
  DSU dsu(n);
  
  map<pii, IntervalSet2<int>> mp;
  for_(i,0,m) {
    int a,d,k; cin>>a>>d>>k;
    a--;
    mp[{d,a%d}].insert({a, a+k*d}); 
  }
  
  for_(i,0,n){
    for_(di,1,11){
      if (i+di >= n) break;
      if (mp[{di,i%di}].contains({i,i+di})) dsu.merge(i,i+di);
    }
  }
  
  auto groups = dsu.groups();
  cout<<sz(groups)<<nl;
}

My submission: 283669482

PS: I used ChatGPT to help in implementing the IntervalSet class so its not in a great state rn;) and I haven't seen any implementations of such an IntervalSet class, so I would love to learn about any other implementations you guys know about.

Contests will mostly be held from 2-7pm IST (UTC +5:30), exact timings will be confirmed for each contest.

Could you add the tags for Chinese Remainder Theorem, or perhaps for extended Euclids?

Ayy, that's great! Discovering all the twists when coming up with the problem was soo fun, it honestly the best part about this problem imo. Hope you enjoyed solving it!

gl