提出 #44117593


ソースコード 拡げる

#include <assert.h>
#include <math.h>
#include <memory.h>
#include <stdio.h>
 
#include <algorithm>
#include <chrono>
#include <complex>
#include <ctime>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <random>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define ARG4(_1,_2,_3,_4,...) _4
 
#define forn3(i,l,r) for (int i = int(l); i < int(r); ++i)
#define forn2(i,n) forn3 (i, 0, n)
#define forn(...) ARG4(__VA_ARGS__, forn3, forn2) (__VA_ARGS__)
 
#define ford3(i,l,r) for (int i = int(r) - 1; i >= int(l); --i)
#define ford2(i,n) ford3 (i, 0, n)
#define ford(...) ARG4(__VA_ARGS__, ford3, ford2) (__VA_ARGS__)

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define all(x) (x).begin(), (x).end()

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = (1LL << 62) - 1;
const long double pi = acos(-1);

template<typename T> inline T abs (T x) {return x < 0 ? -x : x;}
template<typename T> inline T sqr (T x) {return x * x;}

template<typename T1, typename T2> inline bool umx (T1& a, T2 b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T1, typename T2> inline bool umn (T1& a, T2 b) {if (b < a) {a = b; return 1;} return 0;}

const long long P = 1e9 + 7;

void Solve(int ti) {
    int n;
    cin >> n;

    vector<long long> a(n);
    forn (i, n) {
        cin >> a[i];
    }

    vector<long long> b(n);
    forn (i, n) {
        cin >> b[i];
    }

    vector<pair<long long, long long>> f(n);
    forn (i, n) {
        f[i] = {a[i], b[i]};
    }

    sort(all(f));
    f.resize(unique(all(f)) - f.begin());

    int m = sz(f);
    forn (i, 1, m) {
        if (f[i].fs == f[i - 1].fs) {
            cout << "No" << "\n";
            return;
        }
    }

    vector<pair<long long, long long>> res;
    long long add = 0;
    ford (i, m) {
        long long cur_add = 0;
        long long cur_mod = 1;

        if (f[i].fs + add > 0) {
            cur_add = (i == m - 1 ? 2 * P + f[0].sc - f[m - 1].sc - f[0].fs : f[i + 1].sc - f[i].sc + P);
            add += cur_add;
            cur_mod = f[i].fs + add;
        }

        if (i == 0) {
            cur_add += f[i].sc;
            cur_mod = P;
        }

        cur_add %= cur_mod;
        res.pb({cur_add, cur_mod});
    }

    cout << "Yes" << "\n";
    cout << sz(res) << "\n";
    forn (i, sz(res)) {
        cout << res[i].fs << " " << res[i].sc << "\n";
    }
}

int main () {
    ios_base::sync_with_stdio(0);
    std::cin.tie(nullptr);
    
    // clock_t start_clock = clock();
    
    // freopen("_input.txt", "rt", stdin);
    // freopen("_output.txt", "wt", stdout);

    int tc = 1;
    // cin >> tc;
    forn (ti, tc) {
        Solve(ti);
    }
    
    // double total_seconds = (double) (clock() - start_clock) / CLOCKS_PER_SEC;
    // cerr << "Working time: " << total_seconds << "s." << endl;

    return 0;
}

提出情報

提出日時
問題 C - Add Mod Operations
ユーザ TeaPot
言語 C++ (GCC 9.2.1)
得点 800
コード長 3123 Byte
結果 AC
実行時間 7 ms
メモリ 3600 KiB

コンパイルエラー

./Main.cpp: In function ‘void Solve(int)’:
./Main.cpp:53:16: warning: unused parameter ‘ti’ [-Wunused-parameter]
   53 | void Solve(int ti) {
      |            ~~~~^~

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 800 / 800
結果
AC × 4
AC × 58
セット名 テストケース
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
ケース名 結果 実行時間 メモリ
01_sample_01.txt AC 1 ms 3468 KiB
01_sample_02.txt AC 2 ms 3464 KiB
01_sample_03.txt AC 2 ms 3508 KiB
01_sample_04.txt AC 2 ms 3528 KiB
02_small_1_01.txt AC 2 ms 3396 KiB
02_small_1_02.txt AC 2 ms 3472 KiB
02_small_1_03.txt AC 3 ms 3412 KiB
02_small_1_04.txt AC 2 ms 3452 KiB
02_small_1_05.txt AC 2 ms 3528 KiB
02_small_1_06.txt AC 2 ms 3472 KiB
02_small_1_07.txt AC 2 ms 3460 KiB
02_small_1_08.txt AC 3 ms 3432 KiB
02_small_1_09.txt AC 2 ms 3528 KiB
02_small_1_10.txt AC 2 ms 3516 KiB
03_small_2_01.txt AC 2 ms 3512 KiB
03_small_2_02.txt AC 2 ms 3468 KiB
03_small_2_03.txt AC 2 ms 3468 KiB
03_small_2_04.txt AC 1 ms 3464 KiB
03_small_2_05.txt AC 2 ms 3516 KiB
03_small_2_06.txt AC 2 ms 3528 KiB
03_small_2_07.txt AC 2 ms 3432 KiB
03_small_2_08.txt AC 2 ms 3468 KiB
03_small_2_09.txt AC 2 ms 3508 KiB
03_small_2_10.txt AC 2 ms 3472 KiB
04_rand_1_01.txt AC 2 ms 3584 KiB
04_rand_1_02.txt AC 5 ms 3592 KiB
04_rand_1_03.txt AC 5 ms 3536 KiB
04_rand_1_04.txt AC 3 ms 3588 KiB
04_rand_1_05.txt AC 6 ms 3480 KiB
05_rand_2_01.txt AC 5 ms 3552 KiB
05_rand_2_02.txt AC 3 ms 3500 KiB
05_rand_2_03.txt AC 2 ms 3488 KiB
05_rand_2_04.txt AC 3 ms 3468 KiB
05_rand_2_05.txt AC 2 ms 3452 KiB
06_rand_3_01.txt AC 3 ms 3560 KiB
06_rand_3_02.txt AC 3 ms 3480 KiB
06_rand_3_03.txt AC 3 ms 3600 KiB
06_rand_3_04.txt AC 7 ms 3584 KiB
06_rand_3_05.txt AC 5 ms 3468 KiB
07_rand_4_01.txt AC 4 ms 3500 KiB
07_rand_4_02.txt AC 5 ms 3536 KiB
07_rand_4_03.txt AC 6 ms 3480 KiB
07_rand_4_04.txt AC 4 ms 3560 KiB
07_rand_4_05.txt AC 4 ms 3588 KiB
07_rand_4_06.txt AC 7 ms 3500 KiB
07_rand_4_07.txt AC 4 ms 3500 KiB
07_rand_4_08.txt AC 4 ms 3536 KiB
07_rand_4_09.txt AC 4 ms 3528 KiB
07_rand_4_10.txt AC 4 ms 3596 KiB
08_many_same_01.txt AC 6 ms 3464 KiB
08_many_same_02.txt AC 2 ms 3556 KiB
08_many_same_03.txt AC 2 ms 3552 KiB
08_many_same_04.txt AC 2 ms 3544 KiB
08_many_same_05.txt AC 2 ms 3572 KiB
09_sorted_01.txt AC 7 ms 3528 KiB
09_sorted_02.txt AC 6 ms 3584 KiB
09_sorted_03.txt AC 3 ms 3468 KiB
09_sorted_04.txt AC 4 ms 3468 KiB