| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 98583 | Mercenary | Topovi (COCI15_topovi) | C++14 | 1310 ms | 34348 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;
#define taskname "TEST"
#define pb	push_back
typedef long double ld;
typedef long long ll;
const int maxn = 1e5 + 5;
map<int,int> mcol , mrow;
map<int,int> cntcol , cntrow;
int n , p , k;
map<pair<int,int>,int> mmap;
#define mp make_pair
ll res = 0;
void Move(int r , int c , int val){
    int &valr = mrow[r];int &valc = mcol[c];
    if(valr != valc)res++;
    res -= 2 * n - cntrow[valc] - cntcol[valr];
    cntcol[valc]--;
    cntrow[valr]--;
    valr ^= val;valc ^= val;
    cntcol[valc]++;
    cntrow[valr]++;
    res += 2 * n - cntrow[valc] - cntcol[valr];
    if(valr != valc)res--;
    mmap[mp(r,c)] ^= val;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	if(fopen(taskname".INP","r"))
        freopen(taskname".INP", "r",stdin) ,
        freopen(taskname".OUT", "w",stdout);
    cin >> n >> k >> p;
    cntcol[0] = cntrow[0] = n;
    for(int i = 1 ; i <= k ; ++i)
    {
        int r , c , x;
        cin >> r >> c >> x;
        Move(r,c,x);
    }
    for(int i = 1 ; i <= p ; ++i){
        int r1 , c1 , r2 , c2;cin >> r1 >> c1 >> r2 >> c2;
        int val = mmap[mp(r1,c1)];
        Move(r1,c1,val);
        Move(r2,c2,val);
        cout << res << '\n';
    }
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
