?? 1062.cpp
字號:
#include<iostream>
#include<stdlib.h>
#include<fstream>
#include<sstream>
#include<string>
#include<time.h>
using namespace std;
string a[1001];
string b[1001];
string c[1001];
int n;
bool com(string &a,string &b)
{
int flag;
for(int i=0;i<a.size();i++){
if(a[i]==':'){
flag=i;
break;
}
}
/* for(int i=0;i<flag;i++){
a1[i]=a[i];
b1[i]=b[i];
}*/
string a1(a,0,flag),b1(b,0,flag);
if(atoi(a1.c_str())>atoi(b1.c_str()))
return true;
else if(atoi(a1.c_str()) <atoi(b1.c_str()))
return false;
else{
string a2(a,flag+1,a.size());
string b2(b,flag+1,b.size());
if(atoi(a2.c_str())>=atoi(b2.c_str()))
return true;
else
return false;
}
}
int partition(int low, int high) {
string t1=a[low];
string t2=b[low];
string t3=c[low];
string pivotkey=b[low];
while(low < high){
while(low < high && com(b[high],pivotkey))
--high;
b[low]=b[high];
a[low]=a[high];
c[low]=c[high];
while(low < high && !com(b[low],pivotkey))
++low;
b[high]=b[low];
a[high]=a[low];
c[high]=c[low];
}
a[low]=t1;
b[low]=t2;
c[low]=t3;
return low;
}
int randompartition(int low, int high) {
srand((unsigned)time(NULL));
int i=low+rand()%(high-low+1);
string j=a[i];
a[i]=a[low];
a[low]=j;
return partition(low,high);
}
void sort(int low, int high) {
if(low < high){
int pivotloc=partition(low,high);
sort(low,pivotloc-1);
sort(pivotloc+1,high);
}
}
int main()
{
string result,line;
int sum=1;
ifstream in("1061.txt");
getline(in,line);
istringstream stream(line);
stream >> n;
int i=1;
while(getline(in,line)){
istringstream stream(line);
stream >> a[i];
stream >> c[i];
stream >> b[i++];
}
/* cin >>n;
for(int i=1;i<n+1;i++){
cin >>a[i];
cin >>c[i];
cin >>b[i];
}*/
sort(1,n);
int j=1;
result=a[1]+" ";
b[n]="24:60";
for(int i=2;i<n+1;i++){
// cout <<c[i] << " " << b[j] << endl;
if(com(c[i],b[j])){
sum++;
result+=a[i]+" ";
j=i;
}
}
cout << sum << endl;
string s(result,0,result.size()-1);
cout << s << endl;
// system("pause");
return 0;
}
/* ifstream in("1061.txt");
getline(in,line);
istringstream stream(line);
stream >> n;
int i=0;
while(getline(in,line)){
istringstream stream(line);
stream >> a[i];
stream >> c[i];
stream >> b[i++];
}*/
/* for(int i=0;i<n;i++ ){
cout << a[i] << " " <<c[i] << " " << b[i] << endl;
}*/
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -