답안 #963623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
963623 2024-04-15T11:53:37 Z vladburac Topovi (COCI15_topovi) C++17
6 / 120
2000 ms 51568 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> line_xor, fCol;
map<int, int> col_xor, fLine;

ll ans = 0;
int n;
void upd( int lin, int col, int put ) {
  int oldx = line_xor[lin];
  line_xor[lin] ^= put;
  int oldy = col_xor[col];
  col_xor[col] ^= put;

  ans -= ( n - fCol[oldx] );
  fCol[oldy]--, fCol[col_xor[col]]++;
  ans += ( n - fCol[line_xor[lin]] );

  ans -= ( n - fLine[oldy] );
  fLine[oldx]--, fLine[line_xor[lin]]++;
  ans += ( n - fLine[col_xor[col]] );
}
void solve() {
  int k, p, i, lin, col, put, lin1, col1, lin2, col2;
  cin >> n >> k >> p;
  fLine[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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 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 348 KB Output isn't correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Incorrect 518 ms 8964 KB Output isn't correct
7 Incorrect 297 ms 7196 KB Output isn't correct
8 Incorrect 429 ms 5996 KB Output isn't correct
9 Incorrect 450 ms 5940 KB Output isn't correct
10 Incorrect 451 ms 6616 KB Output isn't correct
11 Execution timed out 2035 ms 51384 KB Time limit exceeded
12 Execution timed out 2021 ms 51568 KB Time limit exceeded
13 Execution timed out 2102 ms 51336 KB Time limit exceeded
14 Execution timed out 2048 ms 51456 KB Time limit exceeded
15 Execution timed out 2071 ms 51440 KB Time limit exceeded
16 Execution timed out 2033 ms 51512 KB Time limit exceeded
17 Execution timed out 2044 ms 51456 KB Time limit exceeded
18 Execution timed out 2017 ms 51536 KB Time limit exceeded
19 Execution timed out 2050 ms 51540 KB Time limit exceeded
20 Execution timed out 2081 ms 51384 KB Time limit exceeded