807A - Is it rated - CodeForces Solution


implementation sortings *900

Please click on ads to support us..

Python Code:

class Solution():

    def is_it_rated(participants):
        ratings = []
        for participant in range(participants):
            rating_before, rating_after = map(int, input().split())
            if rating_after != rating_before:
                return "rated"
            else:
                ratings.append(rating_after)
        if ratings != sorted(ratings, reverse= True):
            return "unrated"
        else:
            return "maybe"
        


if __name__ == '__main__':
    participants = int(input())
    print(Solution.is_it_rated(participants))

C++ Code:

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pi acos(-1)
#define pb push_back
#define pf push_front
//#define endl '\n'
#define MAXN 32000
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize("O3,Ofast,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt,tune=native")
using namespace std;
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll >, rb_tree_tag,
        tree_order_statistics_node_update>
        newset;
ll i,j,a,k,b,c,n,t=1,m,p,q,d,e,f,y,g,z,h,r,l,x,u,o;
ld aa,bb,ee,dd,ff,kk,gg,cc;
vector<ll> v[100006],s,vv;
vector< pair<pair<ll,ll>,ll> > ss,pp,hh;
map<ll,ll > ta,pa,sa,ma;
map< pair<ll,ll>, ll >se,me;
priority_queue<ll,vector<ll>,greater<ll> > aq,tq,pq,nq,mq,xq;
string st,et,ft,pt,ct;
deque<pair<ll,ll> > de,ne;
set<ll > li,si;

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

int main()
{
    fast;

    //cin>>t;

    while(t--)
    {
        cin>>n;
        f = 0;
        for(i=0; i<n; i++)
        {
            cin>>a>>b;
            if(a!=b)f=1;
            ss.pb({{a,b},i});
        }

        for(i=0; i+1<n; i++)
        {
            if(ss[i].first.second<ss[i+1].first.second && f==0){f=2;break;}
        }
        if(f==1)cout<<"rated"<<endl;
        else if(f==2)cout<<"unrated"<<endl;
        else cout<<"maybe"<<endl;
    }

}


 	 		  						 		 	 	 	   	   		


Comments

Submit
0 Comments
More Questions

235A - LCM Challenge
1075B - Taxi drivers and Lyft
1562A - The Miracle and the Sleeper
1216A - Prefixes
1490C - Sum of Cubes
868A - Bark to Unlock
873B - Balanced Substring
1401D - Maximum Distributed Tree
1716C - Robot in a Hallway
1688B - Patchouli's Magical Talisman
99A - Help Far Away Kingdom
622B - The Time
1688C - Manipulating History
1169D - Good Triple
1675B - Make It Increasing
588A - Duff and Meat
1541B - Pleasant Pairs
1626B - Minor Reduction
1680A - Minimums and Maximums
1713A - Traveling Salesman Problem
1713B - Optimal Reduction
1710A - Color the Picture
1686B - Odd Subarrays
251A - Points on Line
427C - Checkposts
1159A - A pile of stones
508A - Pasha and Pixels
912A - Tricky Alchemy
1249A - Yet Another Dividing into Teams
1713C - Build Permutation