Блог пользователя awoo

Автор awoo, история, 5 месяцев назад, По-русски

Neapolis University Pafos

Привет, Codeforces!

Благодаря поддержке Neapolis University Pafos, продолжается серия образовательных раундов.

В Nov/28/2025 17:35 (Moscow time) состоится Educational Codeforces Round 185 (Rated for Div. 2).

Этот раунд будет рейтинговым для участников с рейтингом менее 2100. Соревнование будет проводиться по немного расширенным правилам ICPC. Штраф за каждую неверную посылку до посылки, являющейся полным решением, равен 10 минутам. После окончания раунда будет период времени длительностью в 12 часов, в течение которого вы можете попробовать взломать абсолютно любое решение (в том числе свое). Причем исходный код будет предоставлен не только для чтения, но и для копирования.

Вам будет предложено 6 или 7 задач на 2 часа. Мы надеемся, что вам они покажутся интересными.

Задачи вместе со мной придумывали и готовили Адилбек adedalic Далабаев, Иван BledDest Андросов, Максим Neon Мещеряков, Роман Roms Глазов и Максим FelixArg Новоточинов. Также большое спасибо Михаилу MikeMirzayanov Мирзаянову за системы Polygon и Codeforces.

Удачи в раунде! Успешных решений!

UPD: Разбор опубликован

  • Проголосовать: нравится
  • -290
  • Проголосовать: не нравится

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится -8 Проголосовать: не нравится

as a contestant, i woke up like a sleeper agent at the sight of 6 or 7 problems

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

As a commenter, I commented very fast again!

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

as a contestant am searching for the tester's comment

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

As a contestant, i am waiting for this contest to start

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

where is score distribution?

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67 67

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится -17 Проголосовать: не нравится

676767676767676767676767676766767676767676767676767677667767676767676767667

»
5 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

No more weak pretest please:)

Btw, hope to solve at least 3 problems, thus increase my rating.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hope to solve 5 problems this contest

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится -6 Проголосовать: не нравится

Hope to rank up!

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Is there an interactive problem??

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hello Gays.

Hope that i will top in the next contest.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

As a newbie on codeforces , I will try my best to solve some questions from this contest .

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

first contest

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

hh i wanna ac 1 problem that's enough 2 me

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

six xor seven

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

score distribution>>?

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

I hope problem B is not 2D problem

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Nice B

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

that was tough :/

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Ok, got it. E was a little easier than D ,but how more than 1k people got AC -_- ??????

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +15 Проголосовать: не нравится

There seem to a lot of cheaters in this round

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +12 Проголосовать: не нравится

How can one become master in this economy. Please do the needful by removing cheaters at the top.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +80 Проголосовать: не нравится

terrible D

»
5 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится +12 Проголосовать: не нравится

Spent entire time debugging problem D edge cases. Always seems like a waste of a competition when you spend more time debugging than actually thinking about or solving problems.

Would be nice if they showed failures on test cases (maybe not all test cases but first 5 would be nice) you still get punished for your submission failures, but it also distinguishes between competitors who can solve the problem but are missing edge cases, vs competitors who flat out can't solve the problem. Always hate getting batched in the same ranking as the group who can't even attempt to solve a problem, when i can make a single tweak to solve a problem right after the contest.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

i hope such a D not exist anymore on rated rounds

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

this is way too hard for me

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

