A - Insert
https://atcoder.jp/contests/abc361/tasks/abc361_a
https://atcoder.jp/contests/abc361/submissions/55260626
int n, k, x; vector<int> a; int main() { cin >> n >> k >> x; a.resize(n+1); for(int i=0; i<n+1; i++){ if (i == k){ a[i] = x; } else { cin >> a[i]; } } for(int i=0; i<n+1; i++){ cout << a[i] << " "; } return 0; }
B - Intersection of Cuboids
https://atcoder.jp/contests/abc361/tasks/abc361_b
https://atcoder.jp/contests/abc361/submissions/55334640
int a, b, c, d, e, f; int g, h, i, j, k, l; bool check_if_intersected(array<int, 2>& one_segment, array<int, 2>& two_segment){ int one_start = one_segment[0]; int one_stop = one_segment[1]; int two_start = two_segment[0]; int two_stop = two_segment[1]; /* intersection: one --------------- two ------------- */ if (two_start >= one_start){ if (one_stop > two_start){ return true; } } /* intersection: one --------------- two ------------- */ if (one_start >= two_start){ if (two_stop > one_start){ return true; } } return false; } int main() { cin >> a >> b >> c >> d >> e >> f; cin >> g >> h >> i >> j >> k >> l; array<array<int,2>, 3> dimensions_of_one{{ {a, d}, // x {b, e}, // y {c, f} // z }}; array<array<int,2>, 3> dimensions_of_two{{ {g, j}, // x {h, k}, // y {i, l} // z }}; for(int i=0; i<3; i++){ array<int, 2>& one_segment = dimensions_of_one[i]; array<int, 2>& two_segment = dimensions_of_two[i]; /* check if two segment has intersection. */ if (!check_if_intersected(one_segment, two_segment)){ cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
标签:int,two,start,abc361,segment,array From: https://www.cnblogs.com/lightsong/p/18288278