Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main ()
- {
- int n,x,y, s=0;
- int c,k=0;
- cin >> n;
- int a[100][2] = {0};
- for (int i=1; i<2*n; i+=2)
- {
- cout <<i<<" "<<i+1<<endl;
- if (!(cin >> x))
- {
- s+=1;
- cin.clear();
- cin.ignore(10, '\n');
- }
- else
- {
- if (x == -1) {return 0;}
- cin >> y;
- if (a[x][0] == 0) a[x][0] = i;
- else a[x][1] = i;
- if (a[y][0] == 0) a[y][0] = i+1;
- else a[y][1] = i+1;
- }
- if (i == 2*n - 3 && s == 0) goto here1;
- }
- goto here2;
- here1:
- for (int i=1; i<=n-s; i++)
- {
- if (a[i][0] != 0 && a[i][1] == 0) {a[i][1] = 2*n-k; k++;}
- }
- here2:
- for (int i=1; i<=n-s; i++)
- {
- if (a[i][0] != 0)
- {cout << a[i][0] <<" " << a[i][1]<<endl;}
- if (!(cin >> c))
- {
- cin.clear();
- cin.ignore(10, '\n');
- }
- else return 0;
- }
- cout << -1;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement