P7912 100pts 队列 (used to be using vector, TLE)
This commit is contained in:
2024-10-21 21:41:32 +08:00
parent 8fc5fa15dd
commit b2505a5361
7 changed files with 119 additions and 31 deletions

View File

@@ -1,38 +1,38 @@
// The question want me to impl a sort by my self
// But absolutely not
#include <iostream>
using namespace std;
const int N = 10005;
pair<int, int> arr[N];
int b[N];
int main() {
int n, Q;
cin >> n >> Q;
int arr[n + 5];
int n, m;
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++) {
cin >> arr[i];
scanf("%d", &arr[i].first);
arr[i].second = i;
}
for (int i = 0; i < Q; i++) {
int op;
cin >> op;
sort(arr + 1, arr + n + 1);
for (int i = 1; i <= n; i++) b[arr[i].second] = i;
while (m--) {
int op, x, y;
scanf("%d", &op);
if (op == 1) {
int x, v;
cin >> x >> v;
arr[x] = v;
scanf("%d%d", &x, &y);
arr[b[x]].first = y;
for (int i = 1; i < n; i++) {
if (arr[i] > arr[i + 1]) swap(arr[i], arr[i + 1]);
}
for (int i = n - 1; i >= 1; i--) {
if (arr[i] > arr[i + 1]) swap(arr[i], arr[i + 1]);
}
for (int i = 1; i <= n; i++) b[arr[i].second] = i;
} else {
int xn;
cin >> xn;
int it = arr[xn];
int pos = n;
for (int j = 1; j < xn; j++) {
if (arr[j] > it) pos--;
}
for (int j = xn + 1; j <= n; j++) {
if (arr[j] >= it) pos--;
}
cout << pos << endl;
scanf("%d", &x);
printf("%d\n", b[x]);
}
}
return 0;
}