Submission #646974

# Submission time Handle Problem Language Result Execution time Memory
646974 2022-10-01T09:31:52 Z Trisanu_Das Topovi (COCI15_topovi) C++17
Compilation error
0 ms 0 KB
using namespace std;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);  
  int n, k, p;
  cin >> n >> k >> p;
  long long ans = n * n;
  map<int, int> cx;
  map<int, int> cy;
  cx[0] = n;   
  cy[0] = n;
  map<int, int> xs;
  map<int, int> ys;
  map<pair<int, int>, int> val;
  function<void(int, int, int)> Add = [&](int x, int y, int v) {
    ans -= cx[ys[y]];
    ans -= cy[xs[x]];
    val[{x, y}] = v;
    cx[xs[x]] -= 1;
    cy[ys[y]] -= 1;
    xs[x] ^= v;
    ys[y] ^= v;
    cx[xs[x]] += 1;
    cy[ys[y]] += 1;
    ans += cx[ys[y]];
    ans += cy[xs[x]];
  };
  function<void(int, int, int)> Remove = [&](int x, int y, int v) {
    ans -= cx[ys[y]];
    ans -= cy[xs[x]];
    val[{x, y}] = 0;
    cx[xs[x]] -= 1;
    cy[ys[y]] -= 1;
    xs[x] ^= v;
    ys[y] ^= v;
    cx[xs[x]] += 1;
    cy[ys[y]] += 1;
    ans += cx[ys[y]];
    ans += cy[xs[x]];
  };
  for (int i = 0; i < k; i++) {
    int x, y, a;
    cin >> x >> y >> a;
    Add(x, y, a);
  }
  ans = 0;
  for (auto& p : cx) {
    ans += p.second * 1LL * cy[p.first];
  }
  while (p--) {
    int xa, ya, xb, yb;
    cin >> xa >> ya >> xb >> yb;
    Add(xb, yb, val[{xa, ya}]);
    Remove(xa, ya, val[{xa, ya}]);
    cout << n * 1LL * n - ans << '\n';
  }                                                                  
  return 0;
}

Compilation message

topovi.cpp: In function 'int main()':
topovi.cpp:4:3: error: 'ios' has not been declared
    4 |   ios::sync_with_stdio(false);
      |   ^~~
topovi.cpp:5:3: error: 'cin' was not declared in this scope
    5 |   cin.tie(0);
      |   ^~~
topovi.cpp:1:1: note: 'std::cin' is defined in header '<iostream>'; did you forget to '#include <iostream>'?
  +++ |+#include <iostream>
    1 | using namespace std;
topovi.cpp:9:3: error: 'map' was not declared in this scope
    9 |   map<int, int> cx;
      |   ^~~
topovi.cpp:1:1: note: 'std::map' is defined in header '<map>'; did you forget to '#include <map>'?
  +++ |+#include <map>
    1 | using namespace std;
topovi.cpp:9:7: error: expected primary-expression before 'int'
    9 |   map<int, int> cx;
      |       ^~~
topovi.cpp:10:7: error: expected primary-expression before 'int'
   10 |   map<int, int> cy;
      |       ^~~
topovi.cpp:11:3: error: 'cx' was not declared in this scope
   11 |   cx[0] = n;
      |   ^~
topovi.cpp:12:3: error: 'cy' was not declared in this scope
   12 |   cy[0] = n;
      |   ^~
topovi.cpp:13:7: error: expected primary-expression before 'int'
   13 |   map<int, int> xs;
      |       ^~~
topovi.cpp:14:7: error: expected primary-expression before 'int'
   14 |   map<int, int> ys;
      |       ^~~
topovi.cpp:15:7: error: 'pair' was not declared in this scope
   15 |   map<pair<int, int>, int> val;
      |       ^~~~
topovi.cpp:1:1: note: 'std::pair' is defined in header '<utility>'; did you forget to '#include <utility>'?
  +++ |+#include <utility>
    1 | using namespace std;
topovi.cpp:15:12: error: expected primary-expression before 'int'
   15 |   map<pair<int, int>, int> val;
      |            ^~~
topovi.cpp:16:3: error: 'function' was not declared in this scope
   16 |   function<void(int, int, int)> Add = [&](int x, int y, int v) {
      |   ^~~~~~~~
topovi.cpp:1:1: note: 'std::function' is defined in header '<functional>'; did you forget to '#include <functional>'?
  +++ |+#include <functional>
    1 | using namespace std;
topovi.cpp:16:30: error: expression list treated as compound expression in functional cast [-fpermissive]
   16 |   function<void(int, int, int)> Add = [&](int x, int y, int v) {
      |                              ^
topovi.cpp:16:12: error: expected primary-expression before 'void'
   16 |   function<void(int, int, int)> Add = [&](int x, int y, int v) {
      |            ^~~~
topovi.cpp:29:30: error: expression list treated as compound expression in functional cast [-fpermissive]
   29 |   function<void(int, int, int)> Remove = [&](int x, int y, int v) {
      |                              ^
topovi.cpp:29:12: error: expected primary-expression before 'void'
   29 |   function<void(int, int, int)> Remove = [&](int x, int y, int v) {
      |            ^~~~
topovi.cpp:45:5: error: 'Add' was not declared in this scope
   45 |     Add(x, y, a);
      |     ^~~
topovi.cpp:54:17: error: 'val' was not declared in this scope
   54 |     Add(xb, yb, val[{xa, ya}]);
      |                 ^~~
topovi.cpp:54:5: error: 'Add' was not declared in this scope
   54 |     Add(xb, yb, val[{xa, ya}]);
      |     ^~~
topovi.cpp:55:5: error: 'Remove' was not declared in this scope
   55 |     Remove(xa, ya, val[{xa, ya}]);
      |     ^~~~~~
topovi.cpp:56:5: error: 'cout' was not declared in this scope
   56 |     cout << n * 1LL * n - ans << '\n';
      |     ^~~~
topovi.cpp:56:5: note: 'std::cout' is defined in header '<iostream>'; did you forget to '#include <iostream>'?