单纯为了纪念一下自己写了半天发现读错了题,重新写
写了半天又发现读的还是错的,重新写
心态爆炸,磨磨唧唧一年凑出来的垃圾代码,还好是直接过了,要不然砸电脑了兄弟
题目还是很简单的,读懂了题直接模拟就行。
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <iomanip>
#include <string>
#include <list>
#include <cstdlib>
#include <memory>
#include <cstring>
#include <sstream>
#include <list>
#include <deque>
#include <bitset>
#include <vector>
using namespace std;
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
#define FRER() freopen("input.txt" , "r" , stdin);
#define FREW() freopen("output.txt" , "w" , stdout);
#define QIO ios::sync_with_stdio(false)
#define mem(a, b) memset(a , b , sizeof(a))
#define lson rt << 1, l, mid
#define rson rt << 1|1, mid + 1, r
const double PI = acos(-1);
typedef long long ll;
typedef unsigned long long ull;
const double eps = 1e-3;
const int MOD = 1000000007;
const int maxn = 1e5+100;
struct Node{
string name;
int time , op , idx;
};
bool cmp1(Node& a , Node&b){
return a.name==b.name ? a.time<b.time : a.name<b.name;
}
bool cmp2(Node&a , Node&b){
return a.time==b.time ? a.name > b.name : a.time < b.time;
}
vector<Node> node;
vector<Node> opseq;
int cnt[maxn];
map<string,int> id;
vector<string> res;
int intime[maxn];
//struct Node2{
// int idx , cnt;
//};
vector<pair<int,int> > out;
int main()
{
if (fopen("input.txt", "r") != NULL)
{
freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
}
QIO;
int n , k ;
cin >> n >> k;
for(int i = 0 ; i < n ; i++){
string name , op;
int h , m , s;
char c;
cin >> name >> h >> c >> m >> c >> s >> op;
node.push_back((Node){name,h*60*60+m*60+s,(op=="in"?1:-1) , -1});
}
sort(node.begin() ,node.end(),cmp1);
// for(auto it: node)
// cout << it.name << " " << it.time << " " << it.op << endl;
// cout << "=============================" << endl;
for(int i = 0 ; i < node.size()-1 ; i++){
if(node[i].name == node[i+1].name && node[i].op == 1 && node[i+1].op == -1){
opseq.push_back(node[i]);
opseq.push_back(node[i+1]);
}
}
for(int i = 0 ; i < k; i++){
int h , m , s;
char c;
cin >> h >> c >> m >> c >> s;
opseq.push_back((Node){"",h*60*60+m*60+s,0 , i});
}
// for(auto it: opseq)
// cout << it.name << " " << it.time << " " << it.op << endl;
// cout << "=============================" << endl;
sort(opseq.begin(),opseq.end() , cmp2);
// for(auto it: opseq)
// cout << it.name << " " << it.time << " " << it.op << endl;
// cout << "=============================" << endl;
int maxtime = 0;
int cntnow = 0;
int cur = 0;
for(auto it : opseq){
if(it.op == 1) {
if(!id.count(it.name)) id[it.name] = cur++;
cntnow++;
intime[id[it.name]] = it.time;
}
if(it.op == 0) out.push_back(make_pair(it.idx,cntnow));
if(it.op == -1){
cntnow--;
int idx = id[it.name];
cnt[idx] += it.time - intime[idx];
if(cnt[idx] > maxtime){
res.clear();
res.push_back(it.name);
maxtime = cnt[idx];
}
else if(cnt[idx] == maxtime)
res.push_back(it.name);
}
}
sort(out.begin(),out.end());
for(auto it : out)
cout << it.second << endl;
sort(res.begin(),res.end());
for(auto it : res)
cout << it << " ";
cout << setfill('0');
cout <<setw(2)<< maxtime/60/60 << ":" <<setw(2)<< maxtime/60%60 << ":" <<setw(2)<< maxtime%60 << endl;
// printf("=%02d:%02d:%02d=\n" , maxtime/60/60,maxtime/60%60,maxtime%60);
return 0;
}