Submission #44141032
Source Code Expand
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define op(x) ((x&1)?x+1:x-1)
#define odd(x) (x&1)
#define even(x) (!odd(x))
#define lc(x) (x<<1)
#define rc(x) (lc(x)|1)
#define lowbit(x) (x&-x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
using namespace std;
const ll MAXN = 1010,K = 1e14;
ll n,a[MAXN],b[MAXN],arr[MAXN],tot;
typedef array<ll,2> pr;
vector<pr>ret;
void add(ll x,ll y){
x%=y;
ret.push_back({x,y});
}
void output(){
cout<<"Yes\n";
cout<<ret.size()<<"\n";
for(auto [x,y] : ret)cout<<x<<" "<<y<<"\n";
exit(0);
}
int main(){
cin>>n;
rep(i,1,n)cin>>a[i];
rep(i,1,n)cin>>b[i];
rep(i,1,n)rep(j,i+1,n)if(a[i] == a[j] && b[i] != b[j]){
cout<<"No\n";
exit(0);
}
rep(i,1,n){
int flag = 1;
rep(j,1,i-1)if(a[j] == a[i])flag = 0;
if(flag)arr[++tot] = i;
}
if(tot==1){
add(K + b[1] - a[1],K);
output();
}
sort(arr+1,arr+1+tot,[&](ll x,ll y){return a[x] < a[y];});
assert(tot > 0);
ll ps = 0;
rep(i,1,tot-1){
int y = (i==1) ? (1) : (tot-i+2),x = (i==1) ? (tot) : (tot-i+1),mx = tot - i + 1;
ll val = K + b[arr[y]] - b[arr[x]] - ((i==1) ? (a[arr[1]]) : (0));
ps += val;
add(val,a[arr[mx]] + ps);
}
add(b[arr[2]],K);
output();
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Add Mod Operations |
| User | Crying |
| Language | C++ (GCC 9.2.1) |
| Score | 800 |
| Code Size | 1400 Byte |
| Status | AC |
| Exec Time | 9 ms |
| Memory | 3568 KB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 800 / 800 | ||||
| Status |
|
|
| 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 | 7 ms | 3424 KB |
| 01_sample_02.txt | AC | 2 ms | 3476 KB |
| 01_sample_03.txt | AC | 3 ms | 3468 KB |
| 01_sample_04.txt | AC | 3 ms | 3532 KB |
| 02_small_1_01.txt | AC | 2 ms | 3348 KB |
| 02_small_1_02.txt | AC | 2 ms | 3460 KB |
| 02_small_1_03.txt | AC | 2 ms | 3356 KB |
| 02_small_1_04.txt | AC | 2 ms | 3300 KB |
| 02_small_1_05.txt | AC | 2 ms | 3496 KB |
| 02_small_1_06.txt | AC | 2 ms | 3484 KB |
| 02_small_1_07.txt | AC | 3 ms | 3468 KB |
| 02_small_1_08.txt | AC | 2 ms | 3532 KB |
| 02_small_1_09.txt | AC | 2 ms | 3476 KB |
| 02_small_1_10.txt | AC | 2 ms | 3468 KB |
| 03_small_2_01.txt | AC | 2 ms | 3300 KB |
| 03_small_2_02.txt | AC | 2 ms | 3512 KB |
| 03_small_2_03.txt | AC | 2 ms | 3460 KB |
| 03_small_2_04.txt | AC | 2 ms | 3364 KB |
| 03_small_2_05.txt | AC | 3 ms | 3360 KB |
| 03_small_2_06.txt | AC | 2 ms | 3448 KB |
| 03_small_2_07.txt | AC | 2 ms | 3336 KB |
| 03_small_2_08.txt | AC | 2 ms | 3424 KB |
| 03_small_2_09.txt | AC | 3 ms | 3424 KB |
| 03_small_2_10.txt | AC | 2 ms | 3428 KB |
| 04_rand_1_01.txt | AC | 7 ms | 3548 KB |
| 04_rand_1_02.txt | AC | 5 ms | 3392 KB |
| 04_rand_1_03.txt | AC | 5 ms | 3516 KB |
| 04_rand_1_04.txt | AC | 6 ms | 3520 KB |
| 04_rand_1_05.txt | AC | 5 ms | 3512 KB |
| 05_rand_2_01.txt | AC | 4 ms | 3368 KB |
| 05_rand_2_02.txt | AC | 2 ms | 3544 KB |
| 05_rand_2_03.txt | AC | 2 ms | 3304 KB |
| 05_rand_2_04.txt | AC | 3 ms | 3344 KB |
| 05_rand_2_05.txt | AC | 4 ms | 3480 KB |
| 06_rand_3_01.txt | AC | 5 ms | 3496 KB |
| 06_rand_3_02.txt | AC | 7 ms | 3524 KB |
| 06_rand_3_03.txt | AC | 5 ms | 3508 KB |
| 06_rand_3_04.txt | AC | 6 ms | 3524 KB |
| 06_rand_3_05.txt | AC | 6 ms | 3544 KB |
| 07_rand_4_01.txt | AC | 5 ms | 3508 KB |
| 07_rand_4_02.txt | AC | 5 ms | 3492 KB |
| 07_rand_4_03.txt | AC | 5 ms | 3496 KB |
| 07_rand_4_04.txt | AC | 5 ms | 3548 KB |
| 07_rand_4_05.txt | AC | 7 ms | 3340 KB |
| 07_rand_4_06.txt | AC | 8 ms | 3516 KB |
| 07_rand_4_07.txt | AC | 9 ms | 3488 KB |
| 07_rand_4_08.txt | AC | 5 ms | 3548 KB |
| 07_rand_4_09.txt | AC | 8 ms | 3380 KB |
| 07_rand_4_10.txt | AC | 6 ms | 3376 KB |
| 08_many_same_01.txt | AC | 9 ms | 3456 KB |
| 08_many_same_02.txt | AC | 6 ms | 3472 KB |
| 08_many_same_03.txt | AC | 6 ms | 3308 KB |
| 08_many_same_04.txt | AC | 5 ms | 3368 KB |
| 08_many_same_05.txt | AC | 4 ms | 3472 KB |
| 09_sorted_01.txt | AC | 5 ms | 3348 KB |
| 09_sorted_02.txt | AC | 9 ms | 3340 KB |
| 09_sorted_03.txt | AC | 7 ms | 3568 KB |
| 09_sorted_04.txt | AC | 4 ms | 3340 KB |