#include<iostream>
#include<string>
#include<set>
#include<list>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define MAX_N 100000
int silnia(int n)
{
int wynik = 1;
for(int i=1; i<=n; i++)
wynik *= i;
return wynik;
}
struct pomiar
{
int numer;
vector<int> dane;
};
bool porownaj(pomiar p1, pomiar p2)
{
bool czyRowne = true;
bool czyPierwszyMniejszy = true;
for(int i=0; i<p1.dane.size(); i++)
{
if(p1.dane[i] != p2.dane[i])
czyRowne = false;
if(p1.dane[i] > p2.dane[i])
{
czyRowne = false;
czyPierwszyMniejszy = false;
break;
}
}
if(czyRowne == true)
return(p1.numer < p2.numer);
else
{
if(czyPierwszyMniejszy == true)
return true;
else return false;
}
}
int main()
{
ios_base::sync_with_stdio(0);
int n, m;
vector<int> v;
vector<pomiar> pomiary;
cin>>n>>m;
while(n--)
{
int a;
cin>>a;
v.push_back(a);
}
pomiar p;
p.numer = 1;
p.dane = v;
pomiary.push_back(p);
for(int i=1; i<m; i++)
{
int a, b;
cin>>a>>b;
p.numer = i+1;
p.dane = pomiary[i-1].dane;
p.dane[a-1] = b;
pomiary.push_back(p);
}
/*
for(int i=0; i<pomiary.size(); i++)
{
cout<<"nr: "<<pomiary[i].numer<<" | ";
for(int j=0; j<pomiary[i].dane.size(); j++)
cout<<pomiary[i].dane[j]<<" ";
cout<<endl;
}
*/
sort(pomiary.begin(), pomiary.end(), porownaj);
for(int i=0; i<pomiary.size(); i++)
{
cout<<pomiary[i].numer<<" ";
}
}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | #include<iostream> #include<string> #include<set> #include<list> #include<map> #include<vector> #include<queue> #include<stack> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> #include <stdio.h> using namespace std; #define MAX_N 100000 int silnia(int n) { int wynik = 1; for(int i=1; i<=n; i++) wynik *= i; return wynik; } struct pomiar { int numer; vector<int> dane; }; bool porownaj(pomiar p1, pomiar p2) { bool czyRowne = true; bool czyPierwszyMniejszy = true; for(int i=0; i<p1.dane.size(); i++) { if(p1.dane[i] != p2.dane[i]) czyRowne = false; if(p1.dane[i] > p2.dane[i]) { czyRowne = false; czyPierwszyMniejszy = false; break; } } if(czyRowne == true) return(p1.numer < p2.numer); else { if(czyPierwszyMniejszy == true) return true; else return false; } } int main() { ios_base::sync_with_stdio(0); int n, m; vector<int> v; vector<pomiar> pomiary; cin>>n>>m; while(n--) { int a; cin>>a; v.push_back(a); } pomiar p; p.numer = 1; p.dane = v; pomiary.push_back(p); for(int i=1; i<m; i++) { int a, b; cin>>a>>b; p.numer = i+1; p.dane = pomiary[i-1].dane; p.dane[a-1] = b; pomiary.push_back(p); } /* for(int i=0; i<pomiary.size(); i++) { cout<<"nr: "<<pomiary[i].numer<<" | "; for(int j=0; j<pomiary[i].dane.size(); j++) cout<<pomiary[i].dane[j]<<" "; cout<<endl; } */ sort(pomiary.begin(), pomiary.end(), porownaj); for(int i=0; i<pomiary.size(); i++) { cout<<pomiary[i].numer<<" "; } } |
English