Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define fst first
- #define snd second
- #define all(x) (x).begin(), (x).end()
- #define rall(x) (x).rbegin(), (x).rend()
- #define clr(a, v) memset( a , v , sizeof(a) )
- #define pb push_back
- #define mp make_pair
- #define sz size()
- #define FORN( i , s , n ) for( int i = (s) ; i < (n) ; i++ )
- #define FOR( i , n ) FORN( i , 0 , n )
- #define FORIT( i , x ) for( typeof x.begin() i = x.begin() ; i != x.end() ; i++ )
- #define trace(x) cout << #x << ": " << x << endl;
- #define trace2(x, y) cout << #x << ": " << x << " | " << #y << ": " << y << endl;
- #define trace3(x, y, z) cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
- #define read ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
- using namespace std;
- typedef long long int64;
- typedef vector <int> vi;
- typedef pair <int,int> ii;
- typedef vector <string> vs;
- typedef vector <ii> vii;
- int64 cont[20][20];
- int64 val [20];
- int64 ans [100005];
- int main(){
- int64 T,a,b;
- cin>>T;
- while(T--){
- int64 n,M;
- cin>>n>>M;
- clr(val,0);
- clr(cont,0);
- clr(ans,0);
- FOR(i,n){
- // 1<= a,b <= 16
- cin>>a>>b;
- cont[b][a]++;
- val [b]++;
- }
- int64 acm = 0;
- FORN(i,1,17) {cont[i][0] = 1; acm+=val[i];}
- FOR(k,M){
- ans[acm]++;
- FORN(i,1,17){
- if( cont[i][cont[i][0]]>0 ) acm-=cont[i][cont[i][0]];
- cont[i][0]++;
- if( cont[i][0]>i ) {acm+=val[i]; cont[i][0] = 1;}
- }
- }
- FOR(i,n+1) cout<<ans[i]<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement