提出 #47824461


ソースコード 拡げる

#include<bits/stdc++.h>
#define ll long long
#define db double
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define FR first
#define SE second
#define int long long
using namespace std;
inline int read() {
  int x = 0; bool op = false;
  char c = getchar();
  while(!isdigit(c))op |= (c == '-'), c = getchar();
  while(isdigit(c))x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return op ? -x : x;
}
const int N = 1e3 + 10;
const int P = 1e10;
int n;
pii a[N];
vector<pii> ans;
void work(int x, int y) {
  ans.pb({x, y});
  for(int i = 1; i <= n; i++)a[i].FR = (a[i].FR + x) % y;
  // for(int i = 1; i <= n; i++)printf("%lld ", a[i].FR % P); cout << endl;
  return ;
}
int f[N];
signed main() {
  n = read();
  for(int i = 1; i <= n; i++)a[i].FR = read();
  for(int i = 1; i <= n; i++)a[i].SE = read();
  sort(a + 1, a + 1 + n);
  n = unique(a + 1, a + 1 + n) - (a + 1);
  for(int i = 1; i < n; i++)if(a[i].FR == a[i + 1].FR)return puts("No"), 0;
  puts("Yes");
  // for(int i = 1; i <= n; i++)printf("%d ", a[i].FR % P); cout << endl;
  if(n == 1)work((a[1].SE - a[1].FR + P) % P, P);
  else {
    f[1] = a[1].SE - a[n].SE - a[1].FR + P;
    for(int i = 2; i < n; i++)f[i] = a[n - i + 2].SE - a[n - i + 1].SE + P;
    f[n] = a[2].SE;
    for(int i = n; i > 1; i--)work(f[n - i + 1], a[i].FR + f[n - i + 1]);
    work(f[n], P);
  }
  for(int i = 1; i <= n; i++)assert(a[i].FR == a[i].SE);
  printf("%lu\n", ans.size());
  for(auto t : ans)printf("%lld %lld\n", t.FR, t.SE);
  return 0;
}

提出情報

提出日時
問題 C - Add Mod Operations
ユーザ thebighead
言語 C++ 20 (gcc 12.2)
得点 800
コード長 1598 Byte
結果 AC
実行時間 5 ms
メモリ 3844 KiB

ジャッジ結果

セット名 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 3 ms 3596 KiB
01_sample_02.txt AC 1 ms 3680 KiB
01_sample_03.txt AC 2 ms 3640 KiB
01_sample_04.txt AC 1 ms 3504 KiB
02_small_1_01.txt AC 1 ms 3652 KiB
02_small_1_02.txt AC 1 ms 3756 KiB
02_small_1_03.txt AC 1 ms 3608 KiB
02_small_1_04.txt AC 1 ms 3744 KiB
02_small_1_05.txt AC 1 ms 3696 KiB
02_small_1_06.txt AC 1 ms 3604 KiB
02_small_1_07.txt AC 1 ms 3652 KiB
02_small_1_08.txt AC 1 ms 3560 KiB
02_small_1_09.txt AC 1 ms 3576 KiB
02_small_1_10.txt AC 1 ms 3596 KiB
03_small_2_01.txt AC 1 ms 3624 KiB
03_small_2_02.txt AC 1 ms 3556 KiB
03_small_2_03.txt AC 1 ms 3828 KiB
03_small_2_04.txt AC 1 ms 3616 KiB
03_small_2_05.txt AC 1 ms 3596 KiB
03_small_2_06.txt AC 1 ms 3484 KiB
03_small_2_07.txt AC 1 ms 3636 KiB
03_small_2_08.txt AC 1 ms 3544 KiB
03_small_2_09.txt AC 1 ms 3504 KiB
03_small_2_10.txt AC 1 ms 3448 KiB
04_rand_1_01.txt AC 4 ms 3624 KiB
04_rand_1_02.txt AC 4 ms 3788 KiB
04_rand_1_03.txt AC 4 ms 3788 KiB
04_rand_1_04.txt AC 5 ms 3680 KiB
04_rand_1_05.txt AC 4 ms 3616 KiB
05_rand_2_01.txt AC 2 ms 3468 KiB
05_rand_2_02.txt AC 1 ms 3452 KiB
05_rand_2_03.txt AC 1 ms 3456 KiB
05_rand_2_04.txt AC 1 ms 3516 KiB
05_rand_2_05.txt AC 1 ms 3496 KiB
06_rand_3_01.txt AC 4 ms 3784 KiB
06_rand_3_02.txt AC 4 ms 3628 KiB
06_rand_3_03.txt AC 4 ms 3684 KiB
06_rand_3_04.txt AC 4 ms 3624 KiB
06_rand_3_05.txt AC 5 ms 3680 KiB
07_rand_4_01.txt AC 4 ms 3596 KiB
07_rand_4_02.txt AC 4 ms 3664 KiB
07_rand_4_03.txt AC 5 ms 3844 KiB
07_rand_4_04.txt AC 5 ms 3792 KiB
07_rand_4_05.txt AC 4 ms 3784 KiB
07_rand_4_06.txt AC 5 ms 3792 KiB
07_rand_4_07.txt AC 4 ms 3596 KiB
07_rand_4_08.txt AC 4 ms 3784 KiB
07_rand_4_09.txt AC 4 ms 3656 KiB
07_rand_4_10.txt AC 4 ms 3680 KiB
08_many_same_01.txt AC 1 ms 3816 KiB
08_many_same_02.txt AC 1 ms 3760 KiB
08_many_same_03.txt AC 1 ms 3752 KiB
08_many_same_04.txt AC 1 ms 3652 KiB
08_many_same_05.txt AC 1 ms 3764 KiB
09_sorted_01.txt AC 4 ms 3792 KiB
09_sorted_02.txt AC 4 ms 3676 KiB
09_sorted_03.txt AC 4 ms 3844 KiB
09_sorted_04.txt AC 4 ms 3784 KiB