ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1112. Cover

Posted by King Without Kingdom 6 Feb 2002 23:22
#include<iostream.h>
int n;
int nal[100];
int mass[100][2];
int del();
void main(){
cin >> n;
int j;
for(int i=0;i<n;i++)
nal[i]=0;
for(i=0;i<n;i++)
{
cin >> mass[i][0];
cin >> mass[i][1];
if(mass[i][1]<mass[i][0])
{
int t=mass[i][1];
mass[i][1]=mass[i][0];
mass[i][0]=t;
}
}
for(i=0;i<n-1;i++)
for(j=0;j<n-1;j++)
if(mass[j][0]>mass[j+1][0])
{
int t1=mass[j][0];
int t2=mass[j][1];
mass[j][0]=mass[j+1][0];
mass[j][1]=mass[j+1][1];
mass[j+1][0]=t1;
mass[j+1][1]=t2;
}
while(del());
j=0;
for(i=0;i<n;i++)
if(nal[i]==0)
j++;
cout << j<<"\n";
for(i=0;i<n;i++)
if(nal[i]==0)
cout<<mass[i][0]<<" "<<mass[i][1]<<"\n";
}
int del(){
int quan=0;
int nquan;
int thr;
for(int i=0;i<n;i++)
if(nal[i]==0)
{
nquan=0;
for(int j=0;j<n;j++)
if((nal[j]==0)&&(j!=i))
if(((mass[j][0]>=mass
[i][0])&&(mass[j][0]<mass[i][1]))
||((mass[j][1]>mass[i]
[0])&&(mass[j][1]<=mass[i][1]))
||((mass[j][0]<=mass
[i][0])&&(mass[j][1]>=mass[i][1])))
nquan++;
if(nquan>quan)
{
quan=nquan;
thr=i;
}
}
if(quan!=0)
{
nal[thr]=1;
return 1;
}
return 0;
}

Sorry now i know where is my error
Posted by King Without Kingdom 1 Mar 2002 19:14