Pagini recente » Cod sursa (job #2901212) | Cod sursa (job #702099) | Cod sursa (job #2041826) | Cod sursa (job #1764163) | Cod sursa (job #2763484)
#include <fstream>
#include <algorithm>
#include <bitset>
using namespace std;
ifstream fin("sortaret.in");
ofstream fout("sortaret.out");
int n, m;
vector<pair<int, int>> v[50010];
bitset<50010> use;
int main() {
fin >> n >> m;
for (int i = 1; i <= m; i++) {
int x, y;
fin >> x >> y;
v[x].push_back(make_pair(y, i));
}
for (int i = 1; i <= n; i++)
sort(v[i].begin(), v[i].end());
for (int i = 1; i <= n; i++)
for (auto it:v[i]) {
fout << it.second << " ";
use[it.second] = 1;
}
for (int i = 1; i <= n; i++)
if (!use[i])
fout << i << " ";
return 0;
}