Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- using pi = pair <int, int>;
- const int N = 5000005;
- int a[1510][2], b[1510][2], c[1510][2], d[1510][2];
- int n;
- pi hashing[N], keep[N];
- pi zero = {0, 0};
- int main(){
- int t1, t2;
- scanf("%d%d", &t1, &t2);
- scanf("%d", &n);
- for(int i=1;i<=n;i++) scanf("%d%d", &a[i][0], &a[i][1]);
- for(int i=1;i<=n;i++) scanf("%d%d", &b[i][0], &b[i][1]);
- for(int i=1;i<=n;i++) scanf("%d%d", &c[i][0], &c[i][1]);
- for(int i=1;i<=n;i++) scanf("%d%d", &d[i][0], &d[i][1]);
- for(int i=1;i<=n;i++){
- for(int j=1;j<=n;j++){
- int hsh = abs( (3*(a[i][0] + b[j][0]) + 7*(a[i][1] + b[j][1]) + N) % N);
- while(hashing[hsh] != zero){
- hsh ++;
- hsh = hsh % N;
- }
- hashing[hsh] = {i, j};
- keep[hsh] = {a[i][0] + b[j][0], a[i][1] + b[j][1]};
- }
- }
- for(int i=1;i<=n;i++){
- for(int j=1;j<=n;j++){
- int hsh = abs( (3*(t1 - c[i][0] - d[j][0]) + 7*(t2 - c[i][1] - d[j][1]) + N) % N);
- while(hashing[hsh] != zero){
- if(keep[hsh].first == t1 - c[i][0] - d[j][0] and keep[hsh].second == t2 - c[i][1] - d[j][1]){
- printf("%d %d\n", a[hashing[hsh].first][0], a[hashing[hsh].first][1]);
- printf("%d %d\n", b[hashing[hsh].second][0], b[hashing[hsh].second][1]);
- printf("%d %d\n", c[i][0], c[i][1]);
- printf("%d %d", d[j][0], d[j][1]);
- return 0;
- }
- hsh ++;
- hsh = hsh % N;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement