hdu 1541 简单题

简单题,直接贴代码

/*
* hdu1541/win.cpp
* Created on: 2011-11-14
* Author : ben
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <functional>
#include <numeric>
#include <cctype>
using namespace std;
const int MAXN = 15100;
const int MAXM = 32100;
typedef struct {
int x;
int y;
} MyPoint;
MyPoint points[MAXN];
int endindex[MAXM];
int tongji[MAXN];
int main() {
#ifndef ONLINE_JUDGE
freopen("data.in", "r", stdin);
#endif
int N, lasty, ans;
while (scanf("%d", &N) == 1) {
scanf("%d%d", &points[0].x, &points[0].y);
lasty = points[0].y;
for (int i = 1; i < N; i++) {
scanf("%d%d", &points[i].x, &points[i].y);
if (points[i].y != lasty) {
endindex[lasty] = i - 1;
}
lasty = points[i].y;
}
endindex[points[N - 1].y] = N - 1;
memset(tongji, 0, sizeof(tongji));
for (int i = 0; i < N; i++) {
ans = 0;
for (int j = 0; j <= endindex[points[i].y];
j++) {
if (j != i && points[j].x <= points[i].x) {
ans++;
}
}
tongji[ans]++;
}
for (int i = 0; i < N; i++) {
printf("%d\n", tongji[i]);
}
}
return 0;
}



原文地址:https://www.cnblogs.com/moonbay/p/2248196.html