Submission #382492

#TimeUsernameProblemLanguageResultExecution timeMemory
382492BlancaHMTopovi (COCI15_topovi)C++14
60 / 120
57 ms65540 KiB
#include <iostream> #include <vector> #include <map> using namespace std; typedef long long int ll; int N, K, P; long long int attacked; vector<int> rowXOR, colXOR; map<pair<int, int>, int> rooks; map<int, int> valRows, valCols; void init() { attacked = 0; rowXOR.assign(N, 0); colXOR.assign(N, 0); valRows[0] = N; valCols[0] = N; } void include(int r, int c, int p) { attacked -= (ll) (N - valRows[colXOR[c]]); attacked -= (ll) (N - valCols[rowXOR[r]]); valRows[rowXOR[r]]--; valCols[colXOR[c]]--; rooks[{r, c}] = p; rowXOR[r] ^= p; colXOR[c] ^= p; valRows[rowXOR[r]]++; valCols[colXOR[c]]++; attacked += (ll) (N - valRows[colXOR[c]]); attacked += (ll) (N - valCols[rowXOR[r]]); } int main() { ios::sync_with_stdio(false); cin.tie(NULL); int r, c, p, r2, c2; cin >> N >> K >> P; init(); for (int i = 0; i < K; i++) { cin >> r >> c >> p; include(r-1, c-1, p); //cout << attacked << '\n'; } for (int i = 0; i < P; i++) { cin >> r >> c >> r2 >> c2; p = rooks[{r-1, c-1}]; include(r-1, c-1, p); include(r2-1, c2-1, p); cout << attacked << '\n'; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...