Advertisement
Shiam7777777

Untitled

Apr 14th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.21 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  4. #define ll long long
  5. #define ld double
  6. #define llu long long unsigned
  7.  
  8. int main()
  9. {
  10.     fast;
  11.     int tt;
  12.     cin>>tt;
  13.     for( int i = 1 ; i <= tt ; i++ )
  14.     {
  15.         int n;
  16.         cin>>n;
  17.         vector < string > a;
  18.         vector < string > b;
  19.         vector < string > c;
  20.         vector < string > d;
  21.         while( n-- )
  22.         {
  23.             string s;
  24.             cin>>s;
  25.             if( s[0] == 'A' or s[0] == 'a' )
  26.                 a.push_back( s );
  27.             if( s[0] == 'B' or s[0] == 'b' )
  28.                 b.push_back( s );
  29.             if( s[0] == 'C' or s[0] == 'c' )
  30.                 c.push_back( s );
  31.             if( s[0] == 'D' or s[0] == 'd' )
  32.                 d.push_back( s );
  33.         }
  34.         sort( a.begin() , a.end() );
  35.         sort( b.begin() , b.end() );
  36.         sort( c.begin() , c.end() );
  37.         sort( d.begin() , d.end() );
  38.         for( int i = 0 ; i < a.size() ; i++ )
  39.             cout<<a[i]<<endl;
  40.         for( int i = 0 ; i < b.size() ; i++ )
  41.             cout<<b[i]<<endl;
  42.         for( int i = 0 ; i < c.size() ; i++ )
  43.             cout<<c[i]<<endl;
  44.         for( int i = 0 ; i < d.size() ; i++ )
  45.             cout<<d[i]<<endl;
  46.         cin>>n;
  47.         for( int  i = 0 ; i <= n ; i++ )
  48.         {
  49.             string s;
  50. //            getchar();
  51.             getline( cin , s );
  52.             if( !i )
  53.                 continue;
  54. //            cout<<s<<endl;
  55.             if( s[0] == 'A' and a.size() )
  56.             {
  57.                 cout<<a[0]<<endl;
  58.                 a.erase( a.begin() );
  59.             }
  60.             else if( s[0] == 'B' and b.size() )
  61.             {
  62.                 cout<<b[0]<<endl;
  63.                 b.erase( b.begin() );
  64.             }
  65.             else if( s[0] == 'C' and c.size() )
  66.             {
  67.                 cout<<c[0]<<endl;
  68.                 c.erase( c.begin() );
  69.             }
  70.             else if( s[0] == 'D' and d.size() )
  71.             {
  72.                 cout<<d[0]<<endl;
  73.                 d.erase( d.begin() );
  74.             }
  75.             else
  76.                 cout<<"Already Mastered"<<endl;
  77.         }
  78.     }
  79.     return 0;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement