Submission #230557

# Submission time Handle Problem Language Result Execution time Memory
230557 2020-05-10T11:27:22 Z alireza_kaviani Topovi (COCI15_topovi) C++17
120 / 120
878 ms 39928 KB
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (Windows, macOS, Linux)
 * Author: alireza_kaviani
 * Time: 2020-05-10 15:06:09
**/
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define all(x)                      (x).begin(),(x).end()
#define Sort(x)                     sort(all((x)))
#define X                           first
#define Y                           second
#define sep                         ' '
#define endl                        '\n'
#define SZ(x)                       ll(x.size())

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 1e6 + 10;
const ll LOG = 22;
const ll INF = 8e18;
const ll MOD = 1e9 + 7; // 998244353; // 1e9 + 9;

// row : n , col : m
ll n , k , p , ans;
map<pair<int , int> , int> val;
map<int , int> col , row , cntCol , cntRow;

void modifyCol(int c , int x){
    ans += cntRow[c] * x;
    cntCol[c] += x;
}

void modifyRow(int r , int x){
    ans += cntCol[r] * x;
    cntRow[r] += x;
}

void insert(int r , int c , int x){ 
    int R = (row[r] ^= x) , C = (col[c] ^= x); val[{r , c}] ^= x;
    modifyRow(R ^ x , -1) ; modifyCol(C ^ x , -1);
    modifyRow(R , +1) ; modifyCol(C , +1);
}

int main() {
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

    scanf("%lld%lld%lld" , &n , &k , &p); ans = n * n;
    cntCol[0] = cntRow[0] = n;
    for(int i = 1 , r , c , x ; i <= k ; i++){
        scanf("%d%d%d" , &r , &c , &x);
        insert(r , c , x);
    }

    for(int i = 1 , r1 , c1 , r2 , c2 ; i <= p ; i++){
        scanf("%d%d%d%d" , &r1 , &c1 , &r2 , &c2);
        ll v = val[{r1 , c1}];
        insert(r1 , c1 , v);
        insert(r2 , c2 , v);
        printf("%lld\n" , n * n - ans);
    }

    return 0;
}
/*

*/

Compilation message

topovi.cpp: In function 'int main()':
topovi.cpp:60:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld%lld" , &n , &k , &p); ans = n * n;
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:63:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d" , &r , &c , &x);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
topovi.cpp:68:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d%d" , &r1 , &c1 , &r2 , &c2);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 75 ms 6136 KB Output is correct
7 Correct 60 ms 5368 KB Output is correct
8 Correct 47 ms 4472 KB Output is correct
9 Correct 53 ms 4600 KB Output is correct
10 Correct 54 ms 4728 KB Output is correct
11 Correct 792 ms 39636 KB Output is correct
12 Correct 768 ms 39672 KB Output is correct
13 Correct 770 ms 39608 KB Output is correct
14 Correct 831 ms 39548 KB Output is correct
15 Correct 858 ms 39928 KB Output is correct
16 Correct 878 ms 39524 KB Output is correct
17 Correct 862 ms 39596 KB Output is correct
18 Correct 877 ms 39776 KB Output is correct
19 Correct 878 ms 39584 KB Output is correct
20 Correct 847 ms 39572 KB Output is correct