QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#20951. جلسة تصوير

Statistics

يصطف لدى Farmer John عدد $N$ من الأبقار ($2\le N\le 10^3$)، مرقمة $1\ldots N$، لجلسة تصوير. خطط FJ أن تكون البقرة رقم $i$ من اليسار هي ذات الرقم $a_i,$، وكتب التبديل $a_1,a_2,\ldots,a_N$ على ورقة. للأسف سرق Farmer Nhoj الورقة مؤخرًا!

لحسن الحظ، ربما يستطيع FJ استعادة التبديل الذي كتبه. قبل السرقة سجلت Bessie المتتالية $b_1,b_2,\ldots,b_{N-1}$ التي تحقق $b_i=a_i+a_{i+1}$ لكل $1\le i<N.$

بناء على معلومات Bessie، ساعد FJ في استعادة التبديل $a$ «الأصغر معجميًا» الذي قد ينتج $b$. يكون التبديل $x$ أصغر معجميًا من $y$ إذا وجد $j$ بحيث $x_i=y_i$ لكل $i<j$ و$x_j<y_j$ (أي يتطابقان حتى موضع معين، حيث يكون $x$ أصغر من $y$). وجود تبديل $a$ واحد على الأقل مضمون.

الإدخال

يحتوي السطر الأول على عدد صحيح واحد $N.$

يحتوي الثاني على $N-1$ أعداد صحيحة $b_1,b_2,\ldots,b_{N-1}.$ مفصولة بمسافات.

الإخراج

سطر واحد فيه $N$ أعداد صحيحة $a_1,a_2,\ldots,a_{N}.$ مفصولة بمسافات.

أمثلة

الإدخال 1

5
4 6 7 6

الإخراج 1

3 1 5 2 4

ملاحظة

ينتج $a$ المتتالية $b$ لأن $3+1=4$ و$1+5=6$ و$5+2=7$ و$2+4=6.$

المهام الفرعية

  • تحقق حالات الاختبار $2$–$4$ الشرط $N\le 8.$

  • لا توجد قيود إضافية لحالات الاختبار $5$–$10$.

مؤلفا المسألة: Benjamin Qi وChris Zhang

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.