Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 0ms AC，附代码

Posted by taesimple at 2011-08-01 21:42:16 on Problem 2419

#include <stdio.h>
#include <math.h>
unsigned long long a[100] = {0};
unsigned long long b[100] = {0};
void bubble_sort(int n){
for(int i = 0; i < n; i++){
for(int j = n-1; j > i; j--){
if(b[j] < b[j-1] || (b[j] == b[j-1] && a[j] < a[j-1])){
unsigned long long tmp1 = b[j];
b[j] = b[j-1];
b[j-1] = tmp1;
unsigned long long tmp2 = a[j];
a[j] = a[j-1];
a[j-1] = tmp2;
}
}
}
}
int main(){
int p, t;
int i, k;  //i是人编号，k是树编号
scanf("%d%d", &p, &t);
while(scanf("%d%d", &i, &k) != EOF){
if(k <= 50)  //因为有重复说的，所以这里只能用|=而不能用+=
a[i-1] |= (unsigned long long)pow(2, k-1);
else
b[i-1] |= (unsigned long long)pow(2, k-50-1);
}
bubble_sort(p);
int cnt = 1;
for(int i = 1; i < p; i++)
if(a[i] != a[i-1] || b[i] != b[i-1])
cnt++;
printf("%d\n", cnt);
return 0;
}

Followed by: