Submission #966293

#TimeUsernameProblemLanguageResultExecution timeMemory
966293Trisanu_DasExamination (JOI19_examination)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back #define int ll const int N = 2e5 + 5; bool cmp(pair<int, int> a, pair<int, int> b){ if(a == b) return 0; if(a.ff + a.ss > b.ff + b.ss) return 0; if(a.ff + a.ss < b.ff + b.ss) return 1; if(a.ff > b.ff) return 0; return 1; } int BIT[N], ans[N], cutoffs[N][3]; vector<pair<int, int> > a; void add(int idx, int val){ for( ; idx < N; idx |= (idx + 1)) BIT[idx] += val; } int qry(int idx){ int ans = 0; for(; idx >= 0; idx = (idx & (idx + 1)) - 1) ans += BIT[idx] return ans; } int sum(int l, int r){ if(l > r) return 0; return qry(r) - qry(l - 1); } signed main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, q; cin >> n >> q; for(int i = 0; i < n; i++){ int s, t; cin >> s >> t; a.pb({s, t}); } sort(a.begin(), a.end()); vector<pair<pair<int, int>, int> > c_sort1; for(int i = 0; i < q; i++) cin >> cutoffs[i][0] >> cutoffs[i][1] >> cutoffs[i][2]; for(int i = 0; i < q; i++) if(cutoffs[i][0] + cutoffs[i][1] >= cutoffs[i][2]) c_sort1.pb({{cutoffs[i][0], cutoffs[i][1]}, i}); sort(c_sort1.begin(), c_sort1.end()); int idx = n - 1; memset(BIT, 0, sizeof(BIT)); while(!c_sort1.empty()){ auto x = c_sort1.back(); c_sort1.pop_back(); while(idx >= 0 and a[idx].ff >= x.ff.ff){ upd(a[idx].ss, 1); idx--; } ans[x.ss] = sum(x.ff.ss, N - 1); } vector<pair<int, int> > c_sort2; for(int i = 0; i < q; i++) if(cutoffs[i][0] + cutoffs[i][1] < cutoffs[i][2]) c_sort2.pb({cutoffs[i][2], i}); sort(c_sort2.begin(), c_sort2.end()); sort(a.begin(), a.end(), cmp); memset(bit, 0, sizeof(bit)); idx = n - 1; for(int i = (int)c_sort2.size() - 1; i >= 0; i--){ while(idx >= 0 and a[idx].ff + a[idx].ss >= c_sort2[i].ff){ upd(a[idx].ff, 1); idx--; } ans[c_sort2[i].ss] += n - idx - 1; ans[c_sort2[i].ss] -= sum(0, cutoffs[c_sort2[i].ss][0] - 1); } memset(BIT, 0, sizeof(BIT)); idx = n - 1; for(int i = (int)c_sort2.size() - 1; i >= 0; i--){ while(idx >= 0 and a[idx].ff + a[idx].ss >= c_sort2[i].ff){ upd(a[idx].ss, 1); idx--; } ans[c_sort2[i].ss] -= sum(0, cutoffs[c_sort2[i].ss][1] - 1); } for(int i = 0; i < q; i++) cout << ans[i] << '\n'; }

Compilation message (stderr)

examination.cpp:6:13: error: 'll' does not name a type
    6 | #define int ll
      |             ^~
examination.cpp:7:7: note: in expansion of macro 'int'
    7 | const int N = 2e5 + 5;
      |       ^~~
examination.cpp:6:13: error: 'll' was not declared in this scope
    6 | #define int ll
      |             ^~
examination.cpp:9:15: note: in expansion of macro 'int'
    9 | bool cmp(pair<int, int> a, pair<int, int> b){
      |               ^~~
examination.cpp:6:13: error: 'll' was not declared in this scope
    6 | #define int ll
      |             ^~
examination.cpp:9:20: note: in expansion of macro 'int'
    9 | bool cmp(pair<int, int> a, pair<int, int> b){
      |                    ^~~
examination.cpp:9:23: error: template argument 1 is invalid
    9 | bool cmp(pair<int, int> a, pair<int, int> b){
      |                       ^
examination.cpp:9:23: error: template argument 2 is invalid
examination.cpp:6:13: error: 'll' was not declared in this scope
    6 | #define int ll
      |             ^~
examination.cpp:9:33: note: in expansion of macro 'int'
    9 | bool cmp(pair<int, int> a, pair<int, int> b){
      |                                 ^~~
examination.cpp:6:13: error: 'll' was not declared in this scope
    6 | #define int ll
      |             ^~
examination.cpp:9:38: note: in expansion of macro 'int'
    9 | bool cmp(pair<int, int> a, pair<int, int> b){
      |                                      ^~~
examination.cpp:9:41: error: template argument 1 is invalid
    9 | bool cmp(pair<int, int> a, pair<int, int> b){
      |                                         ^
examination.cpp:9:41: error: template argument 2 is invalid
examination.cpp: In function 'bool cmp(int, int)':
examination.cpp:3:12: error: request for member 'first' in 'a', which is of non-class type 'int'
    3 | #define ff first
      |            ^~~~~
examination.cpp:11:7: note: in expansion of macro 'ff'
   11 |  if(a.ff + a.ss > b.ff + b.ss) return 0;
      |       ^~
examination.cpp:4:12: error: request for member 'second' in 'a', which is of non-class type 'int'
    4 | #define ss second
      |            ^~~~~~
examination.cpp:11:14: note: in expansion of macro 'ss'
   11 |  if(a.ff + a.ss > b.ff + b.ss) return 0;
      |              ^~
examination.cpp:3:12: error: request for member 'first' in 'b', which is of non-class type 'int'
    3 | #define ff first
      |            ^~~~~
examination.cpp:11:21: note: in expansion of macro 'ff'
   11 |  if(a.ff + a.ss > b.ff + b.ss) return 0;
      |                     ^~
examination.cpp:4:12: error: request for member 'second' in 'b', which is of non-class type 'int'
    4 | #define ss second
      |            ^~~~~~
examination.cpp:11:28: note: in expansion of macro 'ss'
   11 |  if(a.ff + a.ss > b.ff + b.ss) return 0;
      |                            ^~
examination.cpp:3:12: error: request for member 'first' in 'a', which is of non-class type 'int'
    3 | #define ff first
      |            ^~~~~
examination.cpp:12:7: note: in expansion of macro 'ff'
   12 |  if(a.ff + a.ss < b.ff + b.ss) return 1;
      |       ^~
examination.cpp:4:12: error: request for member 'second' in 'a', which is of non-class type 'int'
    4 | #define ss second
      |            ^~~~~~
examination.cpp:12:14: note: in expansion of macro 'ss'
   12 |  if(a.ff + a.ss < b.ff + b.ss) return 1;
      |              ^~
examination.cpp:3:12: error: request for member 'first' in 'b', which is of non-class type 'int'
    3 | #define ff first
      |            ^~~~~
examination.cpp:12:21: note: in expansion of macro 'ff'
   12 |  if(a.ff + a.ss < b.ff + b.ss) return 1;
      |                     ^~
examination.cpp:4:12: error: request for member 'second' in 'b', which is of non-class type 'int'
    4 | #define ss second
      |            ^~~~~~
examination.cpp:12:28: note: in expansion of macro 'ss'
   12 |  if(a.ff + a.ss < b.ff + b.ss) return 1;
      |                            ^~
examination.cpp:3:12: error: request for member 'first' in 'a', which is of non-class type 'int'
    3 | #define ff first
      |            ^~~~~
examination.cpp:13:7: note: in expansion of macro 'ff'
   13 |  if(a.ff > b.ff) return 0;
      |       ^~
examination.cpp:3:12: error: request for member 'first' in 'b', which is of non-class type 'int'
    3 | #define ff first
      |            ^~~~~
examination.cpp:13:14: note: in expansion of macro 'ff'
   13 |  if(a.ff > b.ff) return 0;
      |              ^~
examination.cpp: At global scope:
examination.cpp:6:13: error: 'll' does not name a type
    6 | #define int ll
      |             ^~
examination.cpp:17:1: note: in expansion of macro 'int'
   17 | int BIT[N], ans[N], cutoffs[N][3];
      | ^~~
examination.cpp:6:13: error: 'll' was not declared in this scope
    6 | #define int ll
      |             ^~
examination.cpp:18:13: note: in expansion of macro 'int'
   18 | vector<pair<int, int> > a;
      |             ^~~
examination.cpp:6:13: error: 'll' was not declared in this scope
    6 | #define int ll
      |             ^~
examination.cpp:18:18: note: in expansion of macro 'int'
   18 | vector<pair<int, int> > a;
      |                  ^~~
examination.cpp:18:21: error: template argument 1 is invalid
   18 | vector<pair<int, int> > a;
      |                     ^
examination.cpp:18:21: error: template argument 2 is invalid
examination.cpp:18:23: error: template argument 1 is invalid
   18 | vector<pair<int, int> > a;
      |                       ^
examination.cpp:18:23: error: template argument 2 is invalid
examination.cpp:20:6: error: variable or field 'add' declared void
   20 | void add(int idx, int val){
      |      ^~~
examination.cpp:6:13: error: 'll' was not declared in this scope
    6 | #define int ll
      |             ^~
examination.cpp:20:10: note: in expansion of macro 'int'
   20 | void add(int idx, int val){
      |          ^~~
examination.cpp:6:13: error: 'll' was not declared in this scope
    6 | #define int ll
      |             ^~
examination.cpp:20:19: note: in expansion of macro 'int'
   20 | void add(int idx, int val){
      |                   ^~~
examination.cpp:6:13: error: 'll' does not name a type
    6 | #define int ll
      |             ^~
examination.cpp:24:1: note: in expansion of macro 'int'
   24 | int qry(int idx){
      | ^~~
examination.cpp:6:13: error: 'll' does not name a type
    6 | #define int ll
      |             ^~
examination.cpp:30:1: note: in expansion of macro 'int'
   30 | int sum(int l, int r){
      | ^~~
examination.cpp: In function 'int main()':
examination.cpp:6:13: error: 'll' was not declared in this scope
    6 | #define int ll
      |             ^~
examination.cpp:37:2: note: in expansion of macro 'int'
   37 |  int n, q; cin >> n >> q;
      |  ^~~
examination.cpp:37:19: error: 'n' was not declared in this scope
   37 |  int n, q; cin >> n >> q;
      |                   ^
examination.cpp:37:24: error: 'q' was not declared in this scope
   37 |  int n, q; cin >> n >> q;
      |                        ^
examination.cpp:38:10: error: expected ';' before 'i'
   38 |  for(int i = 0; i < n; i++){
      |          ^
examination.cpp:38:17: error: 'i' was not declared in this scope
   38 |  for(int i = 0; i < n; i++){
      |                 ^
examination.cpp:39:7: error: expected ';' before 's'
   39 |   int s, t; cin >> s >> t;
      |       ^
examination.cpp:39:20: error: 's' was not declared in this scope
   39 |   int s, t; cin >> s >> t;
      |                    ^
examination.cpp:39:25: error: 't' was not declared in this scope
   39 |   int s, t; cin >> s >> t;
      |                         ^
examination.cpp:5:12: error: request for member 'push_back' in 'a', which is of non-class type 'int'
    5 | #define pb push_back
      |            ^~~~~~~~~
examination.cpp:40:5: note: in expansion of macro 'pb'
   40 |   a.pb({s, t});
      |     ^~
examination.cpp:42:9: error: request for member 'begin' in 'a', which is of non-class type 'int'
   42 |  sort(a.begin(), a.end());
      |         ^~~~~
examination.cpp:42:20: error: request for member 'end' in 'a', which is of non-class type 'int'
   42 |  sort(a.begin(), a.end());
      |                    ^~~
examination.cpp:43:33: error: template argument 1 is invalid
   43 |  vector<pair<pair<int, int>, int> > c_sort1;
      |                                 ^
examination.cpp:43:35: error: template argument 1 is invalid
   43 |  vector<pair<pair<int, int>, int> > c_sort1;
      |                                   ^
examination.cpp:43:35: error: template argument 2 is invalid
examination.cpp:44:10: error: expected ';' before 'i'
   44 |  for(int i = 0; i < q; i++) cin >> cutoffs[i][0] >> cutoffs[i][1] >> cutoffs[i][2];
      |          ^
examination.cpp:44:17: error: 'i' was not declared in this scope
   44 |  for(int i = 0; i < q; i++) cin >> cutoffs[i][0] >> cutoffs[i][1] >> cutoffs[i][2];
      |                 ^
examination.cpp:44:36: error: 'cutoffs' was not declared in this scope
   44 |  for(int i = 0; i < q; i++) cin >> cutoffs[i][0] >> cutoffs[i][1] >> cutoffs[i][2];
      |                                    ^~~~~~~
examination.cpp:45:10: error: expected ';' before 'i'
   45 |  for(int i = 0; i < q; i++)
      |          ^
examination.cpp:45:17: error: 'i' was not declared in this scope
   45 |  for(int i = 0; i < q; i++)
      |                 ^
examination.cpp:46:6: error: 'cutoffs' was not declared in this scope
   46 |   if(cutoffs[i][0] + cutoffs[i][1] >= cutoffs[i][2])
      |      ^~~~~~~
examination.cpp:5:12: error: request for member 'push_back' in 'c_sort1', which is of non-class type 'int'
    5 | #define pb push_back
      |            ^~~~~~~~~
examination.cpp:47:12: note: in expansion of macro 'pb'
   47 |    c_sort1.pb({{cutoffs[i][0], cutoffs[i][1]}, i});
      |            ^~
examination.cpp:48:15: error: request for member 'begin' in 'c_sort1', which is of non-class type 'int'
   48 |  sort(c_sort1.begin(), c_sort1.end());
      |               ^~~~~
examination.cpp:48:32: error: request for member 'end' in 'c_sort1', which is of non-class type 'int'
   48 |  sort(c_sort1.begin(), c_sort1.end());
      |                                ^~~
examination.cpp:49:6: error: expected ';' before 'idx'
   49 |  int idx = n - 1;
      |      ^~~
examination.cpp:50:9: error: 'BIT' was not declared in this scope
   50 |  memset(BIT, 0, sizeof(BIT));
      |         ^~~
examination.cpp:51:17: error: request for member 'empty' in 'c_sort1', which is of non-class type 'int'
   51 |  while(!c_sort1.empty()){
      |                 ^~~~~
examination.cpp:52:20: error: request for member 'back' in 'c_sort1', which is of non-class type 'int'
   52 |   auto x = c_sort1.back(); c_sort1.pop_back();
      |                    ^~~~
examination.cpp:52:36: error: request for member 'pop_back' in 'c_sort1', which is of non-class type 'int'
   52 |   auto x = c_sort1.back(); c_sort1.pop_back();
      |                                    ^~~~~~~~
examination.cpp:53:9: error: 'idx' was not declared in this scope; did you mean 'index'?
   53 |   while(idx >= 0 and a[idx].ff >= x.ff.ff){
      |         ^~~
      |         index
examination.cpp:54:4: error: 'upd' was not declared in this scope
   54 |    upd(a[idx].ss, 1); idx--;
      |    ^~~
examination.cpp:56:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   56 |   ans[x.ss] = sum(x.ff.ss, N - 1);
      |   ^~~
      |   abs
examination.cpp:56:28: error: 'N' was not declared in this scope
   56 |   ans[x.ss] = sum(x.ff.ss, N - 1);
      |                            ^
examination.cpp:56:15: error: 'sum' was not declared in this scope
   56 |   ans[x.ss] = sum(x.ff.ss, N - 1);
      |               ^~~
examination.cpp:58:24: error: template argument 1 is invalid
   58 |  vector<pair<int, int> > c_sort2;
      |                        ^
examination.cpp:58:24: error: template argument 2 is invalid
examination.cpp:59:10: error: expected ';' before 'i'
   59 |  for(int i = 0; i < q; i++)
      |          ^
examination.cpp:59:17: error: 'i' was not declared in this scope
   59 |  for(int i = 0; i < q; i++)
      |                 ^
examination.cpp:60:6: error: 'cutoffs' was not declared in this scope
   60 |   if(cutoffs[i][0] + cutoffs[i][1] < cutoffs[i][2])
      |      ^~~~~~~
examination.cpp:5:12: error: request for member 'push_back' in 'c_sort2', which is of non-class type 'int'
    5 | #define pb push_back
      |            ^~~~~~~~~
examination.cpp:61:12: note: in expansion of macro 'pb'
   61 |    c_sort2.pb({cutoffs[i][2], i});
      |            ^~
examination.cpp:62:15: error: request for member 'begin' in 'c_sort2', which is of non-class type 'int'
   62 |  sort(c_sort2.begin(), c_sort2.end());
      |               ^~~~~
examination.cpp:62:32: error: request for member 'end' in 'c_sort2', which is of non-class type 'int'
   62 |  sort(c_sort2.begin(), c_sort2.end());
      |                                ^~~
examination.cpp:63:9: error: request for member 'begin' in 'a', which is of non-class type 'int'
   63 |  sort(a.begin(), a.end(), cmp);
      |         ^~~~~
examination.cpp:63:20: error: request for member 'end' in 'a', which is of non-class type 'int'
   63 |  sort(a.begin(), a.end(), cmp);
      |                    ^~~
examination.cpp:64:9: error: 'bit' was not declared in this scope
   64 |  memset(bit, 0, sizeof(bit));
      |         ^~~
examination.cpp:65:2: error: 'idx' was not declared in this scope; did you mean 'index'?
   65 |  idx = n - 1;
      |  ^~~
      |  index
examination.cpp:66:10: error: expected ';' before 'i'
   66 |  for(int i = (int)c_sort2.size() - 1; i >= 0; i--){
      |          ^
examination.cpp:66:39: error: 'i' was not declared in this scope
   66 |  for(int i = (int)c_sort2.size() - 1; i >= 0; i--){
      |                                       ^
examination.cpp:68:4: error: 'upd' was not declared in this scope
   68 |    upd(a[idx].ff, 1);
      |    ^~~
examination.cpp:71:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   71 |   ans[c_sort2[i].ss] += n - idx - 1;
      |   ^~~
      |   abs
examination.cpp:72:32: error: 'cutoffs' was not declared in this scope
   72 |   ans[c_sort2[i].ss] -= sum(0, cutoffs[c_sort2[i].ss][0] - 1);
      |                                ^~~~~~~
examination.cpp:72:25: error: 'sum' was not declared in this scope
   72 |   ans[c_sort2[i].ss] -= sum(0, cutoffs[c_sort2[i].ss][0] - 1);
      |                         ^~~
examination.cpp:76:10: error: expected ';' before 'i'
   76 |  for(int i = (int)c_sort2.size() - 1; i >= 0; i--){
      |          ^
examination.cpp:76:39: error: 'i' was not declared in this scope
   76 |  for(int i = (int)c_sort2.size() - 1; i >= 0; i--){
      |                                       ^
examination.cpp:78:4: error: 'upd' was not declared in this scope
   78 |    upd(a[idx].ss, 1);
      |    ^~~
examination.cpp:81:3: error: 'ans' was not declared in this scope; did you mean 'abs'?
   81 |   ans[c_sort2[i].ss] -= sum(0, cutoffs[c_sort2[i].ss][1] - 1);
      |   ^~~
      |   abs
examination.cpp:81:32: error: 'cutoffs' was not declared in this scope
   81 |   ans[c_sort2[i].ss] -= sum(0, cutoffs[c_sort2[i].ss][1] - 1);
      |                                ^~~~~~~
examination.cpp:81:25: error: 'sum' was not declared in this scope
   81 |   ans[c_sort2[i].ss] -= sum(0, cutoffs[c_sort2[i].ss][1] - 1);
      |                         ^~~
examination.cpp:83:10: error: expected ';' before 'i'
   83 |  for(int i = 0; i < q; i++) cout << ans[i] << '\n';
      |          ^
examination.cpp:83:17: error: 'i' was not declared in this scope
   83 |  for(int i = 0; i < q; i++) cout << ans[i] << '\n';
      |                 ^
examination.cpp:83:37: error: 'ans' was not declared in this scope; did you mean 'abs'?
   83 |  for(int i = 0; i < q; i++) cout << ans[i] << '\n';
      |                                     ^~~
      |                                     abs