| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
H2O#include <stdio.h>
int has[30][30];
int mxx,mxy,cnt;
int solve(){
int res = 0;
while(cnt>0){
int pos = 1;
for(int i = 1; i <= mxx; i++){
int mxPos = 0;
for(int j = mxy; j >= pos; j--){
if(has[i][j]){
mxPos = j;
break;
}
}
if(mxPos == 0) continue;
for(int j = pos; j <= mxPos; j++){
if(has[i][j]){
has[i][j] = 0;
cnt--;
}
}
pos = mxPos;
}
res++;
}
return res;
}
int main(int argc, char **argv){
while(1){
int a,b,c,d;
mxx=0,mxy=0,cnt=0;
scanf("%d%d",&a,&b);
if(a==-1) break;
for(int i = 1; i < 30; i++){
for(int j = 1; j < 30; j++){
has[i][j] = 0;
}
}
while(1){
scanf("%d%d",&c,&d);
has[a][b] = 1;
cnt++;
if(a>mxx) mxx=a;
if(b>mxy) mxy=b;
if(!c) break;
a=c; b=d;
}
printf("%d\n", solve());
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator