| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 98727 | luckyboy | Topovi (COCI15_topovi) | C++14 | 1697 ms | 33756 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.
/// COCI 2015-2016 contest 1
/**Lucky Boy**/
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define FORD(i, a, b) for (int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define maxc 1000000007
#define maxn 200005
#define maxm 500005
#define pii pair <int,int>
#define Task "TOPOVI"
template <typename T> inline void read(T &x){char c;bool nega=0;while((!isdigit(c=getchar()))&&(c!='-'));if(c=='-'){nega=1;c=getchar();}x=c-48;while(isdigit(c=getchar())) x=x*10+c-48;if(nega) x=-x;}
template <typename T> inline void writep(T x){if(x>9) writep(x/10);putchar(x%10+48);}
template <typename T> inline void write(T x){if(x<0){putchar('-');x=-x;}writep(x);putchar(' ');}
template <typename T> inline void writeln(T x){write(x);putchar('\n');}
using namespace std;
int n,m,q;
map <int,int> row,col,cntr,cntc;
map <pii,int> a;
long long ans;
void Add(int x,int y,int z)
{
    ans -= (m - cntc[row[x]]);
    ans -= (m - cntr[col[y]]);
    --cntc[col[y]];
    --cntr[row[x]];
    row[x] ^= z;
    col[y] ^= z;
    ++cntc[col[y]];
    ++cntr[row[x]];
    ans += (m - cntc[row[x]]);
    ans += (m - cntr[col[y]]);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen(Task".inp", "r",stdin);
    //freopen(Task".out", "w",stdout);
    cin >> m >> n >> q;
    cntc[0] = cntr[0] = m;
    FOR(i,1,n)
    {
        int x,y,z;
        cin >> x >> y >> z;
        a[mp(x,y)] = z;
        Add(x,y,z);
    }
    while (q--)
    {
        int x,y,u,v;
        cin >> x >> y >> u >> v;
        int z = a[mp(x,y)];
        Add(x,y,z);
        Add(u,v,z);
        swap(a[mp(x,y)],a[mp(u,v)]);
        cout << ans << '\n';
    }
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
