#include<iostream> #include<vector> using namespace std; typedef struct{ int index, a, b; }Box; int main(){ int all; cin >> all; for(int t = 0;t < all;t ++){ int n, m; cin >> n >> m; vector<Box> box; for(int j = 0;j < n;j ++){ Box temp; temp.index = j + 1; cin >> temp.a >> temp.b; box.push_back(temp); } for(int j = 0;j < n;j ++){ for(int k = j;k < n;k ++){ if(box[k].b < box[k + 1].b){ Box temp = box[k]; box[k] = box[k + 1]; box[k + 1] = temp; } } } for(int j = 0;j < n;j ++){ for(int k = j;k < n;k ++){ if(box[k].a < box[k + 1].a){ Box temp = box[k]; box[k] = box[k + 1]; box[k + 1] = temp; } } } for(int j = 0;j < m - 1;j ++){ cout << box[j].index << " "; } cout << box[j].index << endl; } } /* Main.cc: In function 'int main()': Main.cc:44:17: error: 'j' was not declared in this scope cout << box[j].index << endl; ^ */ |
Double click to view unformatted code.