In problem C, i tried to sort both arrays, then, considering each index i, if (r[i]+1]*q[i]+r[i]<=k then it counts as a correct pair. Idk where im wrong, hlep :D

  • »
    »
    5 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    sort quotients increasing, remainders decreasing.

    Here's where you fucked up. If you can't match a remainder to the lowest remaining quotient, you discard the high remainder but don't discard the low quotient.

    keep track of your quotient index. Then iterate through your remainders (largest to smallest) if you have a match, increase your quotient index and add to answer, otherwise do nothing

    • »
      »
      »
      5 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      "Here's where you fucked up. If you can't match a remainder to the lowest remaining quotient, you discard the high remainder but don't discard the low quotient."

      Initially was doing same but dk why i sorted both in increasing order lol..XD

    • »
      »
      »
      5 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      Could you please provide an example of this?

      • »
        »
        »
        »
        5 месяцев назад, скрыть # ^ |
        Rev. 2  
        Проголосовать: нравится +6 Проголосовать: не нравится

        First for the root logic. We're looking for a pair, (x, y) that fits the condition (x/y) = q[i] and (x%y) = r[i] and max(x, y) <= k.

        Since our max (x, y) needs to be <= k, what is the smallest x and y that can meet these conditions?

        well y must be greater than the remainder, and x will always be equal to y * q[i], so we want y to be as small as possible. So lets set y = r[i] + 1.

        Now the greedy portion:

        low remainders as well as low quotients are obviously more "valuable" because it makes it easier to satisfy the condition max(x, y) <= k.

        Each quotient or remainder can only contribute a maximum of 1 to the overall score, so it makes the most sense to pair the each quotient with the (LEAST valuable aka largest) remainder that still satisfies the condition so you can save the more valuable remainders for the higher quotients.

        lets say we have k = 11 and we have q = [1, 5] and r = [1, 5].

        f = smallest such y that meets conditions y/x, y/x = q and y % x = r

        f(q[0], r[0]) = 3 f(q[1], r[1]) = 35

        f(q[0], r[1]) = 11 f(q[1], r[0]) = 11

    • »
      »
      »
      5 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      ohhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh

    • »
      »
      »
      5 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      thank you so much

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +31 Проголосовать: не нравится

Did I over complicate or was D such a pain to implement .

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

351059087 what i am doing wrong in this..I think problem is in 2nd while loop

»
5 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

I feel like the description of the problem B is somehow incomplete. There can be some tests where the solution doesn't exist.What about the test case as n = 5, b[n] = 0 0 1 1 1? Here we can't perform the exact n operations!

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +59 Проголосовать: не нравится

possibly the worst problem D of any div2 round

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +56 Проголосовать: не нравится

how exactly was D accepted in a modern cf round? my hatred for it is especially strong since it resulted in me getting an rte on my last-minute submission for F due to a lack of time

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

