cxf2012 @ 2024-12-29 16:53:38
#include<bits/stdc++.h>
using namespace std;
#define L long long
#define N 114514
L n, t, p, k, i1, i2, i3, i4;
L x[101];
int x1[101][101][2];
//dy x[101];
//struct dy {
// L id;
// L Tm;
// L times;
//};
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
// freopen("prizes.in", "r", stdin);
// freopen("prizes.out", "w", stdout);
cin >> n >> t >> p >> k;
int l = t, o[n + 1], id[n + 1], Tm[n + 1];
for (int i = 1; i <= n; i++) {
cin >> id[i] >> Tm[i] >> o[i];
if (o[i] == 1) {
if (x1[id[i]][Tm[i]][0] == 0) {
x[id[i]]++;
if (x[id[i]] == 1)l--;
x1[id[i]][Tm[i]][0] = 1;
x1[id[i]][Tm[i]][1] = i;
if (l == 0 && i4 == 0)i4 = id[i];
} else continue;
}
}
int k1=0,op[t+1];
for (int i = 1; i <= t; i++) {
if(x[i]>=k)op[++k1]=i;
}
for (int i = n; i > 0; i--) {
if (o[i] == 1) {
if (i1 == 0)i1 = id[i];
if (x1[id[i]][Tm[i]][1] == i) {
if (i2 == 0)i2 = id[i];
bool flag = 0;
for (int j = 1; j <= k1; j++) {
if (op[j] == id[i]) {
flag = 1;
break;
}
}
if (flag == 0) {
i3 = id[i];
break;
}
}
}
}
cout << i1 << ' ' << i2 << ' ' << i3 << ' ' << i4;
return 0;
}
by cxf2012 @ 2024-12-29 17:41:35
已AC