20251018总结
前言
666B题黄题做不出来了,我也是个人物。
我们至今仍未得知我考试时写了个什么b玩意
分数:
题目
A - matrix
666直接记录行列的最大值与位置,每次
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 2e5 + 10;
int n, m, q, h[N], l[N], vh[N], vl[N];
vector<vector<int>> a;
vector<int> v;
bool check(int x, int y){
return h[x] == a[x][y] && l[y] == a[x][y];
}
signed main(){
// freopen("matrix.in", "r", stdin);
// freopen("matrix.out", "w", stdout);
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
cin >> n >> m >> q;
v.resize(m + 5), a.push_back(v);
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
cin >> v[j];
if(h[i] < v[j]){
h[i] = v[j], vh[i] = j;
}
if(l[j] < v[j]){
l[j] = v[j], vl[j] = i;
}
}
a.push_back(v);
}
int ans = 0;
for(int i = 1; i <= n; i++){
for(int j = 1; j <= m; j++){
int f = h[i] == a[i][j] && l[j] == a[i][j];
ans += f;
}
}
for(int x, y, t; q--; ){
cin >> x >> y >> t;
int w = !check(x, y);
//cout << x << ' ' << y << ' ' << h[x] << ' ' << l[y] << ' ' << vh[x] << ' ' << vl[y] << ' ' << w << ' ' << t << '\n';
if(t > h[x]){
ans -= (vh[x] != y) * check(x, vh[x]), vh[x] = y, h[x] = t;
}
if(t > l[y]){
ans -= (vl[y] != x) * check(vl[y], y), vl[y] = x, l[y] = t;
}
a[x][y] = t;
ans += (w && check(x, y));
cout << ans << '\n';
}
return 0;
}