Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
- #define ll long long
- #define ld double
- #define llu long long unsigned
- int main()
- {
- fast;
- int tt;
- cin>>tt;
- for( int i = 1 ; i <= tt ; i++ )
- {
- int n;
- cin>>n;
- vector < string > a;
- vector < string > b;
- vector < string > c;
- vector < string > d;
- while( n-- )
- {
- string s;
- cin>>s;
- if( s[0] == 'A' or s[0] == 'a' )
- a.push_back( s );
- if( s[0] == 'B' or s[0] == 'b' )
- b.push_back( s );
- if( s[0] == 'C' or s[0] == 'c' )
- c.push_back( s );
- if( s[0] == 'D' or s[0] == 'd' )
- d.push_back( s );
- }
- sort( a.begin() , a.end() );
- sort( b.begin() , b.end() );
- sort( c.begin() , c.end() );
- sort( d.begin() , d.end() );
- for( int i = 0 ; i < a.size() ; i++ )
- cout<<a[i]<<endl;
- for( int i = 0 ; i < b.size() ; i++ )
- cout<<b[i]<<endl;
- for( int i = 0 ; i < c.size() ; i++ )
- cout<<c[i]<<endl;
- for( int i = 0 ; i < d.size() ; i++ )
- cout<<d[i]<<endl;
- cin>>n;
- for( int i = 0 ; i <= n ; i++ )
- {
- string s;
- // getchar();
- getline( cin , s );
- if( !i )
- continue;
- // cout<<s<<endl;
- if( s[0] == 'A' and a.size() )
- {
- cout<<a[0]<<endl;
- a.erase( a.begin() );
- }
- else if( s[0] == 'B' and b.size() )
- {
- cout<<b[0]<<endl;
- b.erase( b.begin() );
- }
- else if( s[0] == 'C' and c.size() )
- {
- cout<<c[0]<<endl;
- c.erase( c.begin() );
- }
- else if( s[0] == 'D' and d.size() )
- {
- cout<<d[0]<<endl;
- d.erase( d.begin() );
- }
- else
- cout<<"Already Mastered"<<endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement