# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
465389 | JovanB | Topovi (COCI15_topovi) | C++17 | 1135 ms | 39516 KiB |
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>
using namespace std;
using ll = long long;
using ld = long double;
map <int, int> row;
map <int, int> col;
map <int, int> crow;
map <int, int> ccol;
map <pair <int, int>, int> pw;
ll tr;
void uradi(int i, int j, int p){
crow[row[i]]--;
tr -= ccol[row[i]];
row[i] ^= p;
tr += ccol[row[i]];
crow[row[i]]++;
ccol[col[j]]--;
tr -= crow[col[j]];
col[j] ^= p;
tr += crow[col[j]];
ccol[col[j]]++;
pw[{i, j}] = p;
}
int main(){
ios_base::sync_with_stdio(false), cin.tie(0);
cout.precision(10);
cout << fixed;
ll n;
int k, p;
cin >> n >> k >> p;
ccol[0] = crow[0] = n;
tr = n*n;
while(k--){
int i, j, pww;
cin >> i >> j >> pww;
uradi(i, j, pww);
}
while(p--){
int i, j;
cin >> i >> j;
int pww = pw[{i, j}];
uradi(i, j, pww);
pw[{i, j}] = 0;
cin >> i >> j;
uradi(i, j, pww);
cout << n*n - tr << "\n";
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |