Submission #1110290

#TimeUsernameProblemLanguageResultExecution timeMemory
1110290KasymKSegments (IZhO18_segments)C++17
7 / 100
5072 ms10196 KiB
#include "bits/stdc++.h" using namespace std; #define ff first #define ss second #define all(v) v.begin(), v.end() #define ll long long #define pb push_back #define pii pair<int, int> #define pli pair<ll, int> #define pll pair<ll, ll> #define tr(i, c) for(auto i = c.begin(); i != c.end(); ++i) #define wr puts("----------------") template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;} template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;} int f(int a, int b, int c, int d){ if(a>c) swap(a,c), swap(b,d); if(b<c) return 0; if(b<=d) return b-c+1; return d-c+1; } int main(){ // freopen("file.txt", "r", stdin); int q, t, answer = 0; scanf("%d%d", &q, &t); multiset<array<int, 3>> S; int id = 0; map<int, pii> press; while(q--){ int op; scanf("%d", &op); if(op==1){ int a, b; scanf("%d%d", &a, &b); int l = a^(t*answer), r = b^(t*answer); if(l>r) swap(l, r); id++; press[id] = {l, r}; S.insert({id, l, r}); } else if(op==2){ int need; scanf("%d", &need); pii P = press[need]; S.erase({need, P.ff, P.ss}); } else{ int a, b, k; scanf("%d%d%d", &a, &b, &k); int l = a^(t*answer), r = b^(t*answer); if(l>r) swap(l, r); answer = 0; for(auto i : S) answer += f(l, r, i[1], i[2])>=k; printf("%d\n", answer); } } return 0; }

Compilation message (stderr)

segments.cpp: In function 'int main()':
segments.cpp:29:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |  scanf("%d%d", &q, &t);
      |  ~~~~~^~~~~~~~~~~~~~~~
segments.cpp:35:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   35 |   scanf("%d", &op);
      |   ~~~~~^~~~~~~~~~~
segments.cpp:38:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |    scanf("%d%d", &a, &b);
      |    ~~~~~^~~~~~~~~~~~~~~~
segments.cpp:48:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |    scanf("%d", &need);
      |    ~~~~~^~~~~~~~~~~~~
segments.cpp:54:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |    scanf("%d%d%d", &a, &b, &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...