Submission #961816

# Submission time Handle Problem Language Result Execution time Memory
961816 2024-04-12T13:47:36 Z ASN49K Topovi (COCI15_topovi) C++14
0 / 120
778 ms 33668 KB
#include <bits/stdc++.h>

using namespace std;
#define pb push_back
#define all(x) x.begin(),x.end()
#define LINE 0
#define COLOUMN 1
using i64=long long;
map<int,int>value[2],cnt[2];
map<pair<int,int>,int>mpp;
int n;
i64 cost;

void calculate(int poz,int tip,int sign)
{
    cnt[tip][value[tip][poz]]+=sign;
    cost+=sign*(n-cnt[tip^1][value[tip][poz]]);
}
void add(int poz,int val,bool tip)
{
    calculate(poz,tip,-1);
    value[tip][poz]^=val;
    calculate(poz,tip,1);
}

void change(int l1,int r1,int l2,int r2)
{
    int vall=mpp[make_pair(l1,r1)];
    add(l1,vall,LINE);
    add(r1,vall,COLOUMN);
    add(l2,vall,LINE);
    add(r2,vall,COLOUMN);
    mpp[make_pair(l2,r2)]=vall;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int k,q;
    cin>>n>>k>>q;
    cnt[LINE][0]=n;
    cnt[COLOUMN][0]=n;
    for(int i=0;i<k;i++)
    {
        int x,y,k;
        cin>>x>>y>>k;
        add(x,k,LINE);
        add(y,k,COLOUMN);
        mpp[make_pair(x,y)]=k;
    }
    cout<<cost<<'\n';

    while(q--)
    {
        int l1,r1,l2,r2;
        cin>>l1>>r1>>l2>>r2;
        change(l1,r1,l2,r2);
        cout<<cost<<'\n';
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Incorrect 0 ms 348 KB Output isn't correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Incorrect 1 ms 344 KB Output isn't correct
5 Incorrect 1 ms 344 KB Output isn't correct
6 Incorrect 74 ms 5412 KB Output isn't correct
7 Incorrect 61 ms 4688 KB Output isn't correct
8 Incorrect 49 ms 4044 KB Output isn't correct
9 Incorrect 48 ms 3920 KB Output isn't correct
10 Incorrect 54 ms 4180 KB Output isn't correct
11 Incorrect 776 ms 33488 KB Output isn't correct
12 Incorrect 733 ms 33596 KB Output isn't correct
13 Incorrect 778 ms 33668 KB Output isn't correct
14 Incorrect 722 ms 33532 KB Output isn't correct
15 Incorrect 729 ms 33516 KB Output isn't correct
16 Incorrect 770 ms 33628 KB Output isn't correct
17 Incorrect 735 ms 33356 KB Output isn't correct
18 Incorrect 766 ms 33560 KB Output isn't correct
19 Incorrect 718 ms 33468 KB Output isn't correct
20 Incorrect 745 ms 33528 KB Output isn't correct