📄 1028.cpp
字号:
/*
5
1 1
5 1
7 1
3 3
5 5
5
1 1
1 2
2 2
3 2
4 2
*/
#include <iostream>
using namespace std;
const int maxN = 32000;
int a[maxN + 1 ], level[maxN + 1];
int max(int a, int b ){ return a > b ? a : b; }
int min(int a, int b ){ return a < b ? a : b; }
int main()
{
int n, i, j,l_sum; //line sum
int x, prex, maxX, y, prey;
memset( level, 0 ,sizeof(level) );
memset( a, 0 ,sizeof(a) );
cin >> n;
l_sum = 0;
cin >> x >> y;
maxX = prex = x, prey = y;
level[0]++;
l_sum++;
a[x]++;
for( i = 2; i <= n; i++ )
{
cin >> x >> y;
if( prey == y )
{
if( x > maxX )
for( j = maxX+1; j <= x; j++ )
a[j] = a[maxX];
for( j = prex+1; j <= min(x,maxX); j++ )
a[j] += l_sum;
}
if( prey != y )
{
if( prex < maxX )
for( j = prex+1; j <= maxX; j++ )
a[j] += l_sum;
if( x > maxX )
for( j = maxX+1; j <= x; j++ )
a[j] = a[maxX];
l_sum = 0;
for( j = 1; j <= x; j++ )
a[j] += l_sum;
}
l_sum++;
level[ a[x] ] ++;
a[x]++;
prex = x;
prey = y;
maxX = max(x,maxX);
/* cout << "line : " ;
for( j = 1 ; j <= maxX; j++ )
cout << a[j] << ' ';
cout << endl;
*/
}
for( i = 0; i <= n-1; i++ )
cout << level[i] << endl;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -