답안 #963633

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
963633 2024-04-15T12:09:30 Z vladburac Topovi (COCI15_topovi) C++17
6 / 120
2000 ms 45652 KB
#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 < n; 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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 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 344 KB Output isn't correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Incorrect 685 ms 8220 KB Output isn't correct
7 Incorrect 431 ms 6476 KB Output isn't correct
8 Incorrect 573 ms 5364 KB Output isn't correct
9 Incorrect 592 ms 5564 KB Output isn't correct
10 Incorrect 658 ms 6056 KB Output isn't correct
11 Execution timed out 2043 ms 45524 KB Time limit exceeded
12 Execution timed out 2005 ms 45652 KB Time limit exceeded
13 Execution timed out 2058 ms 45520 KB Time limit exceeded
14 Execution timed out 2065 ms 45308 KB Time limit exceeded
15 Execution timed out 2015 ms 45448 KB Time limit exceeded
16 Execution timed out 2055 ms 45324 KB Time limit exceeded
17 Execution timed out 2025 ms 45500 KB Time limit exceeded
18 Execution timed out 2071 ms 45444 KB Time limit exceeded
19 Execution timed out 2045 ms 45372 KB Time limit exceeded
20 Execution timed out 2048 ms 45312 KB Time limit exceeded