Submission #50499455
Source Code Expand
#include<bits/stdc++.h>
using namespace std;
using pl=pair<long long,long long>;
vector<long long> work(vector<pl> &op,vector<long long> a){
for(auto &nx : op){
for(auto &ny : a){
ny=(ny+nx.first)%nx.second;
}
}
return a;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
long long big=1e12;
long long n;
cin >> n;
vector<long long> a(n),b(n);
for(auto &nx : a){cin >> nx;}
for(auto &nx : b){cin >> nx;}
vector<pl> vp(n);
for(long long i=0;i<n;i++){
vp[i].first=a[i];
vp[i].second=b[i];
}
sort(vp.begin(),vp.end());
reverse(vp.begin(),vp.end());
vector<long long> del(n);
for(long long i=0;i<n;i++){
del[i]=vp[i].first-vp[i].second;
}
for(long long i=0;i<n-1;i++){
del[i]-=del[n-1];
}
// for(auto &nx : vp){cout << nx.first << " ";}cout << "\n";
// for(auto &nx : vp){cout << nx.second << " ";}cout << "\n";
// for(auto &nx : del){cout << nx << " ";}cout << "\n";
vector<pl> res;
long long cm=big;
for(long long i=0;i<n-1;i++){
pl op={cm+del[i]-vp[i].first,cm+del[i]};
cm+=big;
res.push_back(op);
for(auto &nx : vp){
nx.first=(nx.first+op.first)%op.second;
}
// cout << op.first << " , " << op.second << "\n";
// for(auto &nx : vp){cout << nx.first << " ";}cout << "\n";
}
long long lf=(big+vp[0].second-(vp[0].first%big))%big;
long long ls=big;
res.push_back({lf,ls});
for(auto &nx : vp){
nx.first=(nx.first+lf)%ls;
}
// cout << lf << " , " << ls << "\n";
// for(auto &nx : vp){cout << nx.first << " ";}cout << "\n";
if(work(res,a)!=b){
cout << "No\n";
return 0;
}
cout << "Yes\n";
cout << res.size() << "\n";
for(auto &nx : res){
cout << nx.first%nx.second << " ";
cout << nx.second << "\n";
}
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Add Mod Operations |
| User | physics0523 |
| Language | C++ 20 (gcc 12.2) |
| Score | 800 |
| Code Size | 1876 Byte |
| Status | AC |
| Exec Time | 7 ms |
| Memory | 3704 KiB |
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 | 3468 KiB |
| 01_sample_02.txt | AC | 1 ms | 3500 KiB |
| 01_sample_03.txt | AC | 1 ms | 3400 KiB |
| 01_sample_04.txt | AC | 1 ms | 3444 KiB |
| 02_small_1_01.txt | AC | 1 ms | 3396 KiB |
| 02_small_1_02.txt | AC | 1 ms | 3436 KiB |
| 02_small_1_03.txt | AC | 1 ms | 3504 KiB |
| 02_small_1_04.txt | AC | 1 ms | 3480 KiB |
| 02_small_1_05.txt | AC | 1 ms | 3400 KiB |
| 02_small_1_06.txt | AC | 1 ms | 3420 KiB |
| 02_small_1_07.txt | AC | 1 ms | 3576 KiB |
| 02_small_1_08.txt | AC | 1 ms | 3488 KiB |
| 02_small_1_09.txt | AC | 1 ms | 3440 KiB |
| 02_small_1_10.txt | AC | 1 ms | 3456 KiB |
| 03_small_2_01.txt | AC | 1 ms | 3396 KiB |
| 03_small_2_02.txt | AC | 1 ms | 3496 KiB |
| 03_small_2_03.txt | AC | 1 ms | 3568 KiB |
| 03_small_2_04.txt | AC | 1 ms | 3500 KiB |
| 03_small_2_05.txt | AC | 1 ms | 3424 KiB |
| 03_small_2_06.txt | AC | 1 ms | 3500 KiB |
| 03_small_2_07.txt | AC | 1 ms | 3564 KiB |
| 03_small_2_08.txt | AC | 1 ms | 3508 KiB |
| 03_small_2_09.txt | AC | 1 ms | 3500 KiB |
| 03_small_2_10.txt | AC | 1 ms | 3500 KiB |
| 04_rand_1_01.txt | AC | 7 ms | 3500 KiB |
| 04_rand_1_02.txt | AC | 7 ms | 3476 KiB |
| 04_rand_1_03.txt | AC | 7 ms | 3704 KiB |
| 04_rand_1_04.txt | AC | 7 ms | 3632 KiB |
| 04_rand_1_05.txt | AC | 7 ms | 3512 KiB |
| 05_rand_2_01.txt | AC | 7 ms | 3572 KiB |
| 05_rand_2_02.txt | AC | 7 ms | 3496 KiB |
| 05_rand_2_03.txt | AC | 7 ms | 3560 KiB |
| 05_rand_2_04.txt | AC | 7 ms | 3576 KiB |
| 05_rand_2_05.txt | AC | 7 ms | 3548 KiB |
| 06_rand_3_01.txt | AC | 7 ms | 3568 KiB |
| 06_rand_3_02.txt | AC | 7 ms | 3568 KiB |
| 06_rand_3_03.txt | AC | 7 ms | 3584 KiB |
| 06_rand_3_04.txt | AC | 7 ms | 3496 KiB |
| 06_rand_3_05.txt | AC | 7 ms | 3660 KiB |
| 07_rand_4_01.txt | AC | 7 ms | 3576 KiB |
| 07_rand_4_02.txt | AC | 7 ms | 3648 KiB |
| 07_rand_4_03.txt | AC | 7 ms | 3564 KiB |
| 07_rand_4_04.txt | AC | 7 ms | 3516 KiB |
| 07_rand_4_05.txt | AC | 7 ms | 3564 KiB |
| 07_rand_4_06.txt | AC | 7 ms | 3512 KiB |
| 07_rand_4_07.txt | AC | 7 ms | 3568 KiB |
| 07_rand_4_08.txt | AC | 7 ms | 3500 KiB |
| 07_rand_4_09.txt | AC | 7 ms | 3584 KiB |
| 07_rand_4_10.txt | AC | 7 ms | 3512 KiB |
| 08_many_same_01.txt | AC | 7 ms | 3580 KiB |
| 08_many_same_02.txt | AC | 7 ms | 3500 KiB |
| 08_many_same_03.txt | AC | 7 ms | 3508 KiB |
| 08_many_same_04.txt | AC | 7 ms | 3520 KiB |
| 08_many_same_05.txt | AC | 7 ms | 3632 KiB |
| 09_sorted_01.txt | AC | 7 ms | 3632 KiB |
| 09_sorted_02.txt | AC | 7 ms | 3576 KiB |
| 09_sorted_03.txt | AC | 7 ms | 3576 KiB |
| 09_sorted_04.txt | AC | 7 ms | 3564 KiB |