CP3 Exercise 1.2.3//5

#include<bits/stdc++.h>
using namespace std;
#define sf(a)                   scanf("%I64d",&a)
#define sff(a,b)                scanf("%I64d %I64d",&a,&b)
#define sfff(a,b,c)             scanf("%I64d %I64d %I64d",&a,&b,&c)
#define sffff(a,b,c,d)          scanf("%I64d %I64d %I64d %I64d",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)       scanf("%I64d %I64d %I64d %I64d %I64d",&a,&b,&c,&d,&e)
#define flop(m,n,q)             for(ll i=m;i<n;i+=q)
#define read                    freopen("input.txt","r",stdin)
#define write                   freopen("output.txt","w",stdout)
#define ll                      long long int
#define MAX                     1000009
#define Max                     1000000009
#define pb                      push_back
#define all(c)                  c.begin(),c.end()
#define sloop(a,itr)            for(itr=a.begin();itr!=a.end();itr++)

bool comp(pair<int,pair<int,int>>p1,pair<int,pair<int,int>>p2)
{
    if(p1.second.first<p2.second.first)
        return 1;
    else if(p1.second.first==p2.second.first)
    {
        if(p1.first==p2.first)
        {
            if(p1.second.second<p2.second.second)
               return 1;
            else
                return 0;
        }
        else if(p1.first<p2.first)
            return 1;
        else
            return 0;
    }
    else
        return 0;
}


int main()
{
    read;
    int d,m,y,n,i;
    pair<int,pair<int,int>>p;
    vector<pair<int,pair<int,int>>>info;
    cin>>n;
    for(i=0;i<n;i++)
    {
        cin>>d>>m>>y;
        p=make_pair(d,make_pair(m,y));
        info.pb(p);
    }
    sort(all(info),comp);
    for(i=0;i<n;i++)
    {
        cout<<info[i].first<<" "<<info[i].second.first<<" "<<info[i].second.second<<endl;
    }
}


Input::

13
23 10 1997
24 10 1997
21 10 1997
23 11 1997
21 11 1997
21 11 1999
24 11 1999
21 10 1999
24 10 1999
21 10 1996
24 10 1996
21 11 1996

24 11 1996

output::

21 10 1996
21 10 1997
21 10 1999
23 10 1997
24 10 1996
24 10 1997
24 10 1999
21 11 1996
21 11 1997
21 11 1999
23 11 1997
24 11 1996
24 11 1999

মন্তব্যসমূহ

এই ব্লগটি থেকে জনপ্রিয় পোস্টগুলি

lightOJ-1072 Calm Down