Submission #51713173


Source Code Expand

/**
 _  _   __  _ _ _  _  _ _
 |a  ||t  ||o    d | |o  |
| __    _| | _ | __|  _ |
| __ |/_  | __  /__\ / _\|

**/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int N_MAX = 1000;

int N;
pair <ll, ll> input[N_MAX + 2];

ll A[N_MAX + 2], B[N_MAX + 2];

vector <pair <ll, ll>> sol;
void do_move (ll x, ll y) {
    sol.push_back(make_pair(x, y));
    for (int i = 1; i <= N; i++) {
        A[i] += x; A[i] %= y;
    }
}

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> input[i].first;
    }
    for (int i = 1; i <= N; i++) {
        cin >> input[i].second;
    }
    sort(input + 1, input + N + 1);
    int cnt = 0;
    for (int i = 1; i <= N; i++) {
        if (cnt == 0 || input[i].first > input[i - 1].first) {
            cnt++;
            A[cnt] = input[i].first; B[cnt] = input[i].second;
        } else {
            if (input[i].second != input[i - 1].second) {
                cout << "No\n";
                return 0;
            }
        }
    }
    N = cnt;
    ll K = 3000000000;
    if (N == 1) {
        cout << "Yes\n";
        if (A[1] == B[1]) {
            cout << 0 << "\n";
        } else if (A[1] < B[1]) {
            cout << 1 << "\n";
            cout << B[1] - A[1] << " " << K << "\n";
        } else {
            cout << 1 << "\n";
            cout << B[1] - A[1] + K << " " << K << "\n";
        }
        return 0;
    }
    B[N + 1] = B[1];
    for (int i = 1; i <= N - 1; i++) {
        ll maxA = A[N - i + 1];
        ll x = B[N - i + 2] - B[N - i + 1] + K - (i == 1 ? A[1] : 0);
        do_move(x, maxA + x);
    }
    do_move(B[2], K);
    cout << "Yes\n";
    cout << (int) sol.size() << "\n";
    for (pair <ll, ll> mv : sol) {
        cout << mv.first << " " << mv.second << "\n";
    }

    return 0;
}

Submission Info

