Shayan's blog

By Shayan, 27 hours ago, In English

Note: The text editorials will be provided by the authors of the round. This video tutorial acts as an additional resource for those who prefer video over text, and not as a substitute for the text editorial.

2004A — Closest Point

Video

2004B — Game with Doors

Video

2004C — Splitting Items

Video

2004D — Colored Portals

Video

2004E — Not a Nim Problem

Video

2004F — Make a Palindrome

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

»
26 hours ago, # |
  Vote: I like it +3 Vote: I do not like it

BRUUUUHHHHHHH I didn't notice the change in B until after the contest :( such BS

»
25 hours ago, # |
  Vote: I like it +3 Vote: I do not like it

Will a tutorial on problem G appear?

»
18 hours ago, # |
  Vote: I like it +48 Vote: I do not like it

Are there written solutions for the problems? My English listening is poor.

»
16 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

When is the text editorial?

»
15 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

WHERE D hacked ? anyone have test case ?

  • »
    »
    13 hours ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    Yes, many people were hacked, including me on tl. I think many people had a problem because of the slow map<string,vector> structure

    • »
      »
      »
      11 hours ago, # ^ |
        Vote: I like it +11 Vote: I do not like it

      I have looked at your code, and the problem is you are doing :

      for(auto z : mapic){
          //do something                    
      }
      

      In this code, z will copy each vector in the map once, so that is why your code is $$$O(nq)$$$, but if you change it to :

      for(auto &z : mapic){
          //do something                    
      }
      

      Then the vector will not be copied as you are only taking a reference to where does it exist.

»
14 hours ago, # |
  Vote: I like it +13 Vote: I do not like it

Is it a tendency, that now we have video editorials instead text one? I don't know, right now, is it better or worse, but definetly text editorials provides faster acsess to solution idea, because reading is faster than watching video. On another hand video edits can be easier to understand, so I personally prefer there both would be

  • »
    »
    8 hours ago, # ^ |
      Vote: I like it +1 Vote: I do not like it

    also text editorials often have hints that are really valuable when you're almost solving the problem

»
12 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

Can we solve D using DSU? If not why

  • »
    »
    10 hours ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    same doubt:(

  • »
    »
    9 hours ago, # ^ |
      Vote: I like it +4 Vote: I do not like it

    If you ONLY want to use DSU, it would have worked if the problem asked to tell whether it is possible to move from some city to other. However the problem asks to find the minimum cost of moving from one city to other, which is not possible to solve ONLY using DSU.

»
11 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

The sub-array of f problem is continuous, so you shouldn't use that much n*(n+1)*(n+2)/6

  • »
    »
    10 hours ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    No, this equation is exactly right

    • »
      »
      »
      9 hours ago, # ^ |
        Vote: I like it 0 Vote: I do not like it

      can you tell me why?

      • »
        »
        »
        »
        9 hours ago, # ^ |
          Vote: I like it 0 Vote: I do not like it

        you can just do a brute force on n=(some number you like) and you'll find that, i do not know how to prove that though.

»
8 hours ago, # |
  Vote: I like it +7 Vote: I do not like it

i prefer text editorials

»
8 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

where G

»
7 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

Is there any text tutorial? :(

»
6 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

Yoo everyone, I was trying to upsolve the problems and I submitted the code for problem D and decided to take a break and now when I came back, it's been over 15 mins but my code is still in the queue, idk wht to do

  • »
    »
    6 hours ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    As of writing this comment, it is processing submissions from 7 hours ago, so I think it's gonna take a while. :)

»
4 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

Can anyone tell me why the first code is getting AC but the second one got hacked and now is showing TLE? Same logic. But in first one im passing from left to right and in second one im passing from right to left.

Thanks!

Code 1

	public static void solve() {
		int n = ii(), k = ii();
		List<Integer> A = new ArrayList<>();
		for(int i = 0; i < n; ++i) {
			A.add(ii());
		}
		Collections.sort(A, (a , b) -> Integer.compare(b, a));
		for(int i = 0; i < n - 1; i += 2) {
			int d = A.get(i) - A.get(i + 1);
			int min = Math.min(k, d);
			A.set(i + 1, A.get(i + 1) + min);
			k -= min;
		}
		long alice = 0, bob = 0;
		for(int i = 0; i < n; ++i) {
			if(i % 2 == 0) alice += A.get(i);
			if(i % 2 != 0) bob += A.get(i);
		}
		System.out.println(alice - bob);
	}

Code 2

	public static void solve() {
		int n = ii(), k = ii();
		int [] A = iir(n);
		Arrays.sort(A);
		for(int i = n - 2; i >= 0; i -= 2) {
			int d = A[i + 1] - A[i];
			int min = Math.min(k, d);
			A[i] += min;
			k -= min;
		}
		long x = 0, alice = 0, bob = 0;
		for(int i = n - 1; i >= 0; --i) {
			if(x % 2 == 0) alice += A[i];
			if(x++ % 2 != 0) bob += A[i];
		}
		System.out.println(alice - bob);
	}
»
3 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

When will ratings get updated??