# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
963627 |
2024-04-15T12:04:20 Z |
vladburac |
Topovi (COCI15_topovi) |
C++17 |
|
2000 ms |
45644 KB |
#include <bits/stdc++.h>
using namespace std;
#define pii pair<long long, long long>
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--;
}
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 < n; i++ ) {
cin >> lin >> col >> put;
upd( lin, col, put );
power[{lin, col}] = put;
}
for( i = 0; i < p; i++ ) {
cin >> lin1 >> col1 >> lin2 >> col2;
upd( lin1, col1, power[{lin1,col1}] );
upd( lin2, col2, power[{lin1,col1}] );
swap( power[{lin1,col1}], power[{lin2,col2}] );
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 |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
424 KB |
Output isn't correct |
5 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
6 |
Incorrect |
673 ms |
8216 KB |
Output isn't correct |
7 |
Incorrect |
412 ms |
6476 KB |
Output isn't correct |
8 |
Incorrect |
577 ms |
5368 KB |
Output isn't correct |
9 |
Incorrect |
591 ms |
5564 KB |
Output isn't correct |
10 |
Incorrect |
638 ms |
6056 KB |
Output isn't correct |
11 |
Execution timed out |
2059 ms |
45324 KB |
Time limit exceeded |
12 |
Execution timed out |
2084 ms |
45392 KB |
Time limit exceeded |
13 |
Execution timed out |
2043 ms |
45500 KB |
Time limit exceeded |
14 |
Execution timed out |
2043 ms |
45516 KB |
Time limit exceeded |
15 |
Execution timed out |
2051 ms |
45476 KB |
Time limit exceeded |
16 |
Execution timed out |
2093 ms |
45644 KB |
Time limit exceeded |
17 |
Execution timed out |
2057 ms |
45408 KB |
Time limit exceeded |
18 |
Execution timed out |
2049 ms |
45504 KB |
Time limit exceeded |
19 |
Execution timed out |
2070 ms |
45428 KB |
Time limit exceeded |
20 |
Execution timed out |
2062 ms |
45492 KB |
Time limit exceeded |