Submission Time
Task C - Add Mod Operations
User atodo
Language C++ 20 (gcc 12.2)
Score 800
Code Size 1943 Byte
Status AC
Exec Time 5 ms
Memory 3708 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 800 / 800
Status
AC × 4
AC × 58
Set Name Test Cases
Sample 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 01_sample_04.txt
All 01_sample_01.txt, 01_sample_02.txt, 01_sample_03.txt, 01_sample_04.txt, 02_small_1_01.txt, 02_small_1_02.txt, 02_small_1_03.txt, 02_small_1_04.txt, 02_small_1_05.txt, 02_small_1_06.txt, 02_small_1_07.txt, 02_small_1_08.txt, 02_small_1_09.txt, 02_small_1_10.txt, 03_small_2_01.txt, 03_small_2_02.txt, 03_small_2_03.txt, 03_small_2_04.txt, 03_small_2_05.txt, 03_small_2_06.txt, 03_small_2_07.txt, 03_small_2_08.txt, 03_small_2_09.txt, 03_small_2_10.txt, 04_rand_1_01.txt, 04_rand_1_02.txt, 04_rand_1_03.txt, 04_rand_1_04.txt, 04_rand_1_05.txt, 05_rand_2_01.txt, 05_rand_2_02.txt, 05_rand_2_03.txt, 05_rand_2_04.txt, 05_rand_2_05.txt, 06_rand_3_01.txt, 06_rand_3_02.txt, 06_rand_3_03.txt, 06_rand_3_04.txt, 06_rand_3_05.txt, 07_rand_4_01.txt, 07_rand_4_02.txt, 07_rand_4_03.txt, 07_rand_4_04.txt, 07_rand_4_05.txt, 07_rand_4_06.txt, 07_rand_4_07.txt, 07_rand_4_08.txt, 07_rand_4_09.txt, 07_rand_4_10.txt, 08_many_same_01.txt, 08_many_same_02.txt, 08_many_same_03.txt, 08_many_same_04.txt, 08_many_same_05.txt, 09_sorted_01.txt, 09_sorted_02.txt, 09_sorted_03.txt, 09_sorted_04.txt
Case Name Status Exec Time Memory
01_sample_01.txt AC 1 ms 3604 KiB
01_sample_02.txt AC 1 ms 3456 KiB
01_sample_03.txt AC 1 ms 3520 KiB
01_sample_04.txt AC 1 ms 3648 KiB
02_small_1_01.txt AC 1 ms 3524 KiB
02_small_1_02.txt AC 1 ms 3644 KiB
02_small_1_03.txt AC 1 ms 3448 KiB
02_small_1_04.txt AC 1 ms 3520 KiB
02_small_1_05.txt AC 1 ms 3520 KiB
02_small_1_06.txt AC 1 ms 3444 KiB
02_small_1_07.txt AC 1 ms 3488 KiB
02_small_1_08.txt AC 1 ms 3448 KiB
02_small_1_09.txt AC 1 ms 3648 KiB
02_small_1_10.txt AC 1 ms 3528 KiB
03_small_2_01.txt AC 1 ms 3648 KiB
03_small_2_02.txt AC 1 ms 3484 KiB
03_small_2_03.txt AC 1 ms 3520 KiB
03_small_2_04.txt AC 1 ms 3396 KiB
03_small_2_05.txt AC 1 ms 3420 KiB
03_small_2_06.txt AC 1 ms 3520 KiB
03_small_2_07.txt AC 1 ms 3420 KiB
03_small_2_08.txt AC 1 ms 3488 KiB
03_small_2_09.txt AC 1 ms 3604 KiB
03_small_2_10.txt AC 1 ms 3460 KiB
04_rand_1_01.txt AC 4 ms 3584 KiB
04_rand_1_02.txt AC 4 ms 3548 KiB
04_rand_1_03.txt AC 4 ms 3508 KiB
04_rand_1_04.txt AC 4 ms 3576 KiB
04_rand_1_05.txt AC 4 ms 3704 KiB
05_rand_2_01.txt AC 1 ms 3532 KiB
05_rand_2_02.txt AC 1 ms 3436 KiB
05_rand_2_03.txt AC 1 ms 3528 KiB
05_rand_2_04.txt AC 1 ms 3540 KiB
05_rand_2_05.txt AC 1 ms 3416 KiB
06_rand_3_01.txt AC 5 ms 3580 KiB
06_rand_3_02.txt AC 4 ms 3456 KiB
06_rand_3_03.txt AC 4 ms 3504 KiB
06_rand_3_04.txt AC 4 ms 3516 KiB
06_rand_3_05.txt AC 4 ms 3516 KiB
07_rand_4_01.txt AC 4 ms 3704 KiB
07_rand_4_02.txt AC 4 ms 3576 KiB
07_rand_4_03.txt AC 4 ms 3564 KiB
07_rand_4_04.txt AC 4 ms 3544 KiB
07_rand_4_05.txt AC 4 ms 3708 KiB
07_rand_4_06.txt AC 4 ms 3584 KiB
07_rand_4_07.txt AC 4 ms 3664 KiB
07_rand_4_08.txt AC 4 ms 3520 KiB
07_rand_4_09.txt AC 4 ms 3580 KiB
07_rand_4_10.txt AC 4 ms 3524 KiB
08_many_same_01.txt AC 1 ms 3540 KiB
08_many_same_02.txt AC 1 ms 3500 KiB
08_many_same_03.txt AC 1 ms 3528 KiB
08_many_same_04.txt AC 1 ms 3412 KiB
08_many_same_05.txt AC 1 ms 3420 KiB
09_sorted_01.txt AC 4 ms 3708 KiB
09_sorted_02.txt AC 4 ms 3580 KiB
09_sorted_03.txt AC 4 ms 3520 KiB
09_sorted_04.txt AC 4 ms 3576 KiB