How am I able to submit a hack if I can't view the code, when every submissions that I clicked in (even my own) display as "N/A"? Does anyone have the same issue like me? Please help me with this issue, I have had this issue for the last two weeks.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone please explain to me how to solve B ?

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Can someone please explain to me how to solve problem B?

  • »
    »
    5 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    Thinking about how to include more elements in a single operation. This value is equal to the smaller of the number of non-zero elements in the array and the sum of the array minus (n-1) (ensuring that there are numbers left to add in the remaining n-1 operations).

  • »
    »
    5 месяцев назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    We can easily do it using binary search. We first count all the non zero elements of array B. Let's term this value nz. This way we know our answer x will always be 1 <= x <= nz. Now we simply binary search on the value of x.

    For any "mid" which is a candidate answer of x:

    sum(b[1...n]) — mid >= n — 1 should always be satisfied. Why? This is because if x is a genuine candidate answer, then there should at least be 1 operation of length x hence we see if the remaining difference is greater than n — 1. Because is no way we can increase the sum less than n — 1 in exactly n — 1 operations. 351013821

    • »
      »
      »
      5 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      if u dont mind can u paste here

      • »
        »
        »
        »
        5 месяцев назад, скрыть # ^ |
         
        Проголосовать: нравится 0 Проголосовать: не нравится
        #include <bits/stdc++.h>
        #include <iostream>
        #include <set>
        #include <map>
        using namespace std;
        typedef long long ll;
        typedef long double ld;
        typedef vector<long long> vll;
        typedef pair<ll , ll> pll;
        typedef vector<int> vi;
        typedef vector<string> vs;
        typedef vector<pair<long long, long long>> vpll;
        #define all(v) v.begin(), v.end()
        #define sz(x) ((int)(x).size())
        #define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());}
        void show(vll &a) {for(auto it : a) cout<<it<<" "; cout<<endl;}
        void show(vector<vll> &a){for(int i = 0; i < a.size(); i++) show(a[i]); cout << endl;}
        
        // Header files, namespaces,
        // macros as defined above
        #include <ext/pb_ds/assoc_container.hpp>
        #include <ext/pb_ds/tree_policy.hpp>
        using namespace __gnu_pbds;
        
        #define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
        
        void solve(int tc){
            ll n;
            cin >> n;
            vll arr(n);
            for(int i = 0; i < n ; i++) cin >> arr[i];
        
            sort(all(arr));
            ll sm = 0, nz = 0;
            for(int i = 0; i < n ; i++){
                sm += arr[i];
                if(arr[i] > 0) nz++;
            }
            ll s = 1, e = nz, ans = 0;
            while(s <= e){
                ll mid = s + (e - s)/2;
                bool isPossible = sm - mid >= n - 1;
                if(isPossible){
                    s = mid + 1;
                    ans = mid;
                } else{
                    e = mid - 1;
                }
            }
            cout << ans << endl;
        }
        
        int main(){
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
            int t = 1;
            cin >> t;
            for(int i = 1; i <= t ; i++){
                solve(t);
            }
            return 0;
        }
        
    • »
      »
      »
      5 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      what is wrong in this:

      #include <bits/stdc++.h>
      using namespace std;
      #define endl '\n'
      #define all(x) (x).begin(), (x).end()
      #define sz(x) (int)(x).size()
      #define pb push_back
      #define S second
      #define F first
      #define RAND(l, r) ([&](){ static std::mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count()); return std::uniform_int_distribution<int>(l, r)(rng); })()
      using ll = long long; 
      const long long INF = 0x3f3f3f3f3f3f3f3f;
      const ll MOD =  998244353; 
      ll modpow(ll a, ll b) {
          ll res = 1;
          while (b > 0) {
              if (b & 1) res = res * a % MOD;
              a = a * a % MOD;
              b >>= 1;
          }
          return res;
      }
      void solve() {
          int N; cin >> N; 
          vector<int>A(N);
          int Sum = 0;
          int zeros =0;
          for (int i = 0; i < N; i++) {
              cin >> A[i];
              Sum += A[i];
              zeros += A[i] == 0;
          }
          int ans = 1;
          for (int i = 1; i <= N - zeros; i++) {
              if (Sum - i >= N - 1) ans = max(ans, i);
          }
          cout << ans << endl;
      }
      int main() {
          ios::sync_with_stdio(false); 
          cin.tie(nullptr);
          cout.tie(nullptr);
          // freopen("workspace/input.txt", "r", stdin);
          bool tc=1;
          int t;
          if (tc)cin>>t;
          else t=1;
          while (t--){
          solve();
          }
          return 0;
      }
      
  • »
    »
    5 месяцев назад, скрыть # ^ |
    Rev. 3  
    Проголосовать: нравится 0 Проголосовать: не нравится

    if sum of all elements == n then ans is 1; else we have to check, How many positions we can fill in one operation with non-zero elements. (as we can form a from b by shifting also)

  • »
    »
    5 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    The "dumb" solution would be: * sort the b ascending * start filling the a greedily — go through the b and choose l/r for every element, like this: l=i, r=n, for every i-th element record b[i] pairs * note the 1st such recorded pair is the longest one * the above is the greedy filling, which may end up in less then n rounds, lets say we have extra unused rounds (extra = n — number of pairs) and we need to distribute them somehow * now going in the pairs array in reverse, reduce the length of the pair to 1, deducting the reduced length from extra * once extra == 0, the 1st pair is the longest one

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +51 Проголосовать: не нравится

C was a nice problem. But D kinda ruined the experience 😭😭

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится -9 Проголосовать: не нравится

WHY ISNT PROBLEM D THE LAST ONE TS WASTED LIKE 99% OF MY TIME ON THIS CONTEST >:(((

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +21 Проголосовать: не нравится

The plague of heavy implementation has infected Educational Codeforces Rounds. Let's see who will be the next victim.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится -7 Проголосовать: не нравится

Way too many solves for C. Too many cheaters in the contest.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +5 Проголосовать: не нравится

btw, I very love D, for less guessing than other div2D and some transition between states (... but currently I'm not yet submitted)

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

My name starts with D, today D is sad because D is bad

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

couldn't solve D, but struggled with C also ... is there some simple solution for C

  • »
    »
    5 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    C is pretty standard binary search on answer. For x = q*y + r, we know that y > r. Also, if some no. of removals is possible then less no. of removals than that is always possible, so the partition point can be binary searched.

    If we sort both q and r arrays, then it's obvious that taking a small prefix of both is good because smaller values of q and r will ensure that x and y remain <= k. Additionally, for each choice of r, we can take y = r + 1, as that will result in smallest possible values of x and y. If we were to test for an answer take, then we take take length prefixes of q and r arrays (after sorting) and pair them in reverse so that i-th largest r matches up with i-th smallest q. This minimizes the x value.

    You can check my impl: 351181458

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

What a ride till problem C !

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

D is hardest :(((((

I think the solution of D is if — then until die....

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

how to solve E?

  • »
    »
    5 месяцев назад, скрыть # ^ |
    Rev. 5  
    Проголосовать: нравится +7 Проголосовать: не нравится

    First, you can observe that a string is beautiful if it consists of more than one block. Because if it contains an even number of blocks (>= 2) you can remove either the first or last block, and if it contains an odd number of blocks(>= 3), you can remove one of the middle blocks, then 2 blocks of the same color would merge and you would decrease the number of blocks by 2, it doesn't work if you only have one block because the string will become empty which is not beautiful.

    After that the problem just becomes find the number of binary strings such that none of the given ranges is contained inside one block (i.e. have only 1 type of bit), You can solve it using dp, specifically you can think of the state as the position you are currently in, and the transition is adding a block, while making sure you that no given range is contained inside one block.

    so dp[len] = number of binary strings of length n satisfying above condition, you can reach it from dp[len-1], dp[len-2] ... dp[0]. but you need to exclude cases where the block you will be adding will violate the conditions. so you maintain the maximum L for all ranges such that R <= len, and you can only now transition from dp[len-1], dp[len-2], ... dp[maxL]. Because if you transition from any states before that you will violate one of the conditions (the block added will contain one of the ranges).

    To do these transitions quickly you can use prefix sums. Refer to this submission for more details.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +29 Проголосовать: не нравится

weak pretests on edu round :(

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

is there something wrong with the b tests/input constraints? there are so many solutions getting hacked for wa

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +72 Проголосовать: не нравится

Very nice ABCEF, But one bad problem can ruin the contest. D is so disgusting.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +112 Проголосовать: не нравится

The author after putting problem $$$D$$$ in the contest

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +17 Проголосовать: не нравится

bad gap between C and D

»
5 месяцев назад, скрыть # |
Rev. 3  
Проголосовать: нравится 0 Проголосовать: не нравится

Problem D was a pretty cooked problem tho :|, with less solves than E

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Is the test in the contest an official test?

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Is the test in the contest an official test?

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

is there any approach with xor basis on F?

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

C was amazing

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

What is the idea for D? I tried splitting it up into ?X/V, I?, ??, and ? and going from there, but this doesn't work.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Why there wasn't overflow test in task B? I got hacked :-(

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится -29 Проголосовать: не нравится

Why were the tests so weak got my solution hacked due to integer overflow bad contest.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится -17 Проголосовать: не нравится

D is INCREDIBLE good problem, I LOVE IT SO MUCH

  • »
    »
    5 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится

    What is the solution idea for it?

    • »
      »
      »
      5 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится +3 Проголосовать: не нравится

      put as many IV or IX as u can

      • »
        »
        »
        »
        5 месяцев назад, скрыть # ^ |
         
        Проголосовать: нравится +3 Проголосовать: не нравится

        Thanks for the reply, Nyemot. I tried to do that, but I couldn't figure out how to precompute all the necessary details for the code to run in time. Can you please help me understand how to do this?

        • »
          »
          »
          »
          »
          5 месяцев назад, скрыть # ^ |
           
          Проголосовать: нравится +4 Проголосовать: не нравится

          I submitted this verbose version of my solution after contest 351091920
          It might be hard to read here, maybe copy it to your IDE.
          Tell me what you think, also if you still don't understand some things, feel free to ask again.

          Code
        • »
          »
          »
          »
          »
          5 месяцев назад, скрыть # ^ |
          Rev. 2  
          Проголосовать: нравится +1 Проголосовать: не нравится

          Let Z be some large value (X or V). We know that intuitively, we want to use as many I's as possible, and use V's and then X's iff necessary.

          In solving the problem, one of the first observations I made was that we can break the input string down into blocks of ?s; this problem can probably be solved with a different, simpler approach, but let's go with this for now. Following this, we can store the size of each block, along with a boolean/integer flag for whether the determined character to the immediate left of the block is I (called aL) and whether the determined character to the immediate right of the block is Z (called aR). This is the only information about the surroundings of each block we need.

          For example, with the string "X????V", our block would be of size 4 with aL = 0 and aR = 1.

          Now, we want to compute the amount of pairs of IZ that we can possibly make in some block, and we will find this given the amount of Is we will put into it (called k); let's call this function f(block,k). We know that, ignoring aL and aR, our formula is trivially f(block,k)=min(k, block.size-k) because the # of IZ pairs is limited by both I and Z. Now, if we only have aL=true and aR=false, we can set the first ? in our block to Z, so we have min(k+1, size-k) IZ pairs, and vice versa for if we only have aR. Therefore, our comprehensive f is f(block,k) = min(k + block.aL, (block.size-k) + block.aR).

          So, to recap, we now know the amount of IZ pairs we can get in each block. All we have to do now is maximize the amount of IZ pairs we can make globally while using all of our available Is. So now, let K be the amount of Is we are allowed to use (per query). Effectively, we want to distribute this K into multiple smaller ks that we can give to each block. In order to do this, we can observe that f is always concave, with a slope of 1, 0, or -1. So, let's define d(k) as f(k)-f(k-1) (essentially slope), observing that it is non decreasing for increasing k. We can now state that f(k) = f(0) + sum(d(t) for t=1...k)), and that f_all(j) = sum(f(0) for all blocks) + sum(sum(d(t) for t=1...j_i)) for all blocks), where f_all is the global amount of IV pairs given some array j with j_i for all blocks (j sums to K; here, j can be thought of as a 'config' for f_all).

          Given this, and seeing the first part of f_all, our initial intuitive step can be to simply store the sum of all f(0) for all blocks in a single variable to use for each query; let's call that F0. Next, we also know that, intuitively (for the lack of a better explanation), d(k) is the "potential" for f at some point k, in that it shows whether f still has more "room" for IZ pairs (d(k)=1) or not (d(k)<1), and we also know it holds a numerically equivalent relationship with how many IZ pairs we actually make. So, we can essentially combine all multisets d into one large multiset D, which stores these deltas/slopes for all blocks. Sorting this descending, we find how many IZ pairs we will make using an optimal strategy is D(x) for x=1...K given some K from the query. To make this O(1) per query, we can just store a prefix sum pref for D, and so our total amount of IZ pairs given K is always F0 + pref[k].

          So, overall, we now have the total amount of IZ pairs we will make in our blocks. We can trivially compute the contributions from the predetermined characters before processing queries, and then add the contribution from our ? blocks following our greedy strategy to maximize the # of Is we use, then Vs, and then Xs to obtain our final result.

          Submission: 351062521

  • »
    »
    5 месяцев назад, скрыть # ^ |
    Rev. 2  
    Проголосовать: нравится 0 Проголосовать: не нравится

    I agree.

    It was kinda mess and i was lucky for sure to not spend hours debuging it.

    But i dont mind implementation-hell problems. If its like 1 in a month or so. I was much happier from it passing then usual.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

Was D just heavy casework?

e.g. ?V, ?X, ?, ??, etc?

  • »
    »
    5 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    The solution for D was not too hard to think of but it was just a bit of caseworkey problem. My approach was kinda nice.

    Spoiler
»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится -15 Проголосовать: не нравится

I appreciate the announcement. I'm looking forward to the round; the extended ICPC format should make it interesting, and the problemsetter lineup appears solid , Gl everyone !

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

It's always just integer overflow... why...

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

D is cancer

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится -14 Проголосовать: не нравится

Hello, I received the similarity warning for my solution in this round. I did not share my code with anyone and did not copy from anyone. It is possible that I once used an online IDE that unintentionally made my code public. I understand this is against the rules even if unintentional, and I sincerely apologize. I will make sure this never happens again. Thank you for checking.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Problem D

Greedy approach: 1) replace all "?" with "I" and compute the score. 2) replace question mark "I" with "V" for those scores that change by +2, +4, +6 respectively (three loops) and save all the results. 3) finally answer the queries with the precomputed scores, adjusting by cx * 5 since we worked with "V"s

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +31 Проголосовать: не нравится

Recently, your account was used to crawl. Please change your password to prevent your account from being used for unauthorized activities.

I don't know if this issue is common or not. But this is the first time I've come across this message on Codeforces, and it's already pissed me off. Manually viewing 4-6 submissions per minute is not even close to crawling, come on. This behavior makes a full-fledged hacking phase impossible. I hope that the administrators will eventually be able to adjust the upper activity limits to an adequate level.

  • »
    »
    5 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится 0 Проголосовать: не нравится

    I'm getting the same issue. How do you make it go away? Are we just not allowed to look at like 6-7 solutions per minute or something?

    • »
      »
      »
      5 месяцев назад, скрыть # ^ |
       
      Проголосовать: нравится 0 Проголосовать: не нравится

      I didn't do anything specific to make it disappear. The first time I got this message, it lasted for more than an hour. I tried changing my password but it didn't lift that warning, it eventually vanished itself. The second time, about half an hour without any actions from me. But the third time, it had lasted for at least 3.5 hours which made me write the original comment. Also, after each attempt of opening any solution (including my own solutions!), it logged me off with a message You are temporarily blocked by the administrators. As if the administrators tracked me down and manually blocked me for me daring to open 6 submissions per minute.

      The worst thing about that message is that it doesn't explain its criteria and reasoning (Codeforces, what kind of authority are you to restrict human users from browsing solutions?), and it doesn't tell you how long you have to wait and how you can appeal this decision. This is very annoying, to say the least.

      Alright, forget about hacking phases. Imagine an even simpler yet more important case. Will a coach be blocked for opening a dozen of their students' solutions at a time? Sometimes it is more convenient to browse them en mass. I would be glad to receive any kind of comment from MikeMirzayanov on that case and on the whole situation in general.

      P.S. I never understood why people had alternative accounts on Codeforces. Although I'm not planning to use alts any time soon or later, I won't be surprised if someone turns out to be using alts just because of such a situation.

»
5 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится -18 Проголосовать: не нравится

I'm very happy to take 2nd place after virtualing this round!

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hi all

A newbie here. I registered for this one as a rated contest and managed to solve 2 :P but it's showing as unrated contest in my profile with no rating update. Could someone please let me know why could that be?

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +16 Проголосовать: не нравится

LLMs are ruining Codeforces. It's hard to believe that in an educational round, over 200 users managed to solve six problems. Just a few hours ago, the proportion of pupils and newbies among the top contestants was even larger than that of grandmasters. Although the situation has improved somewhat after the administrators issued bans, a significant number of low-rated users on the leaderboard are still pulling off the "feat" of solving all problems in just 30 minutes. If this continues, Codeforces' rating system will likely collapse.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

I hope the cheaters get banned

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

Very weak pretests :(

»
5 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Last time problem A has a weak preset and this time problem B has a weak preset... I don't dare to participate in educational rounds because of the massive hack on a problem

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hello, I received a “solution coincidence” warning for my submission to Problem 2170D in Educational Codeforces Round 185 (Rated for Div. 2).

My submission ID was 351040087.

I want to clarify that I wrote the solution independently and did not copy from anyone. I also did not share my code. The similarity might be due to standard logic or common approach used for this problem.

I kindly request the coordinators to review my case. Thank you.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

why does it get so much downvote

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

why did this blog get so many downvotes? can someone explain the reason?

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hello, I received a plagiarism warning for problem 2170C. I did not copy from anyone, and I did not share my code with anyone. Any similarity is purely coincidental because I solved the problem myself during the contest. Please review my case. Thank you.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

the test in problem B very weak T_T

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

okay so got this comment saying one of my solutions matched with xyz and all, not sure how that happaned, but i will make sure it wont happen again

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

my ratings are not yet updated even after the hacking phase

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

wtf with the pretest of B? Is it because there’s a hack phase that they don’t care about constructing the pretest at all?

  • »
    »
    5 месяцев назад, скрыть # ^ |
     
    Проголосовать: нравится +3 Проголосовать: не нравится

    I think the main reason for that is this: You generally want small numbers for interesating test cases in this problem. You want to aim for sum < n.

    And there is even a second problem: The most naive "overfloat check" where n=200000 and every b_i=n does not even fail (at leas on some hacked solutions). Because it actually overfloats back to positive and you just need the sum >= n, not the exact value of n.

    Also, being hacked is a learning experience. Yes, weak tests are bad. But now you know how to solve it better next time.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

why do some dislike the rounds they don’t perform well in?

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Pure math roll out of XCPC!

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

nice pretest for problem B

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +4 Проголосовать: не нравится

Terrible testcase for B. Getting hacked just because I didn’t use long long feels bad. If it hadn’t been accepted, I would have figured it out during the contest.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Six seveeeen

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

weak test may lead to many successful hack.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Why round is unrated? I hope that it is a bug.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

My answers have been skipped i don't know how it has been same to some other person I don't even know him/her. It's entirely unnecessary, please check its entirely coincidence, answer of question A has been matched which is very unlikely. I am sure you will do due diligence and my answers won't be skipped.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Why does the problem explanation for Question D describe a problem that is quite different from the original one, and the code also seems unable to pass

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Hello. I received a plagiarism warning for submission 351056694. I would like to clarify that I solved the problem independently and I do not know the other users whose solutions were mentioned. I did not share my code anywhere, and I did not use any public compilers or platforms.

It is possible that the similarity occurred coincidentally, especially since many participants may arrive at similar dynamic programming implementations for this problem.

Please review the situation again. Thank you.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Did they just solve a less awful version of D in the editorial ? That version of D looks much better than this one.

»
5 месяцев назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

weak pretests again :D

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +6 Проголосовать: не нравится

I mention one thing, last contests are starting like this anymore, idk why A- Easy B- Medium C- Easy D- Expert E- Hard F- Medium suprising us all as usual

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Actually my fault, but B is accepted during the round without long long :(

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

B weak pretest let me remain be newbie :(

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

i like apples and bananas

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

do u get ur rating?

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +8 Проголосовать: не нравится

several months into codeforces but waiting for rating update feels the same everytime

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

it seems this contest all unrated, but why?

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

I haven’t received my rating.

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +3 Проголосовать: не нравится

SIX SEVEN!

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

Thanks for this round, it was good

»
5 месяцев назад, скрыть # |
Rev. 17  
Проголосовать: нравится 0 Проголосовать: не нравится

What the heck is wrong with the tag for problem A?

»
5 месяцев назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Here is my screencast:

https://youtu.be/YtJoNIC6lG4

»
3 месяца назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится

My Handel Name is VSS402002_Muhammad_Adil"I have been flagged for problem 2185E, but I want to clarify that I wrote the code independently. I did not copy or share my solution. The similarity might be due to using a standard logic/template or a common implementation of the algorithm. Please review my submission (358521009) fairly."

»
3 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Hello

»
3 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

AOA

»
3 месяца назад, скрыть # |
Rev. 2  
Проголосовать: нравится 0 Проголосовать: не нравится

Hello