All pastes #281156 Raw Edit

Someone

public text v1 · immutable
#281156 ·published 2006-12-16 15:18 UTC
rendered paste body
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

#define REP(i, a, b) for(int i=a; i<b; i++)

using namespace std;
long tab[100005][6];
vector<long>num;
long n, k,a,e,q,ile;
int t;
bool change;

inline bool comp(long a,long b)
{
     REP(i,0,6){
     if(tab[a][i]<tab[b][i])return 1;
     else if(tab[b][i]<tab[a][i])return 0;
     }
     return 0;
}
     
int main()
{
    scanf("%d", &t);
    
while(t--)
{
          ile = 0;
          
        scanf("%ld",&n);
        
        REP(i,0,n)
        REP(j,0,6) scanf("%ld", &tab[i][j]);
        
        REP(i,0,n)num.push_back(i);
        
        sort(num.begin(), num.end(), comp);
          
        REP(i,0,n) 
             {
                   change = false;
                   k = 1;
                              
                   while(!change)              
                     {
                   if(i==n-1)break;
                   REP(j,0,6)if(tab[num[i]][j]!=tab[num[i+1]][j]){change = true; break;}
                     if(!change){
                                                  k++;
                                                  i++;
                                }
                     }
                   e = num[i];
                   printf("%02ld ", tab[e][0]);
                   printf("%08ld ", tab[e][1]);
                   printf("%04ld ", tab[e][2]);
                   printf("%04ld ", tab[e][3]);
                   printf("%04ld ", tab[e][4]);
                   printf("%04ld ", tab[e][5]);
                   
                   printf("%ld\n", k);
             }
        
        printf("\n");
        num.clear();
}
return 0;
}