답안 #268623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
268623 2020-08-16T14:29:11 Z mayhoubsaleh Topovi (COCI15_topovi) C++14
120 / 120
1673 ms 46032 KB
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


using namespace std;
const ll maxn=1e6+100;
const ll inf=1e9+10;

ll n,k,q;
ll unat;
map<pair<ll,ll>,ll>a;
map<ll,ll>cntr,cntc,valr,valc;

void add(ll r,ll c,ll val){
    unat-=cntr[valc[c]];
    unat-=cntc[valr[r]];
    if(valc[c]==valr[r])unat++;
    cntc[valc[c]]--;
    cntr[valr[r]]--;
    valc[c]^=val;
    valr[r]^=val;
    cntc[valc[c]]++;
    cntr[valr[r]]++;
    unat+=cntc[valr[r]];
    unat+=cntr[valc[c]];
    if(valr[r]==valc[c])unat--;
    a[{r,c}]=val;
}

int main()
{
    IOS
    cin>>n>>k>>q;
    cntr[0]=cntc[0]=n;
    unat=n*n;
    while(k--){
        ll r,c,x;
        cin>>r>>c>>x;
        add(r,c,x);
    }

    while(q--){
        ll r,c,rr,cc;
        cin>>r>>c>>rr>>cc;
        ll x=a[{r,c}];
        add(r,c,x);
        add(rr,cc,x);
        cout<<n*n-unat<<endl;
    }
    return 0;
}

# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 201 ms 7032 KB Output is correct
7 Correct 148 ms 6264 KB Output is correct
8 Correct 122 ms 5112 KB Output is correct
9 Correct 124 ms 5240 KB Output is correct
10 Correct 160 ms 5584 KB Output is correct
11 Correct 1619 ms 45816 KB Output is correct
12 Correct 1527 ms 45852 KB Output is correct
13 Correct 1551 ms 45960 KB Output is correct
14 Correct 1530 ms 45816 KB Output is correct
15 Correct 1529 ms 45816 KB Output is correct
16 Correct 1673 ms 46032 KB Output is correct
17 Correct 1533 ms 46004 KB Output is correct
18 Correct 1519 ms 45848 KB Output is correct
19 Correct 1607 ms 45944 KB Output is correct
20 Correct 1586 ms 45940 KB Output is correct