yicongli

Gym 313459B

Jan 24th, 2021
558
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define gc c=getchar()
  6. #define r(x) read(x)
  7. #define ll long long
  8.  
  9. template<typename T>
  10. inline void read(T&x){
  11.     x=0;T k=1;char gc;
  12.     while(!isdigit(c)){if(c=='-')k=-1;gc;}
  13.     while(isdigit(c)){x=x*10+c-'0';gc;}x*=k;
  14. }
  15.  
  16. int cnt[10];
  17. int pointer[10];
  18. int a[10][10];
  19. vector<int>tmp;
  20.  
  21. int main(){
  22.     // freopen(".in","r",stdin);
  23.     // freopen(".out","w",stdout);
  24.     int n;r(n);
  25.     for(int i=0;i<n;++i){
  26.         r(cnt[i]);
  27.         for(int j=0;j<cnt[i];++j){
  28.             r(a[i][j]);
  29.             tmp.push_back(a[i][j]);
  30.         }
  31.     }
  32.     sort(tmp.begin(),tmp.end());
  33.     for(int i=0;i<tmp.size();++i){
  34.         for(int j=0;j<n;++j){
  35.             if(a[j][pointer[j]]==tmp[i]){
  36.                 ++pointer[j];
  37.                 putchar('A'+j);
  38.                 break;
  39.             }
  40.         }
  41.     }
  42.     puts("");
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment