This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fs first
#define sc second
#define tlll tuple<ll,ll,ll>
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int mxn = 1e5+10;
int R,C,Q;
vector<vector<int>> arr,brr;
ordered_set st;
set<int> pos[mxn];
inline void add(int c,int p){
st.erase(*pos[c].begin());
pos[c].insert(p);
st.insert(*pos[c].begin());
return;
}
inline void del(int c,int p){
st.erase(*pos[c].begin());
pos[c].erase(p);
st.insert(*pos[c].begin());
return;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
cin>>R>>C>>Q;
arr = vector<vector<int>>(R+1,vector<int>(C+1,0));
brr = arr;
for(int i = 1;i<=R;i++)for(int j = 1;j<=C;j++)cin>>arr[i][j];
for(int i = 0;i<mxn;i++){
pos[i].insert(i+mxn);
st.insert(i+mxn);
}
for(int i = 1;i<=R;i++)for(int j = 1;j<=C;j++){
cin>>brr[i][j];
add(brr[i][j],j);
}
while(Q--){
int t,x,y,v;
cin>>t>>x>>y>>v;
swap(x,y);
if(t == 2){
if(v>=y)cout<<st.order_of_key(v+1)<<'\n';
else cout<<"0\n";
}
else{
del(brr[x][y],y);
brr[x][y] = v;
add(brr[x][y],y);
}
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |