# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
963642 | vladburac | Topovi (COCI15_topovi) | C++17 | 915 ms | 33788 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 pii pair<int, int>
using ll = long long;
const int NMAX = 5e5;
const int VALMAX = 1e6;
const int LOGMAX = 18;
const int INF = 1e9;
const int MOD = 998244353;
mt19937 rnd( chrono::steady_clock::now().time_since_epoch().count() );
/*
#ifndef HOME
ifstream fin( "regate.in" );
ofstream fout( "regate.out" );
#define cin fin
#define cout fout
#endif // HOME
*/
map<pii, int> power;
map<int, int> l_xor, fCol;
map<int, int> c_xor, fLin;
ll ans = 0;
int n;
void upd( int lin, int col, int put ) {
ans -= n - fCol[l_xor[lin]];
ans -= n - fLin[c_xor[col]];
if( l_xor[lin] ^ c_xor[col] )
ans++;
fLin[l_xor[lin]]--;
l_xor[lin] ^= put;
fLin[l_xor[lin]]++;
fCol[c_xor[col]]--;
c_xor[col] ^= put;
fCol[c_xor[col]]++;
ans += n - fCol[l_xor[lin]];
ans += n - fLin[c_xor[col]];
if( l_xor[lin] ^ c_xor[col] )
ans--;
power[{lin,col}] ^= put;
}
void solve() {
int k, p, i, lin, col, put, lin1, col1, lin2, col2;
cin >> n >> k >> p;
fLin[0] = n, fCol[0] = n;
for( i = 0; i < k; i++ ) {
cin >> lin >> col >> put;
upd( lin, col, put );
}
for( i = 0; i < p; i++ ) {
cin >> lin1 >> col1 >> lin2 >> col2;
int aux = power[{lin1,col1}];
upd( lin1, col1, aux );
upd( lin2, col2, aux );
cout << ans << "\n";
}
}
int main() {
ios_base::sync_with_stdio( false );
cin.tie( NULL );
cout.tie( NULL );
int t = 1;
//cin >> t;
while( t-- ) {
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |