Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.67 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define fst first
  4. #define snd second
  5. #define all(x) (x).begin(), (x).end()
  6. #define rall(x) (x).rbegin(), (x).rend()
  7. #define clr(a, v) memset( a , v , sizeof(a) )
  8. #define pb push_back
  9. #define mp make_pair
  10. #define sz size()
  11. #define FORN( i , s , n ) for( int i = (s) ; i < (n) ; i++ )
  12. #define FOR( i , n ) FORN( i , 0 , n )
  13. #define FORIT( i , x ) for( typeof x.begin() i = x.begin() ; i != x.end() ; i++ )
  14. #define trace(x)    cout << #x << ": " << x << endl;
  15. #define trace2(x, y) cout << #x << ": " << x << " | " << #y << ": " << y << endl;
  16. #define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
  17. #define read ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  18.  
  19. using namespace std;
  20.  
  21. typedef long long int64;
  22. typedef vector <int> vi;
  23. typedef pair <int,int> ii;
  24. typedef vector <string> vs;
  25. typedef vector <ii> vii;
  26.  
  27. int64 cont[20][20];
  28. int64 val [20];
  29. int64 ans [100005];
  30.  
  31. int main(){
  32.     int64 T,a,b;
  33.     cin>>T;
  34.     while(T--){
  35.         int64 n,M;
  36.         cin>>n>>M;
  37.         clr(val,0);
  38.         clr(cont,0);
  39.         clr(ans,0);
  40.         FOR(i,n){
  41.             // 1<= a,b <= 16
  42.             cin>>a>>b;
  43.             cont[b][a]++;
  44.             val [b]++;
  45.         }
  46.         int64 acm = 0;
  47.  
  48.         FORN(i,1,17) {cont[i][0] = 1; acm+=val[i];}
  49.  
  50.         FOR(k,M){
  51.             ans[acm]++;
  52.             FORN(i,1,17){
  53.                 if( cont[i][cont[i][0]]>0 ) acm-=cont[i][cont[i][0]];
  54.                 cont[i][0]++;
  55.                 if( cont[i][0]>i ) {acm+=val[i]; cont[i][0] = 1;}
  56.             }
  57.         }
  58.         FOR(i,n+1) cout<<ans[i]<<endl;
  59.     }
  60.     return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement