|
|
вернуться в форум#include<stdio.h> #include<deque> #include<algorithm> using namespace std; class node{ public: int x,y,num; }dum; bool func(node i,node j) { if(i.y > j.y) return true; return false; } int main() { deque<node> city; int n; scanf("%d",&n); for(int i=0;i<n;i++) { scanf("%d %d",&dum.x,&dum.y); dum.num = (i+1); city.push_back(dum); } if(n == 0) {printf("0");return 0;} sort(city.begin(),city.end(),func); for(int i=0;i<n;i+=2) { printf("%d %d\n",city[i].num,city[i+1].num); } } your code is wrong http://ideone.com/2mv3As it prints 3 4 1 2 instead of 1 3 2 4 for the test from description of the problem perhaps it gaves AC so your code is right, tests are wrong or problem description is not completed |
|
|