2 solutions

  • 0
    @ 2023-9-2 21:41:55
    #include<bits/stdc++.h>
    #define ll long long
    
    using namespace std;
    
    template<typename T>
    inline void in (T &x) {char c;int f=1;do {c=getchar ();if (c=='-') f=-1;} while (c>'9' || c<'0');for (x=0;c>='0' && c<='9';c=getchar ()) x=(x<<1)+(x<<3)+(c^48);x*=f;}
    
    template<typename T>
    inline void out (T x,char c) {if (x==0) {putchar ('0'),putchar (c); return ;}if (x<0)putchar ('-'),x=-x;int sta[20],k=0;while (x) sta[++k]=x%10,x/=10;while (k) putchar (sta[k--]+'0');putchar (c);}
    
    const int N=1e3+5;
    
    struct node{
    	int chi,mat,id;
    }a[N];
    
    int n;
    
    bool cmp(node x,node y){
    	if(x.chi==y.chi){
    		if(x.mat==y.mat){
    			return x.id<y.id;
    		}
    		return x.mat<y.mat;
    	}
    	return x.chi<y.chi;
    }
    int main(){
    //	freopen ("std.in","r",stdin);
    //	freopen (".out","w",stdout);
    	ios::sync_with_stdio(false);
    	cin.tie(0);
    	cout.tie(0);
    	in(n);
    	for(int i=1;i<=n;++i){
    		in(a[i].chi),in(a[i].mat);
    		a[i].id=i;
    	}
    	sort(a+1,a+n+1,cmp);
    	for(int i=1;i<=n;++i){
    		out(a[i].id,' ');
    	}	
    	return 0;
    }
    

    Information

    ID
    6828
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    8
    Tags
    # Submissions
    94
    Accepted
    18
    Uploaded By