#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <climits>
using namespace std;
// Helper function: Convert time in "hh:mmAM/PM" to minutes since midnight
int convertTimeToMinutes
(const string
& time) { if (ampm == "PM" && hours != 12) hours += 12;
if (ampm == "AM" && hours == 12) hours = 0;
return hours * 60 + minutes;
}
// Function to process logs and organize entries and exits
map<int, map<int, pair<vector<int>, vector<int>>>> processLogs(
const vector<tuple<int, string, string, string>>& logs) {
map<int, map<int, pair<vector<int>, vector<int>>>> employeeLogs;
for (const auto
& [employeeID
, action
, location
, time] : logs
) { // Filter only logs with "room" in the location
if (location.find("room") == string::npos) continue;
int roomNumber
= stoi
(location
.substr(4)); // Extract room number int timeInMinutes
= convertTimeToMinutes
(time);
if (action == "enters") {
employeeLogs[employeeID][roomNumber].first.push_back(timeInMinutes);
} else if (action == "exits") {
employeeLogs[employeeID][roomNumber].second.push_back(timeInMinutes);
}
}
// Sort entries and exits for every room
for (auto& [employeeID, rooms] : employeeLogs) {
for (auto& [roomNumber, logs] : rooms) {
sort(logs
.first
.begin
(), logs
.first
.end()); // Sort entries sort(logs
.second
.begin
(), logs
.second
.end()); // Sort exits }
}
return employeeLogs;
}
// Function to calculate work done and consistency
pair<int, bool> calculateWorkDoneAndConsistency(
const map<int, map<int, pair<vector<int>, vector<int>>>>& employeeLogs,
map<int, map<int, int>>& workDonePerRoom, int employeeID) {
int totalWorkDone = 0;
bool isInconsistent = false;
for (const auto& [roomNumber, logs] : employeeLogs.at(employeeID)) {
const auto& entries = logs.first;
const auto& exits = logs.second;
vector<bool> entryUsed(entries.size(), false);
vector<bool> exitUsed(exits.size(), false);
int roomWorkDone = 0;
// Map exits to the nearest prior entry
for (size_t j = 0; j < exits.size(); ++j) {
for (size_t i = 0; i < entries.size(); ++i) {
if (!entryUsed[i] && entries[i] < exits[j]) {
roomWorkDone += exits[j] - entries[i];
entryUsed[i] = true;
exitUsed[j] = true;
break;
}
}
}
// Check if unmatched entries or exits remain
if (any_of
(entryUsed
.begin
(), entryUsed
.end(), [](bool used
) { return !used
; }) || any_of
(exitUsed
.begin
(), exitUsed
.end(), [](bool used
) { return !used
; })) { isInconsistent = true;
}
totalWorkDone += roomWorkDone;
workDonePerRoom[employeeID][roomNumber] = roomWorkDone;
}
return {totalWorkDone, isInconsistent};
}
// Main function
int main() {
int n;
cin >> n;
vector<tuple<int, string, string, string>> logs(n);
for (int i = 0; i < n; ++i) {
int employeeID;
string action
, location
, time; cin
>> employeeID
>> action
>> location
>> time; logs
[i
] = {employeeID
, action
, location
, time}; }
int suspectID;
cin >> suspectID;
// Step 1: Sort logs and organize data
sort(logs
.begin
(), logs
.end(), [](const auto
& a
, const auto
& b
) { if (get<0>(a) != get<0>(b)) return get<0>(a) < get<0>(b);
return get<2>(a) < get<2>(b);
});
auto employeeLogs = processLogs(logs);
// Step 2: Calculate work done and consistency for each employee
map<int, map<int, int>> workDonePerRoom;
map<int, pair<int, bool>> results; // {EmployeeID: {TotalWorkDone, IsInconsistent}}
for (const auto& [employeeID, _] : employeeLogs) {
results[employeeID] = calculateWorkDoneAndConsistency(employeeLogs, workDonePerRoom, employeeID);
}
// Step 3: Print individual employee status
cout << "Employee Status:\n";
for (const auto& [employeeID, result] : results) {
const auto& [totalWorkDone, isInconsistent] = result;
cout << "Employee ID: " << employeeID << "\n";
cout << " Consistency: " << (isInconsistent ? "Inconsistent" : "Consistent") << "\n";
cout << " Total Work Done: " << totalWorkDone << " minutes\n";
cout << " Work Done by Room:\n";
for (const auto& [room, work] : workDonePerRoom[employeeID]) {
cout << " room" << room << ": " << work << " minutes\n";
}
cout << "\n";
}
// Step 4: Determine result for suspect
bool suspectInconsistent = results[suspectID].second;
int suspectWork = results[suspectID].first;
int leastWork = INT_MAX;
bool otherInconsistentWithLessWork = false;
for (const auto& [employeeID, result] : results) {
const auto& [workDone, isInconsistent] = result;
if (workDone < leastWork) leastWork = workDone;
if (employeeID != suspectID && isInconsistent && workDone < suspectWork) {
otherInconsistentWithLessWork = true;
}
}
if (suspectInconsistent || otherInconsistentWithLessWork) {
cout << "Cannot be determined\n";
} else if (suspectWork == leastWork) {
cout << "Yes\n";
} else {
cout << "No\n";
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8bWFwPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8c3N0cmVhbT4KI2luY2x1ZGUgPGlvbWFuaXA+CiNpbmNsdWRlIDxjbGltaXRzPgoKdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCi8vIEhlbHBlciBmdW5jdGlvbjogQ29udmVydCB0aW1lIGluICJoaDptbUFNL1BNIiB0byBtaW51dGVzIHNpbmNlIG1pZG5pZ2h0CmludCBjb252ZXJ0VGltZVRvTWludXRlcyhjb25zdCBzdHJpbmcmIHRpbWUpIHsKICAgIGludCBob3VycyA9IHN0b2kodGltZS5zdWJzdHIoMCwgdGltZS5maW5kKCc6JykpKTsKICAgIGludCBtaW51dGVzID0gc3RvaSh0aW1lLnN1YnN0cih0aW1lLmZpbmQoJzonKSArIDEsIDIpKTsKICAgIHN0cmluZyBhbXBtID0gdGltZS5zdWJzdHIodGltZS5zaXplKCkgLSAyKTsKICAgIGlmIChhbXBtID09ICJQTSIgJiYgaG91cnMgIT0gMTIpIGhvdXJzICs9IDEyOwogICAgaWYgKGFtcG0gPT0gIkFNIiAmJiBob3VycyA9PSAxMikgaG91cnMgPSAwOwogICAgcmV0dXJuIGhvdXJzICogNjAgKyBtaW51dGVzOwp9CgovLyBGdW5jdGlvbiB0byBwcm9jZXNzIGxvZ3MgYW5kIG9yZ2FuaXplIGVudHJpZXMgYW5kIGV4aXRzCm1hcDxpbnQsIG1hcDxpbnQsIHBhaXI8dmVjdG9yPGludD4sIHZlY3RvcjxpbnQ+Pj4+IHByb2Nlc3NMb2dzKAogICAgY29uc3QgdmVjdG9yPHR1cGxlP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bnRyeQogICAgICAgIGZvciAoc2l6ZV90IGogPSAwOyBqIDwgZXhpdHMuc2l6ZSgpOyArK2opIHsKICAgICAgICAgICAgZm9yIChzaXplX3QgaSA9IDA7IGkgPCBlbnRyaWVzLnNpemUoKTsgKytpKSB7CiAgICAgICAgICAgICAgICBpZiAoIWVudHJ5VXNlZFtpXSAmJiBlbnRyaWVzW2ldIDwgZXhpdHNbal0pIHsKICAgICAgICAgICAgICAgICAgICByb29tV29ya0RvbmUgKz0gZXhpdHNbal0gLSBlbnRyaWVzW2ldOwogICAgICAgICAgICAgICAgICAgIGVudHJ5VXNlZFtpXSA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgZXhpdFVzZWRbal0gPSB0cnVlOwogICAgICAgICAgICAgICAgICAgIGJyZWFrOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICAvLyBDaGVjayBpZiB1bm1hdGNoZWQgZW50cmllcyBvciBleGl0cyByZW1haW4KICAgICAgICBpZiAoYW55X29mKGVudHJ5VXNlZC5iZWdpbigpLCBlbnRyeVVzZWQuZW5kKCksIFtdKGJvb2wgdXNlZCkgeyByZXR1cm4gIXVzZWQ7IH0pIHx8CiAgICAgICAgICAgIGFueV9vZihleGl0VXNlZC5iZWdpbigpLCBleGl0VXNlZC5lbmQoKSwgW10oYm9vbCB1c2VkKSB7IHJldHVybiAhdXNlZDsgfSkpIHsKICAgICAgICAgICAgaXNJbmNvbnNpc3RlbnQgPSB0cnVlOwogICAgICAgIH0KCiAgICAgICAgdG90YWxXb3JrRG9uZSArPSByb29tV29ya0RvbmU7CiAgICAgICAgd29ya0RvbmVQZXJSb29tW2VtcGxveWVlSURdW3Jvb21OdW1iZXJdID0gcm9vbVdvcmtEb25lOwogICAgfQoKICAgIHJldHVybiB7dG90YWxXb3JrRG9uZSwgaXNJbmNvbnNpc3RlbnR9Owp9CgovLyBNYWluIGZ1bmN0aW9uCmludCBtYWluKCkgewogICAgaW50IG47CiA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wZWN0CiAgICBib29sIHN1c3BlY3RJbmNvbnNpc3RlbnQgPSByZXN1bHRzW3N1c3BlY3RJRF0uc2Vjb25kOwogICAgaW50IHN1c3BlY3RXb3JrID0gcmVzdWx0c1tzdXNwZWN0SURdLmZpcnN0OwogICAgaW50IGxlYXN0V29yayA9IElOVF9NQVg7CiAgICBib29sIG90aGVySW5jb25zaXN0ZW50V2l0aExlc3NXb3JrID0gZmFsc2U7CgogICAgZm9yIChjb25zdCBhdXRvJiBbZW1wbG95ZWVJRCwgcmVzdWx0XSA6IHJlc3VsdHMpIHsKICAgICAgICBjb25zdCBhdXRvJiBbd29ya0RvbmUsIGlzSW5jb25zaXN0ZW50XSA9IHJlc3VsdDsKICAgICAgICBpZiAod29ya0RvbmUgPCBsZWFzdFdvcmspIGxlYXN0V29yayA9IHdvcmtEb25lOwogICAgICAgIGlmIChlbXBsb3llZUlEICE9IHN1c3BlY3RJRCAmJiBpc0luY29uc2lzdGVudCAmJiB3b3JrRG9uZSA8IHN1c3BlY3RXb3JrKSB7CiAgICAgICAgICAgIG90aGVySW5jb25zaXN0ZW50V2l0aExlc3NXb3JrID0gdHJ1ZTsKICAgICAgICB9CiAgICB9CgogICAgaWYgKHN1c3BlY3RJbmNvbnNpc3RlbnQgfHwgb3RoZXJJbmNvbnNpc3RlbnRXaXRoTGVzc1dvcmspIHsKICAgICAgICBjb3V0IDw8ICJDYW5ub3QgYmUgZGV0ZXJtaW5lZFxuIjsKICAgIH0gZWxzZSBpZiAoc3VzcGVjdFdvcmsgPT0gbGVhc3RXb3JrKSB7CiAgICAgICAgY291dCA8PCAiWWVzXG4iOwogICAgfSBlbHNlIHsKICAgICAgICBjb3V0IDw8ICJOb1xuIjsKICAgIH0KCiAgICByZXR1cm4gMDsKfQo=
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <algorithm>
#include <sstream>
#include <iomanip>
#include <climits>
using namespace std;
// Helper function: Convert time in "hh:mmAM/PM" to minutes since midnight
int convertTimeToMinutes(const string& time) {
int hours = stoi(time.substr(0, time.find(':')));
int minutes = stoi(time.substr(time.find(':') + 1, 2));
string ampm = time.substr(time.size() - 2);
if (ampm == "PM" && hours != 12) hours += 12;
if (ampm == "AM" && hours == 12) hours = 0;
return hours * 60 + minutes;
}
// Function to process logs and organize entries and exits
map<int, map<int, pair<vector<int>, vector<int>>>> processLogs(
const vector<tuple<int, string, string, string>>& logs) {
map<int, map<int, pair<vector<int>, vector<int>>>> employeeLogs;
for (const auto& [employeeID, action, location, time] : logs) {
// Filter only logs with "room" in the location
if (location.find("room") == string::npos) continue;
int roomNumber = stoi(location.substr(4)); // Extract room number
int timeInMinutes = convertTimeToMinutes(time);
if (action == "enters") {
employeeLogs[employeeID][roomNumber].first.push_back(timeInMinutes);
} else if (action == "exits") {
employeeLogs[employeeID][roomNumber].second.push_back(timeInMinutes);
}
}
// Sort entries and exits for every room
for (auto& [employeeID, rooms] : employeeLogs) {
for (auto& [roomNumber, logs] : rooms) {
sort(logs.first.begin(), logs.first.end()); // Sort entries
sort(logs.second.begin(), logs.second.end()); // Sort exits
}
}
return employeeLogs;
}
// Function to calculate work done and consistency
pair<int, bool> calculateWorkDoneAndConsistency(
const map<int, map<int, pair<vector<int>, vector<int>>>>& employeeLogs,
map<int, map<int, int>>& workDonePerRoom, int employeeID) {
int totalWorkDone = 0;
bool isInconsistent = false;
for (const auto& [roomNumber, logs] : employeeLogs.at(employeeID)) {
const auto& entries = logs.first;
const auto& exits = logs.second;
vector<bool> entryUsed(entries.size(), false);
vector<bool> exitUsed(exits.size(), false);
int roomWorkDone = 0;
// Map exits to the nearest prior entry
for (size_t j = 0; j < exits.size(); ++j) {
for (size_t i = 0; i < entries.size(); ++i) {
if (!entryUsed[i] && entries[i] < exits[j]) {
roomWorkDone += exits[j] - entries[i];
entryUsed[i] = true;
exitUsed[j] = true;
break;
}
}
}
// Check if unmatched entries or exits remain
if (any_of(entryUsed.begin(), entryUsed.end(), [](bool used) { return !used; }) ||
any_of(exitUsed.begin(), exitUsed.end(), [](bool used) { return !used; })) {
isInconsistent = true;
}
totalWorkDone += roomWorkDone;
workDonePerRoom[employeeID][roomNumber] = roomWorkDone;
}
return {totalWorkDone, isInconsistent};
}
// Main function
int main() {
int n;
cin >> n;
vector<tuple<int, string, string, string>> logs(n);
for (int i = 0; i < n; ++i) {
int employeeID;
string action, location, time;
cin >> employeeID >> action >> location >> time;
logs[i] = {employeeID, action, location, time};
}
int suspectID;
cin >> suspectID;
// Step 1: Sort logs and organize data
sort(logs.begin(), logs.end(), [](const auto& a, const auto& b) {
if (get<0>(a) != get<0>(b)) return get<0>(a) < get<0>(b);
return get<2>(a) < get<2>(b);
});
auto employeeLogs = processLogs(logs);
// Step 2: Calculate work done and consistency for each employee
map<int, map<int, int>> workDonePerRoom;
map<int, pair<int, bool>> results; // {EmployeeID: {TotalWorkDone, IsInconsistent}}
for (const auto& [employeeID, _] : employeeLogs) {
results[employeeID] = calculateWorkDoneAndConsistency(employeeLogs, workDonePerRoom, employeeID);
}
// Step 3: Print individual employee status
cout << "Employee Status:\n";
for (const auto& [employeeID, result] : results) {
const auto& [totalWorkDone, isInconsistent] = result;
cout << "Employee ID: " << employeeID << "\n";
cout << " Consistency: " << (isInconsistent ? "Inconsistent" : "Consistent") << "\n";
cout << " Total Work Done: " << totalWorkDone << " minutes\n";
cout << " Work Done by Room:\n";
for (const auto& [room, work] : workDonePerRoom[employeeID]) {
cout << " room" << room << ": " << work << " minutes\n";
}
cout << "\n";
}
// Step 4: Determine result for suspect
bool suspectInconsistent = results[suspectID].second;
int suspectWork = results[suspectID].first;
int leastWork = INT_MAX;
bool otherInconsistentWithLessWork = false;
for (const auto& [employeeID, result] : results) {
const auto& [workDone, isInconsistent] = result;
if (workDone < leastWork) leastWork = workDone;
if (employeeID != suspectID && isInconsistent && workDone < suspectWork) {
otherInconsistentWithLessWork = true;
}
}
if (suspectInconsistent || otherInconsistentWithLessWork) {
cout << "Cannot be determined\n";
} else if (suspectWork == leastWork) {
cout << "Yes\n";
} else {
cout << "No\n";
}
return 0;
}