Submission #797460

#TimeUsernameProblemLanguageResultExecution timeMemory
797460kingfran1907Segments (IZhO18_segments)C++14
7 / 100
5079 ms11388 KiB
#include <bits/stdc++.h> #define X first #define Y second using namespace std; const int maxn = 2e5+10; int n, t; set< int > s, cur; int l[maxn], r[maxn]; int inter(pair<int, int> a, pair<int, int> b) { if (a.X > b.X) swap(a, b); return min(a.Y, b.Y) - b.X + 1; } int main() { scanf("%d%d", &n, &t); for (int i = 1; i <= n + 2; i++) s.insert(i); int lastans = 0; int ptr = 0; while (n--) { int type; scanf("%d", &type); if (type == 1) { int ind = ++ptr; int l, r; scanf("%d%d", &l, &r); l = l ^ (t * lastans); r = r ^ (t * lastans); if (l > r) swap(l, r); ::l[ind] = l, ::r[ind] = r; cur.insert(ind); } else if (type == 2) { int x; scanf("%d", &x); cur.erase(x); s.insert(x); } else { int l, r, k; scanf("%d%d%d", &l, &r, &k); l = l ^ (t * lastans); r = r ^ (t * lastans); if (l > r) swap(l, r); lastans = 0; for (int tren : cur) { lastans += (inter({l, r}, {::l[tren], ::r[tren]}) >= k); } printf("%d\n", lastans); } } return 0; }

Compilation message (stderr)

segments.cpp: In function 'int main()':
segments.cpp:19:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |  scanf("%d%d", &n, &t);
      |  ~~~~~^~~~~~~~~~~~~~~~
segments.cpp:26:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   26 |   scanf("%d", &type);
      |   ~~~~~^~~~~~~~~~~~~
segments.cpp:31:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |    scanf("%d%d", &l, &r);
      |    ~~~~~^~~~~~~~~~~~~~~~
segments.cpp:40:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   40 |    scanf("%d", &x);
      |    ~~~~~^~~~~~~~~~
segments.cpp:45:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |    scanf("%d%d%d", &l, &r, &k);
      |    ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...