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

Автор Xiaohuba, 6 месяцев назад, По-английски

A Sequence Game

Idea from cmk666, Prepared by cmk666

Hint 1
Tutorial

B Even Modulo Pair

Idea from 244mhq, Prepared by NetSpeed1

Hint 1
Tutorial

C Dungeon

Idea from Link_Cut_qwq, Prepared by Xiaohuba

Hint 1
Hint 2
Hint 3
Tutorial

D Copy String

Idea from JoesSR, Prepared by JoesSR

Tutorial

E Journey

Idea from Link_Cut_qwq, Prepared by Xiaohuba

Hint 1
Hint 2
Hint 3
Tutorial

F1/F2 Chain Prefix Rank

Idea from JoesSR, Prepared by JoesSR

Tutorial

G Pointless Machine

Idea from Daniel777, Prepared by zjy2008

Hint 1
Hint 2
Hint 3
Tutorial

H PalindromePalindrome

Idea from zjy2008, Prepared by zjy2008

UPD: Unfortunately, the original analysis regarding the number of "relevant" pairs of disjoint substrings was incorrect. The proof was derived from an online blog concerning the range distinct palindrome substring query problem, but that proof turned out to be flawed. Consequently, we previously believed the complexity of the standard solution to be $$$O((n + q) \log n)$$$; however, after the contest, we discovered that it is actually $$$\Theta(n \log^2 n + q \log n)$$$ (and this lower bound is reachable). We apologize for any confusion caused.

Hint 1
Tutorial

Полный текст и комментарии »

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

Автор Xiaohuba, 6 месяцев назад, По-английски

Hello, Codeforces!

We are pleased to announce the resumption of the Global Rounds. Thanks to XTX Markets for supporting the initiative! In 2025, we will hold 3 such rounds. The series results will take into account the best 2 participations out of 3.

On Nov/06/2025 17:35 (Moscow time) we will host Codeforces Global Round 30 (Div. 1 + Div. 2).

Codeforces Global Round 30 marks the second round in the 2025 series of Codeforces Global Rounds. These rounds are open and rated for everyone.

The prizes for this round are as follows:

  • The top 30 participants will receive a t-shirt.
  • 20 t-shirts will be randomly distributed among participants ranked between 31 and 500, inclusive.

The prizes for the 3-round series in 2025:

  • In each round, the top-100 participants get points according to the table.
  • A participant's final score will be the sum of the points they earned in their 2 highest-placing rounds.
  • The top 20 participants across the series will receive sweatshirts and placement certificates.

We extend our gratitude to XTX Markets for supporting the global rounds initiative in 2025!

The 8 problems were authored and prepared by our 8 authors: 244mhq, cmk666, Daniel777, JoesSR, Link_Cut_qwq, NetSpeed1, zjy2008 and me. There is at least one interactive problem, so I strongly urge you to read the guide if you are unfamiliar with the format.

We would also like to thank:

Round Information:

  • Duration: 180 minutes.
  • Number of problems: 8 problems with 1 subtask.
  • Score distribution: 500 + 750 + 1500 + 1750 + 2250 + (2500 + 1500) + 3500 + 5500

GL & HF!

UPD:

Congrats to the winners!

  1. Otomachi_Una
  2. Kevin114514
  3. dXqwq
  4. ksun48
  5. VivaciousAubergine
  6. qiuzx
  7. strapple
  8. hos.lyric
  9. Radewoosh
  10. StarSilk
  11. tourist
  12. maroonrk
  13. potato167
  14. Nachia
  15. BurnedChicken

First Solves:

A: Away_in_the_heavens
B: ksun48
C: Depressed_sad_boy
D: ksun48
E: Kevin114514
F1: Otomachi_Una
F2: Otomachi_Una
G: qiuzx
H: rainboy

UPD2.

Editorial

Полный текст и комментарии »

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

Автор Xiaohuba, история, 19 месяцев назад, По-английски

UPD: I've reduced the code size.

I've recently found that the following code will generate wrong output.

#include <bitset>
#include <iostream>
const int N = 105;
std::bitset<N> ok[N][N];
int n = 5;
int main() {
  ok[2][2].set(2);
  for (int i = n; i; i--)
    for (int j = i; j <= n; j++) {
      ok[i][j] = ok[i][j] | ok[i + 1][j] | ok[i][j - 1];
    }
  std::cout << ok[2][5][2] << '\n';
  return 0;
}

Compiled with -O3 -mtune=skylake -march=skylake, the code outputs 0.

However if you simulate the code you will know that the correct answer should be 1.

Note that the compiler seems to generate wrong sse instruction.

Godbolt link

Again, I believe this code is ub-free, and has nothing to do with implementation-defined stuff.

Полный текст и комментарии »

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

Автор Xiaohuba, история, 20 месяцев назад, По-английски

UPD: It is a compiler bug, and is resolved since gcc 12.3. Further information is on https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116459.

[Apologize for my poor English.]

The code at https://godbolt.org/z/PP1TTdhxf outputs 1. However, if you simulate the code, the answer is obviously 20.

Further exploration showed that the compiler compiled function qpw, but did not call it. Uncomment line 22 solves the issue, surprisingly. Further more, the bug seems to only occur on gcc12.1 and gcc12.2, with -O2 enabled.

I believe the code does not contain any undefined / unspecified behavior.

Полный текст и комментарии »

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

Автор Xiaohuba, 2 года назад, По-английски

Today is December 30th in Chinese Lunar Calendar (a.k.a Chinese New Year Eve).

We will enter the Year of Dragon in a few hours. Quite different from western culture, dragon (which sounds like "loong 龙" in Chinese), is an animal that symbolizes power, wisdom and strength.

The CF community has been passing through a hard time. We've experienced an explosive Goodbye 2023 Round, and there are more contentious topics. But anyway, we hope we will come into a entirely new, wonderful Chinese New Year! Hope that Codeforces will be a platform purely for competitive programming, where contests of good quality are held frequently, and people around the world are able to discuss academic problems freely.

Let's wait for the moment that the Year of Dragon comes!

UPD: The Year of Dragon has arrived. Happy Chinese New Year!

Полный текст и комментарии »

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

Автор Xiaohuba, история, 3 года назад, По-английски

These days I'm trying to compile the following c++ code:

#include<vector>

const int MAXN=1e5+5;
std::vector<int> factor[MAXN];

signed main() {return 0;}

This code works while I'm using g++ 11.3.0. However, if I use g++ 13.1.0 or 12.1.0, I'll receive a compile error:

/var/folders/v7/yk8tz4j54cl2lhp1f80nyz700000gn/T//cc2HpyzP.s:371:29: error: unexpected token in '.section' directive
        .section .data.rel.ro.local

Reinstalling the compiler doesn't works. What should I do?

Note I use Apple M1 with MacOS 13.2.1 (22D68).

Полный текст и комментарии »

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