#include<iostream>
#define N 20;
int a[501][3];
using namespace std;
void swap(int a, int b)
{
int temp = a;
a = b;
b = temp;
}
int main()
{
freopen("input.txt","r",stdin);
int n,T ;
cin >> T;
for(int tc = 1; tc<=T; tc++)
{
cin >> n;
for(int i = 0; i < n; i++)
{
for(int j = 0; j <3; j++)
{
cin >> a[i][j];
//cout << a[i][j] << " ";
}
//cout << endl;
}
for(int i = 0; i< n-1; i++)
{
for(int j = i+1; j < n; j++)
if(a[j][2] < a[i][2])
{
int t1 = a[j][1];
a[j][1] = a[i][1];
a[i][1] = t1;
int t2 = a[j][2];
a[j][2] = a[i][2];
a[i][2] = t2;
}
}
int kq=1;
int t = a[0][2];
for(int i = 1; i < n; i++)
{
if(a[i][1]>=t)
{
kq++;
t = a[i][2];
}
}
cout <<"Case #"<<tc<<endl<< kq<<endl;
}
return 0;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.