題號不錯,1234.提議很簡單,現在給你幾組數據然後讓你找出開門人和關門人。題目形式看下面的鏈接點擊打開鏈接。其實就是水水的string處理,不過話說string的強度不止這些,過幾天省賽回來寫一個下次用吧。因為string是不管什麼比賽都會出現的所以stl和string等函數就比較受acmer的歡迎。
[cpp] <SPAN style="FONT-SIZE: 18px">#include <iostream>
#include <string>
using namespace std;
int main()
{
int t;
cin >> t;
while(t--)
{
int n;
cin >> n;
string id, start, end;
cin >> id >> start >> end;
string idstart, idend, startmin, endmax;
idstart = id;
idend = id;
startmin = start;
endmax = end;
for(int i = 1; i < n; i++)
{
cin >> id >> start >> end;
if(start < startmin)
{
startmin = start;
idstart = id;
}
if(end > endmax)
{
endmax = end;
idend = id;
}
}
cout << idstart << " " << idend << endl;
}
return 0;
}</SPAN>
#include <iostream>
#include <string>
using namespace std;
int main()
{
int t;
cin >> t;
while(t--)
{
int n;
cin >> n;
string id, start, end;
cin >> id >> start >> end;
string idstart, idend, startmin, endmax;
idstart = id;
idend = id;
startmin = start;
endmax = end;
for(int i = 1; i < n; i++)
{
cin >> id >> start >> end;
if(start < startmin)
{
startmin = start;
idstart = id;
}
if(end > endmax)
{
endmax = end;
idend = id;
}
}
cout << idstart << " " << idend << endl;
}
return 0;
}