Professional Documents
Culture Documents
My Sollution 3
My Sollution 3
#include <string>
#include <vector>
class Time {
public:
Time() : m_hour(0), m_minute(0) {}
Time(int hour, int minute) : m_hour(hour), m_minute(minute) {}
private:
int m_hour;
int m_minute;
};
int main()
{
char ferryHarbor = 'L';
int capacity;
cin >> capacity;
vector<string> cars;
vector<string>carsL;
vector<string>carsR;
cars.resize(1);
carsL.resize(1);
carsR.resize(1);
int counter = 0;
int counterL = 0;
int counterR = 0;
int writeL = 0;
int writeR = 0;
string present_time;
vector <string> results;
results.resize(1);
unsigned int counter_result = 0;
cin.ignore();
while (true)
{
if (cin.eof())
{
if (ferryHarbor == 'L' && counterL >= capacity + writeL)
{
int tmp;
if (writeL == 0)
{
Time time(stoi(carsL[writeL + capacity - 1].substr(2, 2)),
stoi(carsL[writeL + capacity - 1].substr(5, 2)));
present_time = time.toString();
}
present_time = newTime.toString();
writeL = tmp + 1;
ferryHarbor = 'P';
}
if (ferryHarbor == 'P' && counterR >= capacity + writeR)
{
int tmp;
break;
}
else {
getline(cin, cars[counter]);
}
if (cars[counter].substr(0, 1) == "L")
{
carsL[counterL] = cars[counter];
counterL++;
carsL.resize(counterL + 1);
}
else if (cars[counter].substr(0, 1) == "P")
{
carsR[counterR] = cars[counter];
counterR++;
carsR.resize(counterR + 1);
}
if (writeL == 0)
{
Time time(stoi(carsL[writeL + capacity - 1].substr(2, 2)),
stoi(carsL[writeL + capacity - 1].substr(5, 2)));
present_time = time.toString();
}
present_time = newTime.toString();
writeL = tmp + 1;
ferryHarbor = 'P';
}
if (ferryHarbor == 'P' && counterR >= capacity + writeR)
{
int tmp;
return 0;
}