Skip to content

Fix #212: draw problem 69's query pairs from a secret per-test seed - #213

Closed
XiaoyuanWang111 wants to merge 1 commit into
FrontierCS:mainfrom
XiaoyuanWang111:fix-69-secret-query-pairs
Closed

XiaoyuanWang111 wants to merge 1 commit into
FrontierCS:mainfrom
XiaoyuanWang111:fix-69-secret-query-pairs

Conversation

@XiaoyuanWang111

Copy link
Copy Markdown

Summary

Please read CONTRIBUTING.md before submitting.

Fixes #212.

The statement of problem 69 says the pair (u, v) of each round is chosen independently and uniformly at random. The interactor computed it from the round number (u = j % n + 1, v = (37 * j + 13) % n + 1), the same on every test, so the program in the issue was accepted on all 10 tests at 67.29 points without reading a power.

  • Each testdata/N.ans now holds a distinct secret 63-bit seed on a second line, drawn with Python's secrets.randbits(63). The first line is unchanged.
  • The interactor reads the seed and draws the q pairs from std::mt19937_64(seed) before it reads any word. A rejection loop keeps each index exactly uniform on [1, n]. A missing seed is a judge failure (_fail). Problem 59 gets its hidden array from a seed in the answer file in the same way (Fix #208: draw problem 59's hidden array from a secret per-test seed #211).
  • The wrong-answer messages no longer print the pair that was asked, since that pair is now secret.

The statement, the scoring formula and the protocol are unchanged, and a test still asks the same pairs on every run. Like the seeds of problem 59, these seeds are public in this repository; the fix removes the answer that needs no outside data.

Type of Change

  • New research problem
  • New algorithmic problem
  • New Frontier-CS 2.0 problem
  • Bug fix
  • Documentation update
  • Other:

Testing

With g++ 13.3 (-O2 -std=gnu++17):

  • algorithmic/tests/test_problem69.py: all 27 tests pass. On main all 27 fail: the 10 that replay the old pairs fail because the transcript is accepted at Ratio 0.6729, and the other 17 because main has no seed.
  • The same counts with g++ 11.4 in Ubuntu 22.04, the base image and compiler of the judge. With either compiler python -m pytest algorithmic/tests gives 244 passed and no failure; the 4 errors in test_problem36_239.py occur on main as well, because that file reads commit 65117c99, which is not in the public repository.
  • The program from the issue, run as an interactive submission: accepted on all 10 tests on main (mean 67.29), 0 on every test with the fix.
  • The 10 pair sequences are the same when built with MSVC 19.44: they match the hashes pinned in the test file.
  • The 45 archived solutions in algorithmic/solutions/69, each played on tests 1, 5 and 10 against the interactor before and after: every one gets the same score on every test. Five of them score above zero (gpt5.2.cpp and three of its variants at 30.4 to 30.8, gpt5_high.cpp at 19.1 to 19.3); the other 40 score 0 with both.

The validate-algorithmic check will fail here: scripts/validate_problems.py reports a missing reference solution, because problem 69 has no reference.cpp. The same check failed on #206, #210 and #211, which also changed problems without one.

Checklist

  • Code follows the project structure and conventions
  • Self-review completed
  • Documentation updated (if applicable)

CI Validation (for new problems)

When adding new problems, CI will automatically validate that your reference solution achieves score > 0.

  • Algorithmic problems: Include reference.cpp in your problem directory
  • Research problems: Include reference.py (or reference.cpp if language: cpp in config.yaml)
  • 2.0 problems: Include reference.py unless the problem config declares another language

The statement says the pair (u, v) of each round is chosen independently
and uniformly at random. The interactor computed it from the round number
instead: u = j % n + 1, v = (37 * j + 13) % n + 1, the same on every test.
A program that prints the n shortest words and then these pairs, without
reading a single power, was accepted on all 10 tests at 67.29 points,
above the 60-point reference.

Each testdata/N.ans now holds a distinct secret 63-bit seed on a second
line, drawn with Python's secrets.randbits(63). The interactor reads it
and draws the q pairs from std::mt19937_64(seed) before it reads any
word. A rejection loop keeps each index exactly uniform on [1, n]. A
missing seed is a judge failure (_fail). Problem 59 gets its hidden array
from a seed in the answer file in the same way.

The wrong-answer messages no longer print the pair that was asked, since
that pair is now secret.

algorithmic/tests/test_problem69.py checks that the old replay is
rejected on every test, that the seeded pairs are the ones asked and are
accepted with the unchanged score formula, that the pair sequences are
pinned, and that a missing seed fails.
@whuang369

Copy link
Copy Markdown
Contributor

Thanks for finding the issue and the thorough patch! This was fixed in #214, which was merged on Nov 20 and closed #212. It takes the same approach: a secret seed in each .ans file, and pairs drawn from mt19937_64 before any word is read. So I think this PR can be closed. Sorry for the overlap!

@XiaoyuanWang111

Copy link
Copy Markdown
Author

Thanks, and no worries! Closing in favor of #214.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Problem 69 interactor: each round's pair is a fixed function of the round number, so a program that ignores every power scores 67

2 participants