Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- struct tepm{
- int data = 1, ind;
- };
- struct all{
- int a, b, c, d;
- };
- int main()
- {
- int n, x, y, z, w;
- bool bol1, bol2, bol3, bol4;
- cin >> n;
- tepm temp;
- vector <tepm> a, b;
- vector <all> k;
- all time;
- for (int i = 1; i <= n; i++){
- cin >> x >> y >> z >> w;
- time.a = x;
- time.b = y;
- time.c = z;
- time.d = w;
- k.push_back(time);
- bol1 = 0;
- bol2 = 0;
- bol3 = 0;
- bol4 = 0;
- for (int j = 1; j <= a.size(); j++){
- if (a[j - 1].ind == x){
- a[j - 1].data++;
- bol1 = 1;
- }
- if (a[j - 1].ind == y){
- a[j - 1].data++;
- bol2 = 1;
- }
- }
- for (int j = 1; j <= b.size(); j++){
- if (b[j - 1].ind == z){
- b[j - 1].data++;
- bol3 = 1;
- }
- if (b[j - 1].ind == w){
- b[j - 1].data++;
- bol4 = 1;
- }
- }
- if (!bol1){
- temp.ind = x;
- a.push_back(temp);
- }
- if (!bol2){
- temp.ind = y;
- a.push_back(temp);
- }
- if (!bol3){
- temp.ind = z;
- b.push_back(temp);
- }
- if (!bol4){
- temp.ind = w;
- b.push_back(temp);
- }
- }
- int maxi = 0, ans, ans1, ans2;
- for (int i = 0; i < a.size(); i++)
- for (int j = 0; j < b.size(); j++){
- ans = 0;
- for (z = 0; z < k.size(); z++)
- if (k[z].a == a[i].ind || k[z].b == a[i].ind || k[z].c == b[j].ind || k[z].d == b[j].ind)
- ans++;
- if (ans > maxi){
- maxi = ans;
- ans1 = a[i].ind;
- ans2 = b[j].ind;
- }
- }
- cout << ans1 << " " << ans2 << endl;
- return 0;
- }
- /*
- 5
- 2 3 1 2
- 3 5 1 2
- 7 8 8 9
- 5 6 2 3
- 3 5 6 8
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement